Disable YogaNode cloning in Android

Reviewed By: achen1

Differential Revision: D7313239

fbshipit-source-id: ecf905a22e04a2115ab968fd29f7582301f0f3c9
This commit is contained in:
David Vacca 2018-03-19 18:21:34 -07:00 committed by Facebook Github Bot
parent e2462e9016
commit 0930fef46d

View File

@ -111,8 +111,7 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
} }
} }
public ReactShadowNodeImpl(ReactShadowNodeImpl original) { protected ReactShadowNodeImpl(ReactShadowNodeImpl original) {
try {
mReactTag = original.mReactTag; mReactTag = original.mReactTag;
mRootTag = original.mRootTag; mRootTag = original.mRootTag;
mViewClassName = original.mViewClassName; mViewClassName = original.mViewClassName;
@ -120,11 +119,9 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
mThemedContext = original.mThemedContext; mThemedContext = original.mThemedContext;
mShouldNotifyOnLayout = original.mShouldNotifyOnLayout; mShouldNotifyOnLayout = original.mShouldNotifyOnLayout;
mNodeUpdated = original.mNodeUpdated; mNodeUpdated = original.mNodeUpdated;
mChildren = original.mChildren == null ? null : new ArrayList<>(original.mChildren);
mIsLayoutOnly = original.mIsLayoutOnly; mIsLayoutOnly = original.mIsLayoutOnly;
mTotalNativeChildren = original.mTotalNativeChildren; mTotalNativeChildren = original.mTotalNativeChildren;
mNativeParent = original.mNativeParent; mNativeParent = original.mNativeParent;
mNativeChildren = original.mNativeChildren == null ? null : new ArrayList<>(original.mNativeChildren);
mNativeParent = original.mNativeParent; mNativeParent = original.mNativeParent;
mScreenX = original.mScreenX; mScreenX = original.mScreenX;
mScreenY = original.mScreenY; mScreenY = original.mScreenY;
@ -132,14 +129,14 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
mScreenHeight = original.mScreenHeight; mScreenHeight = original.mScreenHeight;
arraycopy(original.mPadding, 0, mPadding, 0, original.mPadding.length); arraycopy(original.mPadding, 0, mPadding, 0, original.mPadding.length);
arraycopy(original.mPaddingIsPercent, 0, mPaddingIsPercent, 0, original.mPaddingIsPercent.length); arraycopy(original.mPaddingIsPercent, 0, mPaddingIsPercent, 0, original.mPaddingIsPercent.length);
mYogaNode = original.mYogaNode.clone();
mYogaNode.setData(this);
mParent = null;
mNewProps = null; mNewProps = null;
} catch (CloneNotSupportedException e) { mParent = null;
// it should never happen mYogaNode = original.mYogaNode;
throw new IllegalArgumentException(); // TODO: T26729293 clone YogaNode instead of reusing the same instance
} //mYogaNode = original.mYogaNode.clone();
mNativeChildren = original.mNativeChildren == null ? null : new ArrayList<>(original.mNativeChildren);
mChildren = original.mChildren == null ? null : new ArrayList<>(original.mChildren);
mYogaNode.setData(this);
} }
@Override @Override
@ -279,6 +276,16 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
+ toString() + toString()
+ "')"); + "')");
} }
// TODO: T26729293 This is a temporary code that will be replaced as part of T26729293.
YogaNode parent = childYogaNode.getParent();
if (parent != null) {
for (int k = 0; k < parent.getChildCount(); k++) {
if (parent.getChildAt(k) == childYogaNode) {
parent.removeChildAt(k);
break;
}
}
}
mYogaNode.addChildAt(childYogaNode, i); mYogaNode.addChildAt(childYogaNode, i);
} }
markUpdated(); markUpdated();