Add YogaNode.cloneWithoutChildren
Summary: Adding flat clone method back to YogaNode for reconciliation. Reviewed By: davidaurelio Differential Revision: D14683019 fbshipit-source-id: 08ed2ffbb16052cb11aa464f67a7ba9a64297985
This commit is contained in:
committed by
Facebook Github Bot
parent
e0bc0ebe29
commit
a1e47e37ae
@@ -111,4 +111,5 @@ public class YogaNative {
|
||||
static native void jni_YGNodeSetHasBaselineFunc(long nativePointer, boolean hasMeasureFunc);
|
||||
static native void jni_YGNodePrint(long nativePointer);
|
||||
static native void jni_YGNodeSetStyleInputs(long nativePointer, float[] styleInputsArray, int size);
|
||||
static native long jni_YGNodeClone(long nativePointer);
|
||||
}
|
||||
|
@@ -221,4 +221,6 @@ public abstract class YogaNode {
|
||||
public abstract void print();
|
||||
|
||||
public abstract void setStyleInputs(float[] styleInputs, int size);
|
||||
|
||||
public abstract YogaNode cloneWithoutChildren();
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@DoNotStrip
|
||||
public abstract class YogaNodeJNIBase extends YogaNode {
|
||||
public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
|
||||
@Nullable private YogaNodeJNIBase mOwner;
|
||||
@Nullable private List<YogaNodeJNIBase> mChildren;
|
||||
@@ -93,6 +93,21 @@ public abstract class YogaNodeJNIBase extends YogaNode {
|
||||
return YogaNative.jni_YGNodeIsReferenceBaseline(mNativePointer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public YogaNodeJNIBase cloneWithoutChildren() {
|
||||
try {
|
||||
YogaNodeJNIBase clonedYogaNode = (YogaNodeJNIBase) super.clone();
|
||||
long clonedNativePointer = YogaNative.jni_YGNodeClone(mNativePointer);
|
||||
clonedYogaNode.mOwner = null;
|
||||
clonedYogaNode.mNativePointer = clonedNativePointer;
|
||||
clonedYogaNode.clearChildren();
|
||||
return clonedYogaNode;
|
||||
} catch (CloneNotSupportedException ex) {
|
||||
// This class implements Cloneable, this should not happen
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearChildren() {
|
||||
mChildren = null;
|
||||
YogaNative.jni_YGNodeClearChildren(mNativePointer);
|
||||
|
Reference in New Issue
Block a user