diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaNative.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaNative.java index a0b7c165f16f95..101f0e0eddc8fa 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaNative.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaNative.java @@ -114,4 +114,5 @@ public class YogaNative { static native void jni_YGNodePrintJNI(long nativePointer); static native void jni_YGNodeSetStyleInputsJNI(long nativePointer, float[] styleInputsArray, int size); static native long jni_YGNodeCloneJNI(long nativePointer); + static native void jni_YGNodeSetAlwaysFormsContainingBlockJNI(long nativePointer, boolean alwaysFormContainingBlock); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaNode.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaNode.java index 1f19ec5bbdeea3..253234378dba20 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaNode.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaNode.java @@ -226,4 +226,6 @@ public interface Inputs { public abstract YogaNode cloneWithoutChildren(); public abstract YogaNode cloneWithChildren(); + + public abstract void setAlwaysFormsContainingBlock(boolean alwaysFormsContainingBlock); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaNodeJNIBase.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaNodeJNIBase.java index dbe3fd8a77bb0a..d1010f40bb8c52 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaNodeJNIBase.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaNodeJNIBase.java @@ -504,6 +504,11 @@ public void setMeasureFunction(YogaMeasureFunction measureFunction) { YogaNative.jni_YGNodeSetHasMeasureFuncJNI(mNativePointer, measureFunction != null); } + @Override + public void setAlwaysFormsContainingBlock(boolean alwaysFormsContainingBlock) { + YogaNative.jni_YGNodeSetAlwaysFormsContainingBlockJNI(mNativePointer, alwaysFormsContainingBlock); + } + // Implementation Note: Why this method needs to stay final // // We cache the jmethodid for this method in Yoga code. This means that even if a subclass diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNIVanilla.cpp b/packages/react-native/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNIVanilla.cpp index b3b564866e1fee..ccbf7787750520 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNIVanilla.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNIVanilla.cpp @@ -681,6 +681,15 @@ static void jni_YGNodeSetHasBaselineFuncJNI( hasBaselineFunc ? YGJNIBaselineFunc : nullptr); } +static void jni_YGNodeSetAlwaysFormsContainingBlockJNI( + JNIEnv* /*env*/, + jobject /*obj*/, + jlong nativePointer, + jboolean alwaysFormsContainingBlock) { + YGNodeSetAlwaysFormsContainingBlock( + _jlong2YGNodeRef(nativePointer), alwaysFormsContainingBlock); +} + static void jni_YGNodePrintJNI(JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) { #ifdef DEBUG @@ -958,6 +967,9 @@ static JNINativeMethod methods[] = { {"jni_YGNodeSetHasBaselineFuncJNI", "(JZ)V", (void*)jni_YGNodeSetHasBaselineFuncJNI}, + {"jni_YGNodeSetAlwaysFormsContainingBlockJNI", + "(JZ)V", + (void*)jni_YGNodeSetAlwaysFormsContainingBlockJNI}, {"jni_YGNodePrintJNI", "(J)V", (void*)jni_YGNodePrintJNI}, {"jni_YGNodeCloneJNI", "(J)J", (void*)jni_YGNodeCloneJNI}, }; diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/fakes/FakeYogaNode.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/fakes/FakeYogaNode.kt index d21efbe1582782..103bddb5c630a8 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/fakes/FakeYogaNode.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/fakes/FakeYogaNode.kt @@ -106,6 +106,8 @@ class FakeYogaNode : YogaNode() { override fun setBaselineFunction(baselineFunction: YogaBaselineFunction?) {} + override fun setAlwaysFormsContainingBlock(alwaysFormsContainingBlock: Boolean) {} + override fun getWidth(): YogaValue = YogaValue(YogaConstants.UNDEFINED, YogaUnit.UNDEFINED) override fun getMinWidth(): YogaValue = YogaValue(YogaConstants.UNDEFINED, YogaUnit.UNDEFINED)