From 3f84a0a6f483aed1aeb93820550451c9f35eb726 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Mon, 19 Mar 2018 18:21:37 -0700 Subject: [PATCH] Extend ReactShadowNode in order to have a reference to the ReactShadowNode that was used to clone a node Reviewed By: achen1 Differential Revision: D7289345 fbshipit-source-id: 34bfba8aca43299a3a8929a0e3eb85721f736dd0 --- .../com/facebook/react/uimanager/ReactShadowNode.java | 8 ++++++++ .../facebook/react/uimanager/ReactShadowNodeImpl.java | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java index 75ae4fb8a..dbf64b135 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java @@ -365,4 +365,12 @@ public interface ReactShadowNode { * {@link ReactShadowNode}. */ List getChildrenList(); + + /** + * @return the {@link ReactShadowNode} that was used during the cloning mechanism to create + * this {@link ReactShadowNode} or null if this object was not created using a clone operation. + */ + @Nullable ReactShadowNode getOriginalReactShadowNode(); + + void setOriginalReactShadowNode(@Nullable ReactShadowNode node); } 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 7673c4523..d097842e4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNodeImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNodeImpl.java @@ -99,6 +99,7 @@ public class ReactShadowNodeImpl implements ReactShadowNode private final float[] mPadding = new float[Spacing.ALL + 1]; private final boolean[] mPaddingIsPercent = new boolean[Spacing.ALL + 1]; private YogaNode mYogaNode; + private ReactShadowNode mOriginalReactShadowNode = null; private @Nullable ReactStylesDiffMap mNewProps; @@ -1072,4 +1073,14 @@ public class ReactShadowNodeImpl implements ReactShadowNode public List getChildrenList() { return mChildren == null ? null : Collections.unmodifiableList(mChildren); } + + @Override + public ReactShadowNode getOriginalReactShadowNode() { + return mOriginalReactShadowNode; + } + + @Override + public void setOriginalReactShadowNode(ReactShadowNode node) { + mOriginalReactShadowNode = node; + } }