Pass parent with down with calculateLayout to allow percentages on root node

Summary: For percentage paddings/margins/sizes to work on the root node we need to have the ability to pass down the parent sizes. This has always been possible with the C API but was never exposed to java. This diff exposes this functionality.

Reviewed By: astreet

Differential Revision: D4501016

fbshipit-source-id: 0c9502e86ff200c021c78afb7ac4b48cf11b3bdb
This commit is contained in:
Emil Sjolander
2017-02-03 11:19:45 -08:00
committed by Facebook Github Bot
parent 93e327f4a5
commit 56d06e27cf
21 changed files with 301 additions and 289 deletions

View File

@@ -172,10 +172,10 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
return mChildren == null ? -1 : mChildren.indexOf(child);
}
private native void jni_YGNodeCalculateLayout(long nativePointer);
private native void jni_YGNodeCalculateLayout(long nativePointer, float width, float height);
@Override
public void calculateLayout() {
jni_YGNodeCalculateLayout(mNativePointer);
public void calculateLayout(float width, float height) {
jni_YGNodeCalculateLayout(mNativePointer, width, height);
}
private native boolean jni_YGNodeHasNewLayout(long nativePointer);

View File

@@ -20,7 +20,7 @@ public interface YogaNodeAPI<YogaNodeType extends YogaNodeAPI> {
void setMeasureFunction(YogaMeasureFunction measureFunction);
void setBaselineFunction(YogaBaselineFunction measureFunction);
boolean isMeasureDefined();
void calculateLayout();
void calculateLayout(float width, float height);
boolean isDirty();
boolean hasNewLayout();
void dirty();