Refactor YogaNode.Inputs freeze API
Summary: `InternalNode` will eventually not have a pointer to its parent. This diff removes one of the usages of the `InternalNode#getParent()` API. `InternalNode` will also not host the `YogaNode` eventually; so this diff also removes one of the usages of the `InternalNode#getYogaNode()` api. Now the `Inputs#freeze` api will pass the parent's `YogaNode` and the `YogaNode` of the node (this) being measured. Changelog: [Internal] Passes The YogaNode and parent YogaNode in the Inputs.freeze API Reviewed By: SidharthGuglani Differential Revision: D27240229 fbshipit-source-id: efc4ec3249a963c3181111f9b989d8ed9e17feb4
This commit is contained in:
committed by
Facebook GitHub Bot
parent
07eaeea7a4
commit
cbf6495d66
@@ -15,7 +15,7 @@ public abstract class YogaNode implements YogaProps {
|
|||||||
public interface Inputs {
|
public interface Inputs {
|
||||||
|
|
||||||
/** Requests the data object to disable mutations of its inputs. */
|
/** Requests the data object to disable mutations of its inputs. */
|
||||||
void freeze();
|
void freeze(final YogaNode node, final @Nullable YogaNode parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void reset();
|
public abstract void reset();
|
||||||
|
@@ -197,15 +197,16 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
long[] nativePointers = null;
|
long[] nativePointers = null;
|
||||||
YogaNodeJNIBase[] nodes = null;
|
YogaNodeJNIBase[] nodes = null;
|
||||||
|
|
||||||
freeze();
|
freeze(null);
|
||||||
|
|
||||||
ArrayList<YogaNodeJNIBase> n = new ArrayList<>();
|
ArrayList<YogaNodeJNIBase> n = new ArrayList<>();
|
||||||
n.add(this);
|
n.add(this);
|
||||||
for (int i = 0; i < n.size(); ++i) {
|
for (int i = 0; i < n.size(); ++i) {
|
||||||
List<YogaNodeJNIBase> children = n.get(i).mChildren;
|
final YogaNodeJNIBase parent = n.get(i);
|
||||||
|
List<YogaNodeJNIBase> children = parent.mChildren;
|
||||||
if (children != null) {
|
if (children != null) {
|
||||||
for (YogaNodeJNIBase child : children) {
|
for (YogaNodeJNIBase child : children) {
|
||||||
child.freeze();
|
child.freeze(parent);
|
||||||
n.add(child);
|
n.add(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,10 +221,10 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
YogaNative.jni_YGNodeCalculateLayoutJNI(mNativePointer, width, height, nativePointers, nodes);
|
YogaNative.jni_YGNodeCalculateLayoutJNI(mNativePointer, width, height, nativePointers, nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void freeze() {
|
private void freeze(YogaNode parent) {
|
||||||
Object data = getData();
|
Object data = getData();
|
||||||
if (data instanceof Inputs) {
|
if (data instanceof Inputs) {
|
||||||
((Inputs) data).freeze();
|
((Inputs) data).freeze(this, parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user