Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numpad keypress not logging #1

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion React/Views/ScrollView/RCTScrollContentView.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ - (void)reactSetFrame:(CGRect)frame

RCTAssert([scrollView isKindOfClass:[RCTScrollView class]], @"Unexpected view hierarchy of RCTScrollView component.");

[scrollView updateContentOffsetIfNeeded];
[scrollView updateContentSizeIfNeeded];
}

@end
8 changes: 1 addition & 7 deletions React/Views/ScrollView/RCTScrollView.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@
*/
@property (nonatomic, readonly) UIView *contentView;

/**
* If the `contentSize` is not specified (or is specified as {0, 0}, then the
* `contentSize` will automatically be determined by the size of the subview.
*/
@property (nonatomic, assign) CGSize contentSize;

/**
* The underlying scrollView (TODO: can we remove this?)
*/
Expand Down Expand Up @@ -68,7 +62,7 @@

@interface RCTScrollView (Internal)

- (void)updateContentOffsetIfNeeded;
- (void)updateContentSizeIfNeeded;

@end

Expand Down
62 changes: 2 additions & 60 deletions React/Views/ScrollView/RCTScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ - (instancetype)initWithEventDispatcher:(id<RCTEventDispatcherProtocol>)eventDis

_automaticallyAdjustContentInsets = YES;
_contentInset = UIEdgeInsetsZero;
_contentSize = CGSizeZero;
_lastClippedToRect = CGRectNull;

_scrollEventThrottle = 0.0;
Expand Down Expand Up @@ -381,7 +380,7 @@ - (void)didUpdateReactSubviews
- (void)didSetProps:(NSArray<NSString *> *)changedProps
{
if ([changedProps containsObject:@"contentSize"]) {
[self updateContentOffsetIfNeeded];
[self updateContentSizeIfNeeded];
}
}

Expand Down Expand Up @@ -799,8 +798,6 @@ - (UIView *)viewForZoomingInScrollView:(__unused UIScrollView *)scrollView
return _contentView;
}

#pragma mark - Setters

- (CGSize)_calculateViewportSize
{
CGSize viewportSize = self.bounds.size;
Expand All @@ -813,71 +810,16 @@ - (CGSize)_calculateViewportSize
return viewportSize;
}

- (CGPoint)calculateOffsetForContentSize:(CGSize)newContentSize
{
CGPoint oldOffset = _scrollView.contentOffset;
CGPoint newOffset = oldOffset;

CGSize oldContentSize = _scrollView.contentSize;
CGSize viewportSize = [self _calculateViewportSize];

BOOL fitsinViewportY = oldContentSize.height <= viewportSize.height && newContentSize.height <= viewportSize.height;
if (newContentSize.height < oldContentSize.height && !fitsinViewportY) {
CGFloat offsetHeight = oldOffset.y + viewportSize.height;
if (oldOffset.y < 0) {
// overscrolled on top, leave offset alone
} else if (offsetHeight > oldContentSize.height) {
// overscrolled on the bottom, preserve overscroll amount
newOffset.y = MAX(0, oldOffset.y - (oldContentSize.height - newContentSize.height));
} else if (offsetHeight > newContentSize.height) {
// offset falls outside of bounds, scroll back to end of list
newOffset.y = MAX(0, newContentSize.height - viewportSize.height);
}
}

BOOL fitsinViewportX = oldContentSize.width <= viewportSize.width && newContentSize.width <= viewportSize.width;
if (newContentSize.width < oldContentSize.width && !fitsinViewportX) {
CGFloat offsetHeight = oldOffset.x + viewportSize.width;
if (oldOffset.x < 0) {
// overscrolled at the beginning, leave offset alone
} else if (offsetHeight > oldContentSize.width && newContentSize.width > viewportSize.width) {
// overscrolled at the end, preserve overscroll amount as much as possible
newOffset.x = MAX(0, oldOffset.x - (oldContentSize.width - newContentSize.width));
} else if (offsetHeight > newContentSize.width) {
// offset falls outside of bounds, scroll back to end
newOffset.x = MAX(0, newContentSize.width - viewportSize.width);
}
}

// all other cases, offset doesn't change
return newOffset;
}

/**
* Once you set the `contentSize`, to a nonzero value, it is assumed to be
* managed by you, and we'll never automatically compute the size for you,
* unless you manually reset it back to {0, 0}
*/
- (CGSize)contentSize
{
if (!CGSizeEqualToSize(_contentSize, CGSizeZero)) {
return _contentSize;
}

return _contentView.frame.size;
}

- (void)updateContentOffsetIfNeeded
- (void)updateContentSizeIfNeeded
{
CGSize contentSize = self.contentSize;
if (!CGSizeEqualToSize(_scrollView.contentSize, contentSize)) {
// When contentSize is set manually, ScrollView internals will reset
// contentOffset to {0, 0}. Since we potentially set contentSize whenever
// anything in the ScrollView updates, we workaround this issue by manually
// adjusting contentOffset whenever this happens
CGPoint newOffset = [self calculateOffsetForContentSize:contentSize];
_scrollView.contentSize = contentSize;
_scrollView.contentOffset = newOffset;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.facebook.infer.annotation.Assertions;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.config.ReactFeatureFlags;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
Expand Down Expand Up @@ -89,64 +88,6 @@ private HashMap<String, Object> getLocalMap() {
return mLocalTypeMap;
}

private Iterator<Map.Entry<String, Object>> createExperimentalIterator() {
if (mKeys == null) {
mKeys = Assertions.assertNotNull(importKeys());
}
final String[] iteratorKeys = mKeys;
final Object[] iteratorValues = Assertions.assertNotNull(importValues());
return new Iterator<Map.Entry<String, Object>>() {
int currentIndex = 0;

@Override
public boolean hasNext() {
return currentIndex < iteratorKeys.length;
}

@Override
public Map.Entry<String, Object> next() {
final int index = currentIndex++;
return new Map.Entry<String, Object>() {
@Override
public String getKey() {
return iteratorKeys[index];
}

@Override
public Object getValue() {
return iteratorValues[index];
}

@Override
public Object setValue(Object value) {
throw new UnsupportedOperationException(
"Can't set a value while iterating over a ReadableNativeMap");
}
};
}
};
}

private ReadableMapKeySetIterator createExperimentalKeySetIterator() {
if (mKeys == null) {
mKeys = Assertions.assertNotNull(importKeys());
}
final String[] iteratorKeys = mKeys;
return new ReadableMapKeySetIterator() {
int currentIndex = 0;

@Override
public boolean hasNextKey() {
return currentIndex < iteratorKeys.length;
}

@Override
public String nextKey() {
return iteratorKeys[currentIndex++];
}
};
}

private native Object[] importTypes();

@Override
Expand Down Expand Up @@ -246,16 +187,62 @@ public int getInt(@NonNull String name) {

@Override
public @NonNull Iterator<Map.Entry<String, Object>> getEntryIterator() {
return ReactFeatureFlags.enableExperimentalReadableNativeMapIterator
? createExperimentalIterator()
: getLocalMap().entrySet().iterator();
if (mKeys == null) {
mKeys = Assertions.assertNotNull(importKeys());
}
final String[] iteratorKeys = mKeys;
final Object[] iteratorValues = Assertions.assertNotNull(importValues());
return new Iterator<Map.Entry<String, Object>>() {
int currentIndex = 0;

@Override
public boolean hasNext() {
return currentIndex < iteratorKeys.length;
}

@Override
public Map.Entry<String, Object> next() {
final int index = currentIndex++;
return new Map.Entry<String, Object>() {
@Override
public String getKey() {
return iteratorKeys[index];
}

@Override
public Object getValue() {
return iteratorValues[index];
}

@Override
public Object setValue(Object value) {
throw new UnsupportedOperationException(
"Can't set a value while iterating over a ReadableNativeMap");
}
};
}
};
}

@Override
public @NonNull ReadableMapKeySetIterator keySetIterator() {
return ReactFeatureFlags.enableExperimentalReadableNativeMapIterator
? createExperimentalKeySetIterator()
: new ReadableNativeMapKeySetIterator(this);
if (mKeys == null) {
mKeys = Assertions.assertNotNull(importKeys());
}
final String[] iteratorKeys = mKeys;
return new ReadableMapKeySetIterator() {
int currentIndex = 0;

@Override
public boolean hasNextKey() {
return currentIndex < iteratorKeys.length;
}

@Override
public String nextKey() {
return iteratorKeys[currentIndex++];
}
};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ public class ReactFeatureFlags {
/** Feature flag to configure eager initialization of Fabric */
public static boolean eagerInitializeFabric = false;

/** Use lock-free data structures for Fabric MountItems. */
public static boolean enableLockFreeMountInstructions = false;

/** Disable UI update operations in non-Fabric renderer after catalyst instance was destroyed */
public static boolean disableNonFabricViewOperationsOnCatalystDestroy = false;

Expand All @@ -69,9 +66,6 @@ public class ReactFeatureFlags {
*/
public static boolean enableStartSurfaceRaceConditionFix = false;

/** Enables the usage of an experimental optimized iterator for ReadableNativeMaps. */
public static boolean enableExperimentalReadableNativeMapIterator = false;

/** Enables Static ViewConfig in RN Android native code. */
public static boolean enableExperimentalStaticViewConfigs = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package com.facebook.react.fabric;

import androidx.annotation.NonNull;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.JSIModuleProvider;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.UIManager;
Expand All @@ -18,40 +17,36 @@
import com.facebook.react.fabric.events.FabricEventEmitter;
import com.facebook.react.fabric.mounting.LayoutMetricsConversions;
import com.facebook.react.fabric.mounting.MountingManager;
import com.facebook.react.fabric.mounting.mountitems.BatchMountItem;
import com.facebook.react.fabric.mounting.mountitems.CreateMountItem;
import com.facebook.react.fabric.mounting.mountitems.DispatchCommandMountItem;
import com.facebook.react.fabric.mounting.mountitems.DispatchIntCommandMountItem;
import com.facebook.react.fabric.mounting.mountitems.DispatchStringCommandMountItem;
import com.facebook.react.fabric.mounting.mountitems.InsertMountItem;
import com.facebook.react.fabric.mounting.mountitems.IntBufferBatchMountItem;
import com.facebook.react.fabric.mounting.mountitems.MountItem;
import com.facebook.react.fabric.mounting.mountitems.PreAllocateViewMountItem;
import com.facebook.react.fabric.mounting.mountitems.RemoveDeleteMultiMountItem;
import com.facebook.react.fabric.mounting.mountitems.SendAccessibilityEvent;
import com.facebook.react.fabric.mounting.mountitems.UpdateEventEmitterMountItem;
import com.facebook.react.fabric.mounting.mountitems.UpdateLayoutMountItem;
import com.facebook.react.fabric.mounting.mountitems.UpdatePaddingMountItem;
import com.facebook.react.fabric.mounting.mountitems.UpdatePropsMountItem;
import com.facebook.react.fabric.mounting.mountitems.UpdateStateMountItem;
import com.facebook.react.uimanager.StateWrapper;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManagerRegistry;
import com.facebook.react.uimanager.events.BatchEventDispatchedListener;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.uimanager.events.EventDispatcherImpl;
import com.facebook.systrace.Systrace;

public class FabricJSIModuleProvider implements JSIModuleProvider<UIManager> {

@NonNull private final ReactApplicationContext mReactApplicationContext;
@NonNull private final ComponentFactory mComponentFactory;
@NonNull private final ReactNativeConfig mConfig;
@NonNull private final ViewManagerRegistry mViewManagerRegistry;

public FabricJSIModuleProvider(
@NonNull ReactApplicationContext reactApplicationContext,
@NonNull ComponentFactory componentFactory,
@NonNull ReactNativeConfig config) {
@NonNull ReactNativeConfig config,
@NonNull ViewManagerRegistry viewManagerRegistry) {
mReactApplicationContext = reactApplicationContext;
mComponentFactory = componentFactory;
mConfig = config;
mViewManagerRegistry = viewManagerRegistry;
}

@Override
Expand Down Expand Up @@ -87,15 +82,10 @@ public UIManager get() {
private FabricUIManager createUIManager(@NonNull EventBeatManager eventBeatManager) {
Systrace.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricJSIModuleProvider.createUIManager");
UIManagerModule nativeModule =
Assertions.assertNotNull(mReactApplicationContext.getNativeModule(UIManagerModule.class));
EventDispatcher eventDispatcher = nativeModule.getEventDispatcher();
EventDispatcher eventDispatcher = new EventDispatcherImpl(mReactApplicationContext);
FabricUIManager fabricUIManager =
new FabricUIManager(
mReactApplicationContext,
nativeModule.getViewManagerRegistry_DO_NOT_USE(),
eventDispatcher,
eventBeatManager);
mReactApplicationContext, mViewManagerRegistry, eventDispatcher, eventBeatManager);

Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
return fabricUIManager;
Expand All @@ -107,21 +97,12 @@ private static void loadClasses() {
EventBeatManager.class.getClass();
EventEmitterWrapper.class.getClass();
FabricEventEmitter.class.getClass();
BatchMountItem.class.getClass();
CreateMountItem.class.getClass();
DispatchCommandMountItem.class.getClass();
DispatchIntCommandMountItem.class.getClass();
DispatchStringCommandMountItem.class.getClass();
InsertMountItem.class.getClass();
MountItem.class.getClass();
PreAllocateViewMountItem.class.getClass();
RemoveDeleteMultiMountItem.class.getClass();
SendAccessibilityEvent.class.getClass();
UpdateEventEmitterMountItem.class.getClass();
UpdateLayoutMountItem.class.getClass();
UpdatePaddingMountItem.class.getClass();
UpdatePropsMountItem.class.getClass();
UpdateStateMountItem.class.getClass();
LayoutMetricsConversions.class.getClass();
MountingManager.class.getClass();
Binding.class.getClass();
Expand All @@ -134,5 +115,6 @@ private static void loadClasses() {
StateWrapperImpl.class.getClass();
BatchEventDispatchedListener.class.getClass();
ReactNativeConfig.class.getClass();
IntBufferBatchMountItem.class.getClass();
}
}
Loading