Avoid holding references to ReactShadowNode after a tree is commited
Reviewed By: achen1 Differential Revision: D7495721 fbshipit-source-id: 33d5bba5040729f891455a9c330234fe25130b02
This commit is contained in:
parent
9fd2b9a75f
commit
bf7601fde1
|
@ -329,6 +329,9 @@ public class FabricUIManager implements UIManager {
|
|||
boolean frameDidChange =
|
||||
node.dispatchUpdates(absoluteX, absoluteY, mUIViewOperationQueue, null);
|
||||
}
|
||||
// Set the reference to the OriginalReactShadowNode to NULL, as the tree is already committed
|
||||
// and we do not need to hold references to the previous tree anymore
|
||||
node.setOriginalReactShadowNode(null);
|
||||
node.markUpdateSeen();
|
||||
}
|
||||
|
||||
|
|
|
@ -131,13 +131,16 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
|
|||
mViewClassName = original.mViewClassName;
|
||||
mThemedContext = original.mThemedContext;
|
||||
mShouldNotifyOnLayout = original.mShouldNotifyOnLayout;
|
||||
mNodeUpdated = original.mNodeUpdated;
|
||||
mIsLayoutOnly = original.mIsLayoutOnly;
|
||||
mNativeParent = original.mNativeParent;
|
||||
mScreenX = original.mScreenX;
|
||||
mScreenY = original.mScreenY;
|
||||
mScreenWidth = original.mScreenWidth;
|
||||
mScreenHeight = original.mScreenHeight;
|
||||
// Cloned nodes should be always updated.
|
||||
mNodeUpdated = true;
|
||||
// "cached" screen coordinates are not cloned because FabricJS not always clone the last
|
||||
// ReactShadowNode that was rendered in the screen.
|
||||
mScreenX = 0;
|
||||
mScreenY = 0;
|
||||
mScreenWidth = 0;
|
||||
mScreenHeight = 0;
|
||||
arraycopy(original.mPadding, 0, mPadding, 0, original.mPadding.length);
|
||||
arraycopy(original.mPaddingIsPercent, 0, mPaddingIsPercent, 0, original.mPaddingIsPercent.length);
|
||||
mNewProps = null;
|
||||
|
@ -148,6 +151,7 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
|
|||
private void replaceChild(ReactShadowNodeImpl newNode, int childIndex) {
|
||||
mChildren.remove(childIndex);
|
||||
mChildren.add(childIndex, newNode);
|
||||
newNode.mParent = this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -164,14 +168,7 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
|
|||
copy.mNativeChildren = mNativeChildren == null ? null : new ArrayList<>(mNativeChildren);
|
||||
copy.mTotalNativeChildren = mTotalNativeChildren;
|
||||
copy.mChildren = mChildren == null ? null : new ArrayList<>(mChildren);
|
||||
copy.mYogaNode.setData(this);
|
||||
if (mChildren != null) {
|
||||
for (ReactShadowNode child : mChildren) {
|
||||
if (child.getOriginalReactShadowNode() == null) {
|
||||
child.setOriginalReactShadowNode(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
copy.mYogaNode.setData(copy);
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
@ -182,7 +179,7 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
|
|||
copy.mNativeChildren = null;
|
||||
copy.mChildren = null;
|
||||
copy.mTotalNativeChildren = 0;
|
||||
copy.mYogaNode.setData(this);
|
||||
copy.mYogaNode.setData(copy);
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
@ -306,16 +303,6 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
|
|||
+ toString()
|
||||
+ "')");
|
||||
}
|
||||
// TODO: T26729293 This is a temporary code that will be replaced as part of T26729293.
|
||||
YogaNode parent = childYogaNode.getOwner();
|
||||
if (parent != null) {
|
||||
for (int k = 0; k < parent.getChildCount(); k++) {
|
||||
if (parent.getChildAt(k) == childYogaNode) {
|
||||
parent.removeChildAt(k);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
mYogaNode.addChildAt(childYogaNode, i);
|
||||
}
|
||||
markUpdated();
|
||||
|
|
Loading…
Reference in New Issue