Skip to content

Commit

Permalink
Java bindings for setAlwaysFormsContainingBlock (facebook#1540)
Browse files Browse the repository at this point in the history
Summary:
X-link: facebook/react-native#42192


tsia

Differential Revision: D52608259
  • Loading branch information
joevilches authored and facebook-github-bot committed Jan 8, 2024
1 parent a18a695 commit 25af2cf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions java/com/facebook/yoga/YogaNative.java
Original file line number Diff line number Diff line change
Expand Up @@ -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_YGNodeSetAlwaysFormsContainingBlock(long nativePointer, boolean alwaysFormContainingBlock);
}
2 changes: 2 additions & 0 deletions java/com/facebook/yoga/YogaNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,6 @@ public interface Inputs {
public abstract YogaNode cloneWithoutChildren();

public abstract YogaNode cloneWithChildren();

public abstract void setAlwaysFormsContainingBlock(boolean alwaysFormsContainingBlock);
}
4 changes: 4 additions & 0 deletions java/com/facebook/yoga/YogaNodeJNIBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,10 @@ public void setMeasureFunction(YogaMeasureFunction measureFunction) {
YogaNative.jni_YGNodeSetHasMeasureFuncJNI(mNativePointer, measureFunction != null);
}

public void setAlwaysFormsContainingBlock(boolean alwaysFormsContainingBlock) {
YogaNative.jni_YGNodeSetAlwaysFormsContainingBlock(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
Expand Down
13 changes: 13 additions & 0 deletions java/jni/YGJNIVanilla.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,16 @@ static void jni_YGNodeSetHasBaselineFuncJNI(
hasBaselineFunc ? YGJNIBaselineFunc : nullptr);
}

static void jni_YGNodeSetAlwaysFormsContainingBlockJNI(
JNIEnv* /*env*/,
jobject /*obj*/,
jlong nativePointer,
jboolean alwaysFormsContainingBlock) {
YGNodeSetAlwaysFormsContainingBlock(
_jlong2YGNodeRef(nativePointer),
static_cast<bool>(alwaysFormsContainingBlock));
}

static void
jni_YGNodePrintJNI(JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) {
#ifdef DEBUG
Expand Down Expand Up @@ -958,6 +968,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},
};
Expand Down

0 comments on commit 25af2cf

Please sign in to comment.