Expose UseWebDefaults to java

Summary: Expose UseWebDefaults to java

Reviewed By: astreet

Differential Revision: D4779743

fbshipit-source-id: 65a4184af6fb959fefff5c2014522c551ca440d5
This commit is contained in:
Emil Sjolander
2017-03-29 03:06:17 -07:00
committed by Facebook Github Bot
parent ebdf82f491
commit bc2fb5c7ab
3 changed files with 19 additions and 0 deletions

View File

@@ -46,4 +46,9 @@ public class YogaConfig {
public void setExperimentalFeatureEnabled(YogaExperimentalFeature feature, boolean enabled) { public void setExperimentalFeatureEnabled(YogaExperimentalFeature feature, boolean enabled) {
jni_YGConfigSetExperimentalFeatureEnabled(mNativePointer, feature.intValue(), enabled); jni_YGConfigSetExperimentalFeatureEnabled(mNativePointer, feature.intValue(), enabled);
} }
private native void jni_YGConfigSetUseWebDefaults(long nativePointer, boolean useWebDefaults);
public void setUseWebDefaults(boolean useWebDefaults) {
jni_YGConfigSetUseWebDefaults(mNativePointer, useWebDefaults);
}
} }

View File

@@ -381,6 +381,11 @@ void jni_YGConfigSetExperimentalFeatureEnabled(alias_ref<jobject>, jlong nativeP
YGConfigSetExperimentalFeatureEnabled(config, static_cast<YGExperimentalFeature>(feature), enabled); YGConfigSetExperimentalFeatureEnabled(config, static_cast<YGExperimentalFeature>(feature), enabled);
} }
void jni_YGConfigSetUseWebDefaults(alias_ref<jobject>, jlong nativePointer, jboolean useWebDefaults) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
YGConfigSetUseWebDefaults(config, useWebDefaults);
}
jint jni_YGNodeGetInstanceCount(alias_ref<jclass> clazz) { jint jni_YGNodeGetInstanceCount(alias_ref<jclass> clazz) {
return YGNodeGetInstanceCount(); return YGNodeGetInstanceCount();
} }
@@ -476,6 +481,7 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
YGMakeNativeMethod(jni_YGConfigNew), YGMakeNativeMethod(jni_YGConfigNew),
YGMakeNativeMethod(jni_YGConfigFree), YGMakeNativeMethod(jni_YGConfigFree),
YGMakeNativeMethod(jni_YGConfigSetExperimentalFeatureEnabled), YGMakeNativeMethod(jni_YGConfigSetExperimentalFeatureEnabled),
YGMakeNativeMethod(jni_YGConfigSetUseWebDefaults),
}); });
}); });
} }

View File

@@ -219,6 +219,14 @@ public class YogaNodeTest {
assertEquals(4, (int) node.getLayoutBorder(YogaEdge.BOTTOM)); assertEquals(4, (int) node.getLayoutBorder(YogaEdge.BOTTOM));
} }
@Test
public void testUseWebDefaults() {
final YogaConfig config = new YogaConfig();
config.setUseWebDefaults(true);
final YogaNode node = new YogaNode(config);
assertEquals(YogaFlexDirection.ROW, node.getFlexDirection());
}
@Test @Test
public void testPercentPaddingOnRoot() { public void testPercentPaddingOnRoot() {
final YogaNode node = new YogaNode(); final YogaNode node = new YogaNode();