Adds InternalNode#freeze() API
Summary: Litho needs a new API which is called immediately before yoga begins layout calculations so that the InternalNode gets the opportunity to finalise itself; i.e. perform the last mutations and in effect avoid any more mutations to the hierarchy. See D26373731 where the mutations from `Layout#collectResults` is moved back into the InternalNode. Changelog: [Internal] Adds new API to YogaNodeJNIBase Reviewed By: SidharthGuglani Differential Revision: D26373730 fbshipit-source-id: 471346d3444986ada91e86c95f5f9fb98bcd2fa6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
651c527e94
commit
de36e85004
@@ -197,12 +197,17 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
long[] nativePointers = null;
|
||||
YogaNodeJNIBase[] nodes = null;
|
||||
|
||||
freeze();
|
||||
|
||||
ArrayList<YogaNodeJNIBase> n = new ArrayList<>();
|
||||
n.add(this);
|
||||
for (int i = 0; i < n.size(); ++i) {
|
||||
List<YogaNodeJNIBase> children = n.get(i).mChildren;
|
||||
if (children != null) {
|
||||
n.addAll(children);
|
||||
for (YogaNodeJNIBase child : children) {
|
||||
child.freeze();
|
||||
n.add(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,6 +220,13 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
YogaNative.jni_YGNodeCalculateLayoutJNI(mNativePointer, width, height, nativePointers, nodes);
|
||||
}
|
||||
|
||||
private void freeze() {
|
||||
Object data = getData();
|
||||
if (data instanceof Inputs) {
|
||||
((Inputs) data).freeze();
|
||||
}
|
||||
}
|
||||
|
||||
public void dirty() {
|
||||
YogaNative.jni_YGNodeMarkDirtyJNI(mNativePointer);
|
||||
}
|
||||
|
Reference in New Issue
Block a user