Adding configuration of Fabric inside ReactRootView.

Reviewed By: achen1

Differential Revision: D7102701

fbshipit-source-id: f655327372c42ad86042011a3af3ee693d14014a
This commit is contained in:
David Vacca 2018-03-01 10:24:14 -08:00 committed by Facebook Github Bot
parent 6b45fb2cb1
commit b5b0ee853e
4 changed files with 25 additions and 4 deletions

View File

@ -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(

View File

@ -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;

View File

@ -361,7 +361,7 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
float absoluteX,
float absoluteY,
UIViewOperationQueue uiViewOperationQueue,
NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer) {
@Nullable NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer) {
if (mNodeUpdated) {
onCollectExtraUpdates(uiViewOperationQueue);
}
@ -391,7 +391,18 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
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;

View File

@ -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,