Refactor ReactShadowNode.SetRootNode() -> ReactShadowNode.setRootTag()

Reviewed By: achen1

Differential Revision: D7419566

fbshipit-source-id: 6be790972e88b879fe690acd4f23d0caa27964a4
This commit is contained in:
David Vacca 2018-03-28 23:17:32 -07:00 committed by Facebook Github Bot
parent b531612b2c
commit e88f128608
5 changed files with 11 additions and 12 deletions

View File

@ -77,7 +77,7 @@ public class FabricUIManager implements UIManager {
ViewManager viewManager = mViewManagerRegistry.get(viewName);
ReactShadowNode node = viewManager.createShadowNodeInstance(mReactApplicationContext);
ReactShadowNode rootNode = getRootNode(rootTag);
node.setRootNode(rootNode);
node.setRootTag(rootNode.getReactTag());
node.setViewClassName(viewName);
node.setReactTag(reactTag);
node.setThemedContext(rootNode.getThemedContext());

View File

@ -407,7 +407,7 @@ public class NativeViewHierarchyOptimizer {
// Create the view since it doesn't exist in the native hierarchy yet
mUIViewOperationQueue.enqueueCreateView(
node.getRootNode().getThemedContext(),
node.getThemedContext(),
node.getReactTag(),
node.getViewClass(),
props);

View File

@ -139,9 +139,9 @@ public interface ReactShadowNode<T extends ReactShadowNode> {
void setReactTag(int reactTag);
T getRootNode();
int getRootTag();
void setRootNode(T rootNode);
void setRootTag(int rootTag);
void setViewClassName(String viewClassName);

View File

@ -78,7 +78,6 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
private int mReactTag;
private @Nullable String mViewClassName;
private @Nullable ReactShadowNodeImpl mRootNode;
private int mRootTag;
private @Nullable ThemedReactContext mThemedContext;
private boolean mShouldNotifyOnLayout;
@ -118,7 +117,6 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
mReactTag = original.mReactTag;
mRootTag = original.mRootTag;
mViewClassName = original.mViewClassName;
mRootNode = original.mRootNode;
mThemedContext = original.mThemedContext;
mShouldNotifyOnLayout = original.mShouldNotifyOnLayout;
mNodeUpdated = original.mNodeUpdated;
@ -493,13 +491,14 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
}
@Override
public final ReactShadowNodeImpl getRootNode() {
return Assertions.assertNotNull(mRootNode);
public final int getRootTag() {
Assertions.assertCondition(mRootTag != 0);
return mRootTag;
}
@Override
public final void setRootNode(ReactShadowNodeImpl rootNode) {
mRootNode = rootNode;
public final void setRootTag(int rootTag) {
mRootTag = rootTag;
}
@Override

View File

@ -279,7 +279,7 @@ public class UIImplementation {
Assertions.assertNotNull(rootNode, "Root node with tag " + rootViewTag + " doesn't exist");
cssNode.setReactTag(tag);
cssNode.setViewClassName(className);
cssNode.setRootNode(rootNode);
cssNode.setRootTag(rootNode.getReactTag());
cssNode.setThemedContext(rootNode.getThemedContext());
mShadowNodeRegistry.addNode(cssNode);
@ -1008,7 +1008,7 @@ public class UIImplementation {
ReactShadowNode node = resolveShadowNode(reactTag);
int rootTag = 0;
if (node != null) {
rootTag = node.getRootNode().getReactTag();
rootTag = node.getRootTag();
} else {
FLog.w(
ReactConstants.TAG,