From b5b0ee853e91822c1a6390ab9694db31cf94cd99 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Thu, 1 Mar 2018 10:24:14 -0800 Subject: [PATCH] Adding configuration of Fabric inside ReactRootView. Reviewed By: achen1 Differential Revision: D7102701 fbshipit-source-id: f655327372c42ad86042011a3af3ee693d14014a --- .../com/facebook/react/ReactInstanceManager.java | 3 ++- .../java/com/facebook/react/ReactRootView.java | 9 +++++++++ .../react/uimanager/ReactShadowNodeImpl.java | 15 +++++++++++++-- .../react/uimanager/UIViewOperationQueue.java | 2 +- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index 711e18001..0b24f48db 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -1007,7 +1007,8 @@ public class ReactInstanceManager { CatalystInstance catalystInstance) { Log.d(ReactConstants.TAG, "ReactInstanceManager.attachRootViewToInstance()"); Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachRootViewToInstance"); - final int rootTag = catalystInstance.getNativeModule(UIManagerModule.class).addRootView(rootView); + UIManager uiManagerModule = rootView.isFabric() ? catalystInstance.getFabricUIManager() : catalystInstance.getNativeModule(UIManagerModule.class); + final int rootTag = uiManagerModule.addRootView(rootView); rootView.setRootViewTag(rootTag); rootView.invokeJSEntryPoint(); Systrace.beginAsyncSection( diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index 711d1795e..1bed2f5bb 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -88,6 +88,7 @@ public class ReactRootView extends SizeMonitoringFrameLayout private int mWidthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); private int mHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); private @Nullable Runnable mJSEntryPoint; + private boolean mIsFabric = false; public ReactRootView(Context context) { super(context); @@ -523,6 +524,14 @@ public class ReactRootView extends SizeMonitoringFrameLayout mReactInstanceManager.getCurrentReactContext().handleException(e); } + public void setIsFabric(boolean isFabric) { + mIsFabric = isFabric; + } + + public boolean isFabric() { + return mIsFabric; + } + @Nullable public ReactInstanceManager getReactInstanceManager() { return mReactInstanceManager; diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNodeImpl.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNodeImpl.java index 92a4d57fe..449f85cc5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNodeImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNodeImpl.java @@ -361,7 +361,7 @@ public class ReactShadowNodeImpl implements ReactShadowNode float absoluteX, float absoluteY, UIViewOperationQueue uiViewOperationQueue, - NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer) { + @Nullable NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer) { if (mNodeUpdated) { onCollectExtraUpdates(uiViewOperationQueue); } @@ -391,7 +391,18 @@ public class ReactShadowNodeImpl implements ReactShadowNode mScreenHeight = newScreenHeight; if (layoutHasChanged) { - nativeViewHierarchyOptimizer.handleUpdateLayout(this); + //TODO: T26400974 ReactShadowNode should not depend on nativeViewHierarchyOptimizer + if (nativeViewHierarchyOptimizer != null) { + nativeViewHierarchyOptimizer.handleUpdateLayout(this); + } else { + uiViewOperationQueue.enqueueUpdateLayout( + getParent().getReactTag(), + getReactTag(), + getScreenX(), + getScreenY(), + getScreenWidth(), + getScreenHeight()); + } } return layoutHasChanged; diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java index 5cef75341..1f2135db8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java @@ -764,7 +764,7 @@ public class UIViewOperationQueue { mOperations.add(0, new UIBlockOperation(block)); } - /* package */ void dispatchViewUpdates( + public void dispatchViewUpdates( final int batchId, final long commitStartTime, final long layoutTime) { SystraceMessage.beginSection( Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,