move config jni methods to vanilla jni

Summary: Move yoga node config related jni methods to vanilla jni

Reviewed By: amir-shalem

Differential Revision: D17684821

fbshipit-source-id: 31a667b3ad67501aaef83a132971e4e0826cacd4
This commit is contained in:
Sidharth Guglani
2019-10-08 14:23:57 -07:00
committed by Facebook Github Bot
parent 34b68cf1d2
commit ee73f556b4
6 changed files with 143 additions and 14 deletions

View File

@@ -23,20 +23,37 @@ public abstract class YogaConfigJNIBase extends YogaConfig {
this(YogaNative.jni_YGConfigNew());
}
YogaConfigJNIBase(boolean useVanillaJNI) {
this(useVanillaJNI ? YogaNative.jni_YGConfigNewJNI() : YogaNative.jni_YGConfigNew());
this.useVanillaJNI = useVanillaJNI;
}
public void setExperimentalFeatureEnabled(YogaExperimentalFeature feature, boolean enabled) {
YogaNative.jni_YGConfigSetExperimentalFeatureEnabled(mNativePointer, feature.intValue(), enabled);
if (useVanillaJNI)
YogaNative.jni_YGConfigSetExperimentalFeatureEnabledJNI(mNativePointer, feature.intValue(), enabled);
else
YogaNative.jni_YGConfigSetExperimentalFeatureEnabled(mNativePointer, feature.intValue(), enabled);
}
public void setUseWebDefaults(boolean useWebDefaults) {
YogaNative.jni_YGConfigSetUseWebDefaults(mNativePointer, useWebDefaults);
if (useVanillaJNI)
YogaNative.jni_YGConfigSetUseWebDefaultsJNI(mNativePointer, useWebDefaults);
else
YogaNative.jni_YGConfigSetUseWebDefaults(mNativePointer, useWebDefaults);
}
public void setPrintTreeFlag(boolean enable) {
YogaNative.jni_YGConfigSetPrintTreeFlag(mNativePointer, enable);
if (useVanillaJNI)
YogaNative.jni_YGConfigSetPrintTreeFlagJNI(mNativePointer, enable);
else
YogaNative.jni_YGConfigSetPrintTreeFlag(mNativePointer, enable);
}
public void setPointScaleFactor(float pixelsInPoint) {
YogaNative.jni_YGConfigSetPointScaleFactor(mNativePointer, pixelsInPoint);
if (useVanillaJNI)
YogaNative.jni_YGConfigSetPointScaleFactorJNI(mNativePointer, pixelsInPoint);
else
YogaNative.jni_YGConfigSetPointScaleFactor(mNativePointer, pixelsInPoint);
}
/**
@@ -45,7 +62,10 @@ public abstract class YogaConfigJNIBase extends YogaConfig {
* Because this was such a long-standing bug we must allow legacy users to switch back to this behaviour.
*/
public void setUseLegacyStretchBehaviour(boolean useLegacyStretchBehaviour) {
YogaNative.jni_YGConfigSetUseLegacyStretchBehaviour(mNativePointer, useLegacyStretchBehaviour);
if (useVanillaJNI)
YogaNative.jni_YGConfigSetUseLegacyStretchBehaviourJNI(mNativePointer, useLegacyStretchBehaviour);
else
YogaNative.jni_YGConfigSetUseLegacyStretchBehaviour(mNativePointer, useLegacyStretchBehaviour);
}
/**
@@ -55,8 +75,12 @@ public abstract class YogaConfigJNIBase extends YogaConfig {
*/
public void setShouldDiffLayoutWithoutLegacyStretchBehaviour(
boolean shouldDiffLayoutWithoutLegacyStretchBehaviour) {
YogaNative.jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
mNativePointer, shouldDiffLayoutWithoutLegacyStretchBehaviour);
if (useVanillaJNI)
YogaNative.jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviourJNI(
mNativePointer, shouldDiffLayoutWithoutLegacyStretchBehaviour);
else
YogaNative.jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
mNativePointer, shouldDiffLayoutWithoutLegacyStretchBehaviour);
}
public void setLogger(YogaLogger logger) {
@@ -72,11 +96,6 @@ public abstract class YogaConfigJNIBase extends YogaConfig {
return mNativePointer;
}
@Override
public void setUseVanillaJNI(boolean useVanillaJNI) {
this.useVanillaJNI = useVanillaJNI;
}
@Override
public boolean useVanillaJNI() {
return this.useVanillaJNI;