Rename YogaNode.parent -> YogaNode.owner

Reviewed By: priteshrnandgaonkar

Differential Revision: D7352778

fbshipit-source-id: dcf1af5e72bfc3063b5c4bda197d7952a9194768
This commit is contained in:
David Vacca
2018-04-01 18:27:06 -07:00
committed by Facebook Github Bot
parent aff5a75d8e
commit 29ff30c539
11 changed files with 297 additions and 284 deletions

View File

@@ -301,7 +301,7 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
+ "')");
}
// TODO: T26729293 This is a temporary code that will be replaced as part of T26729293.
YogaNode parent = childYogaNode.getParent();
YogaNode parent = childYogaNode.getOwner();
if (parent != null) {
for (int k = 0; k < parent.getChildCount(); k++) {
if (parent.getChildAt(k) == childYogaNode) {

View File

@@ -29,7 +29,7 @@ public class YogaNode implements Cloneable {
*/
static native int jni_YGNodeGetInstanceCount();
private YogaNode mParent;
private YogaNode mOwner;
private List<YogaNode> mChildren;
private YogaMeasureFunction mMeasureFunction;
private YogaBaselineFunction mBaselineFunction;
@@ -152,7 +152,7 @@ public class YogaNode implements Cloneable {
private native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index);
public void addChildAt(YogaNode child, int i) {
if (child.mParent != null) {
if (child.mOwner != null) {
throw new IllegalStateException("Child already has a parent, it must be removed first.");
}
@@ -160,7 +160,7 @@ public class YogaNode implements Cloneable {
mChildren = new ArrayList<>(4);
}
mChildren.add(i, child);
child.mParent = this;
child.mOwner = this;
jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i);
}
@@ -180,15 +180,23 @@ public class YogaNode implements Cloneable {
public YogaNode removeChildAt(int i) {
final YogaNode child = mChildren.remove(i);
child.mParent = null;
child.mOwner = null;
jni_YGNodeRemoveChild(mNativePointer, child.mNativePointer);
return child;
}
/**
* @returns the {@link YogaNode} that owns this {@link YogaNode}.
* The owner is used to identify the YogaTree that a {@link YogaNode} belongs
* to.
* This method will return the parent of the {@link YogaNode} when the
* {@link YogaNode} only belongs to one YogaTree or null when the
* {@link YogaNode} is shared between two or more YogaTrees.
*/
@Nullable
public
YogaNode getParent() {
return mParent;
YogaNode getOwner() {
return mOwner;
}
public int indexOf(YogaNode child) {