Repository navigation
YogaNode.setNodeType selects a measured node's pixel rounding (#2046) - #2046
Merged
Merged
Conversation
|
@pentiumao has exported this pull request. If you are a Meta employee, you can view the originating Diff in D125292521. |
pentiumao
added a commit
to pentiumao/yoga
that referenced
this pull request
Oct 20, 2026
…2046) Summary: X-link: facebook/litho#1093 **In one sentence.** A Java `YogaNode` with a measure function can now select Yoga's default pixel rounding, through a new `setNodeType` and its JNI binding to Yoga's existing `YGNodeSetNodeType`. ## Why this is needed Installing a measure function makes a Yoga node a text node, which is rounded to the pixel grid as text: its fractional size is rounded up, and its position down, so its content is not truncated. A container measured through a callback should round as a container does, each edge to the nearest pixel. The C API can select that (`YGNodeSetNodeType`); the Java binding could not. - Measured: of three nodes flexed to a third of a 100 wide row each, the first, given a measure function, ends at 33.33 and comes out 34 wide; without one, 33. ## What this diff does **`YogaNode.setNodeType(nodeType)`,** a new public open method that does nothing by default, so a `YogaNode` subclass built against an earlier class does not fail with `AbstractMethodError`. `YogaNodeJNIBase` overrides it through a new native method, `YogaNative.jni_YGNodeSetNodeTypeJNI`, which `YGJNIVanilla.cpp` registers and implements with `YGNodeSetNodeType`. `setMeasureFunction` still sets the type (text for a function, default for null), so a caller selects the type after it. ## What a Yoga user sees **A new public Yoga API.** **The Java and native halves must ship together.** `registerNatives` is strict: a Java class declaring `jni_YGNodeSetNodeTypeJNI` with a native library that lacks it, or the reverse, fails when the class registers. Changelog: [Android][Added] - Add `YogaNode.setNodeType` to select pixel rounding for measured nodes Reviewed By: christophpurrer Differential Revision: D125292521
pentiumao
force-pushed
the
export-D125292521
branch
from
October 20, 2026 15:09
420d5de to
15caf32
Compare
pentiumao
added a commit
to pentiumao/litho
that referenced
this pull request
Oct 20, 2026
…ok#1093) Summary: X-link: react/yoga#2046 **In one sentence.** A Java `YogaNode` with a measure function can now select Yoga's default pixel rounding, through a new `setNodeType` and its JNI binding to Yoga's existing `YGNodeSetNodeType`. ## Why this is needed Installing a measure function makes a Yoga node a text node, which is rounded to the pixel grid as text: its fractional size is rounded up, and its position down, so its content is not truncated. A container measured through a callback should round as a container does, each edge to the nearest pixel. The C API can select that (`YGNodeSetNodeType`); the Java binding could not. - Measured: of three nodes flexed to a third of a 100 wide row each, the first, given a measure function, ends at 33.33 and comes out 34 wide; without one, 33. ## What this diff does **`YogaNode.setNodeType(nodeType)`,** a new public open method that does nothing by default, so a `YogaNode` subclass built against an earlier class does not fail with `AbstractMethodError`. `YogaNodeJNIBase` overrides it through a new native method, `YogaNative.jni_YGNodeSetNodeTypeJNI`, which `YGJNIVanilla.cpp` registers and implements with `YGNodeSetNodeType`. `setMeasureFunction` still sets the type (text for a function, default for null), so a caller selects the type after it. ## What a Yoga user sees **A new public Yoga API.** **The Java and native halves must ship together.** `registerNatives` is strict: a Java class declaring `jni_YGNodeSetNodeTypeJNI` with a native library that lacks it, or the reverse, fails when the class registers. Changelog: [Android][Added] - Add `YogaNode.setNodeType` to select pixel rounding for measured nodes Reviewed By: christophpurrer Differential Revision: D125292521
pentiumao
added a commit
to pentiumao/yoga
that referenced
this pull request
Oct 20, 2026
…2046) Summary: Pull Request resolved: react#2046 X-link: facebook/litho#1093 **In one sentence.** A Java `YogaNode` with a measure function can now select Yoga's default pixel rounding, through a new `setNodeType` and its JNI binding to Yoga's existing `YGNodeSetNodeType`. ## Why this is needed Installing a measure function makes a Yoga node a text node, which is rounded to the pixel grid as text: its fractional size is rounded up, and its position down, so its content is not truncated. A container measured through a callback should round as a container does, each edge to the nearest pixel. The C API can select that (`YGNodeSetNodeType`); the Java binding could not. - Measured: of three nodes flexed to a third of a 100 wide row each, the first, given a measure function, ends at 33.33 and comes out 34 wide; without one, 33. ## What this diff does **`YogaNode.setNodeType(nodeType)`,** a new public open method that does nothing by default, so a `YogaNode` subclass built against an earlier class does not fail with `AbstractMethodError`. `YogaNodeJNIBase` overrides it through a new native method, `YogaNative.jni_YGNodeSetNodeTypeJNI`, which `YGJNIVanilla.cpp` registers and implements with `YGNodeSetNodeType`. `setMeasureFunction` still sets the type (text for a function, default for null), so a caller selects the type after it. ## What a Yoga user sees **A new public Yoga API.** **The Java and native halves must ship together.** `registerNatives` is strict: a Java class declaring `jni_YGNodeSetNodeTypeJNI` with a native library that lacks it, or the reverse, fails when the class registers. Changelog: [Android][Added] - Add `YogaNode.setNodeType` to select pixel rounding for measured nodes Reviewed By: christophpurrer Differential Revision: D125292521
pentiumao
force-pushed
the
export-D125292521
branch
from
October 20, 2026 15:12
15caf32 to
18304ce
Compare
pentiumao
added a commit
to pentiumao/react-native
that referenced
this pull request
Oct 20, 2026
…59235) Summary: Pull Request resolved: react#59235 X-link: react/yoga#2046 X-link: facebook/litho#1093 **In one sentence.** A Java `YogaNode` with a measure function can now select Yoga's default pixel rounding, through a new `setNodeType` and its JNI binding to Yoga's existing `YGNodeSetNodeType`. ## Why this is needed Installing a measure function makes a Yoga node a text node, which is rounded to the pixel grid as text: its fractional size is rounded up, and its position down, so its content is not truncated. A container measured through a callback should round as a container does, each edge to the nearest pixel. The C API can select that (`YGNodeSetNodeType`); the Java binding could not. - Measured: of three nodes flexed to a third of a 100 wide row each, the first, given a measure function, ends at 33.33 and comes out 34 wide; without one, 33. ## What this diff does **`YogaNode.setNodeType(nodeType)`,** a new public open method that does nothing by default, so a `YogaNode` subclass built against an earlier class does not fail with `AbstractMethodError`. `YogaNodeJNIBase` overrides it through a new native method, `YogaNative.jni_YGNodeSetNodeTypeJNI`, which `YGJNIVanilla.cpp` registers and implements with `YGNodeSetNodeType`. `setMeasureFunction` still sets the type (text for a function, default for null), so a caller selects the type after it. ## What a Yoga user sees **A new public Yoga API.** **The Java and native halves must ship together.** `registerNatives` is strict: a Java class declaring `jni_YGNodeSetNodeTypeJNI` with a native library that lacks it, or the reverse, fails when the class registers. Changelog: [Android][Added] - Add `YogaNode.setNodeType` to select pixel rounding for measured nodes Reviewed By: christophpurrer Differential Revision: D125292521
pentiumao
added a commit
to pentiumao/yoga
that referenced
this pull request
Oct 20, 2026
…2046) Summary: X-link: react/react-native#59235 X-link: facebook/litho#1093 **In one sentence.** A Java `YogaNode` with a measure function can now select Yoga's default pixel rounding, through a new `setNodeType` and its JNI binding to Yoga's existing `YGNodeSetNodeType`. ## Why this is needed Installing a measure function makes a Yoga node a text node, which is rounded to the pixel grid as text: its fractional size is rounded up, and its position down, so its content is not truncated. A container measured through a callback should round as a container does, each edge to the nearest pixel. The C API can select that (`YGNodeSetNodeType`); the Java binding could not. - Measured: of three nodes flexed to a third of a 100 wide row each, the first, given a measure function, ends at 33.33 and comes out 34 wide; without one, 33. ## What this diff does **`YogaNode.setNodeType(nodeType)`,** a new public open method that does nothing by default, so a `YogaNode` subclass built against an earlier class does not fail with `AbstractMethodError`. `YogaNodeJNIBase` overrides it through a new native method, `YogaNative.jni_YGNodeSetNodeTypeJNI`, which `YGJNIVanilla.cpp` registers and implements with `YGNodeSetNodeType`. `setMeasureFunction` still sets the type (text for a function, default for null), so a caller selects the type after it. ## What a Yoga user sees **A new public Yoga API.** **The Java and native halves must ship together.** `registerNatives` is strict: a Java class declaring `jni_YGNodeSetNodeTypeJNI` with a native library that lacks it, or the reverse, fails when the class registers. Changelog: [Android][Added] - Add `YogaNode.setNodeType` to select pixel rounding for measured nodes Reviewed By: christophpurrer Differential Revision: D125292521
pentiumao
force-pushed
the
export-D125292521
branch
from
October 20, 2026 16:28
18304ce to
95a0e15
Compare
pentiumao
added a commit
to pentiumao/litho
that referenced
this pull request
Oct 20, 2026
…ok#1093) Summary: X-link: react/react-native#59235 X-link: react/yoga#2046 **In one sentence.** A Java `YogaNode` with a measure function can now select Yoga's default pixel rounding, through a new `setNodeType` and its JNI binding to Yoga's existing `YGNodeSetNodeType`. ## Why this is needed Installing a measure function makes a Yoga node a text node, which is rounded to the pixel grid as text: its fractional size is rounded up, and its position down, so its content is not truncated. A container measured through a callback should round as a container does, each edge to the nearest pixel. The C API can select that (`YGNodeSetNodeType`); the Java binding could not. - Measured: of three nodes flexed to a third of a 100 wide row each, the first, given a measure function, ends at 33.33 and comes out 34 wide; without one, 33. ## What this diff does **`YogaNode.setNodeType(nodeType)`,** a new public open method that does nothing by default, so a `YogaNode` subclass built against an earlier class does not fail with `AbstractMethodError`. `YogaNodeJNIBase` overrides it through a new native method, `YogaNative.jni_YGNodeSetNodeTypeJNI`, which `YGJNIVanilla.cpp` registers and implements with `YGNodeSetNodeType`. `setMeasureFunction` still sets the type (text for a function, default for null), so a caller selects the type after it. ## What a Yoga user sees **A new public Yoga API.** **The Java and native halves must ship together.** `registerNatives` is strict: a Java class declaring `jni_YGNodeSetNodeTypeJNI` with a native library that lacks it, or the reverse, fails when the class registers. Changelog: [Android][Added] - Add `YogaNode.setNodeType` to select pixel rounding for measured nodes Reviewed By: christophpurrer Differential Revision: D125292521
…2046) Summary: X-link: react/react-native#59235 Pull Request resolved: react#2046 X-link: facebook/litho#1093 **In one sentence.** A Java `YogaNode` with a measure function can now select Yoga's default pixel rounding, through a new `setNodeType` and its JNI binding to Yoga's existing `YGNodeSetNodeType`. ## Why this is needed Installing a measure function makes a Yoga node a text node, which is rounded to the pixel grid as text: its fractional size is rounded up, and its position down, so its content is not truncated. A container measured through a callback should round as a container does, each edge to the nearest pixel. The C API can select that (`YGNodeSetNodeType`); the Java binding could not. - Measured: of three nodes flexed to a third of a 100 wide row each, the first, given a measure function, ends at 33.33 and comes out 34 wide; without one, 33. ## What this diff does **`YogaNode.setNodeType(nodeType)`,** a new public open method that does nothing by default, so a `YogaNode` subclass built against an earlier class does not fail with `AbstractMethodError`. `YogaNodeJNIBase` overrides it through a new native method, `YogaNative.jni_YGNodeSetNodeTypeJNI`, which `YGJNIVanilla.cpp` registers and implements with `YGNodeSetNodeType`. `setMeasureFunction` still sets the type (text for a function, default for null), so a caller selects the type after it. ## What a Yoga user sees **A new public Yoga API.** **The Java and native halves must ship together.** `registerNatives` is strict: a Java class declaring `jni_YGNodeSetNodeTypeJNI` with a native library that lacks it, or the reverse, fails when the class registers. Changelog: [Android][Added] - Add `YogaNode.setNodeType` to select pixel rounding for measured nodes Reviewed By: christophpurrer Differential Revision: D125292521
pentiumao
added a commit
to pentiumao/react-native
that referenced
this pull request
Oct 20, 2026
…59235) Summary: Pull Request resolved: react#59235 X-link: react/yoga#2046 X-link: facebook/litho#1093 **In one sentence.** A Java `YogaNode` with a measure function can now select Yoga's default pixel rounding, through a new `setNodeType` and its JNI binding to Yoga's existing `YGNodeSetNodeType`. ## Why this is needed Installing a measure function makes a Yoga node a text node, which is rounded to the pixel grid as text: its fractional size is rounded up, and its position down, so its content is not truncated. A container measured through a callback should round as a container does, each edge to the nearest pixel. The C API can select that (`YGNodeSetNodeType`); the Java binding could not. - Measured: of three nodes flexed to a third of a 100 wide row each, the first, given a measure function, ends at 33.33 and comes out 34 wide; without one, 33. ## What this diff does **`YogaNode.setNodeType(nodeType)`,** a new public open method that does nothing by default, so a `YogaNode` subclass built against an earlier class does not fail with `AbstractMethodError`. `YogaNodeJNIBase` overrides it through a new native method, `YogaNative.jni_YGNodeSetNodeTypeJNI`, which `YGJNIVanilla.cpp` registers and implements with `YGNodeSetNodeType`. `setMeasureFunction` still sets the type (text for a function, default for null), so a caller selects the type after it. ## What a Yoga user sees **A new public Yoga API.** **The Java and native halves must ship together.** `registerNatives` is strict: a Java class declaring `jni_YGNodeSetNodeTypeJNI` with a native library that lacks it, or the reverse, fails when the class registers. Changelog: [Android][Added] - Add `YogaNode.setNodeType` to select pixel rounding for measured nodes Reviewed By: christophpurrer Differential Revision: D125292521
pentiumao
force-pushed
the
export-D125292521
branch
from
October 20, 2026 16:30
95a0e15 to
49c96e0
Compare
pentiumao
added a commit
to pentiumao/litho
that referenced
this pull request
Oct 20, 2026
…ok#1093) Summary: X-link: react/react-native#59235 X-link: react/yoga#2046 Pull Request resolved: facebook#1093 **In one sentence.** A Java `YogaNode` with a measure function can now select Yoga's default pixel rounding, through a new `setNodeType` and its JNI binding to Yoga's existing `YGNodeSetNodeType`. ## Why this is needed Installing a measure function makes a Yoga node a text node, which is rounded to the pixel grid as text: its fractional size is rounded up, and its position down, so its content is not truncated. A container measured through a callback should round as a container does, each edge to the nearest pixel. The C API can select that (`YGNodeSetNodeType`); the Java binding could not. - Measured: of three nodes flexed to a third of a 100 wide row each, the first, given a measure function, ends at 33.33 and comes out 34 wide; without one, 33. ## What this diff does **`YogaNode.setNodeType(nodeType)`,** a new public open method that does nothing by default, so a `YogaNode` subclass built against an earlier class does not fail with `AbstractMethodError`. `YogaNodeJNIBase` overrides it through a new native method, `YogaNative.jni_YGNodeSetNodeTypeJNI`, which `YGJNIVanilla.cpp` registers and implements with `YGNodeSetNodeType`. `setMeasureFunction` still sets the type (text for a function, default for null), so a caller selects the type after it. ## What a Yoga user sees **A new public Yoga API.** **The Java and native halves must ship together.** `registerNatives` is strict: a Java class declaring `jni_YGNodeSetNodeTypeJNI` with a native library that lacks it, or the reverse, fails when the class registers. Changelog: [Android][Added] - Add `YogaNode.setNodeType` to select pixel rounding for measured nodes Reviewed By: christophpurrer Differential Revision: D125292521
pentiumao
added a commit
to pentiumao/react-native
that referenced
this pull request
Oct 20, 2026
…59235) Summary: Pull Request resolved: react#59235 X-link: react/yoga#2046 X-link: facebook/litho#1093 **In one sentence.** A Java `YogaNode` with a measure function can now select Yoga's default pixel rounding, through a new `setNodeType` and its JNI binding to Yoga's existing `YGNodeSetNodeType`. ## Why this is needed Installing a measure function makes a Yoga node a text node, which is rounded to the pixel grid as text: its fractional size is rounded up, and its position down, so its content is not truncated. A container measured through a callback should round as a container does, each edge to the nearest pixel. The C API can select that (`YGNodeSetNodeType`); the Java binding could not. - Measured: of three nodes flexed to a third of a 100 wide row each, the first, given a measure function, ends at 33.33 and comes out 34 wide; without one, 33. ## What this diff does **`YogaNode.setNodeType(nodeType)`,** a new public open method that does nothing by default, so a `YogaNode` subclass built against an earlier class does not fail with `AbstractMethodError`. `YogaNodeJNIBase` overrides it through a new native method, `YogaNative.jni_YGNodeSetNodeTypeJNI`, which `YGJNIVanilla.cpp` registers and implements with `YGNodeSetNodeType`. `setMeasureFunction` still sets the type (text for a function, default for null), so a caller selects the type after it. ## What a Yoga user sees **A new public Yoga API.** **The Java and native halves must ship together.** `registerNatives` is strict: a Java class declaring `jni_YGNodeSetNodeTypeJNI` with a native library that lacks it, or the reverse, fails when the class registers. Changelog: [Android][Added] - Add `YogaNode.setNodeType` to select pixel rounding for measured nodes Reviewed By: christophpurrer Differential Revision: D125292521
meta-codesync Bot
pushed a commit
to react/react-native
that referenced
this pull request
Oct 20, 2026
Summary: Pull Request resolved: #59235 X-link: react/yoga#2046 X-link: facebook/litho#1093 **In one sentence.** A Java `YogaNode` with a measure function can now select Yoga's default pixel rounding, through a new `setNodeType` and its JNI binding to Yoga's existing `YGNodeSetNodeType`. ## Why this is needed Installing a measure function makes a Yoga node a text node, which is rounded to the pixel grid as text: its fractional size is rounded up, and its position down, so its content is not truncated. A container measured through a callback should round as a container does, each edge to the nearest pixel. The C API can select that (`YGNodeSetNodeType`); the Java binding could not. - Measured: of three nodes flexed to a third of a 100 wide row each, the first, given a measure function, ends at 33.33 and comes out 34 wide; without one, 33. ## What this diff does **`YogaNode.setNodeType(nodeType)`,** a new public open method that does nothing by default, so a `YogaNode` subclass built against an earlier class does not fail with `AbstractMethodError`. `YogaNodeJNIBase` overrides it through a new native method, `YogaNative.jni_YGNodeSetNodeTypeJNI`, which `YGJNIVanilla.cpp` registers and implements with `YGNodeSetNodeType`. `setMeasureFunction` still sets the type (text for a function, default for null), so a caller selects the type after it. ## What a Yoga user sees **A new public Yoga API.** **The Java and native halves must ship together.** `registerNatives` is strict: a Java class declaring `jni_YGNodeSetNodeTypeJNI` with a native library that lacks it, or the reverse, fails when the class registers. Changelog: [Android][Added] - Add `YogaNode.setNodeType` to select pixel rounding for measured nodes Reviewed By: christophpurrer Differential Revision: D125292521 fbshipit-source-id: 3300bd4f48a0504bb29a7c1bd261538020f6196f
meta-codesync Bot
pushed a commit
to facebook/litho
that referenced
this pull request
Oct 20, 2026
Summary: X-link: react/react-native#59235 X-link: react/yoga#2046 Pull Request resolved: #1093 **In one sentence.** A Java `YogaNode` with a measure function can now select Yoga's default pixel rounding, through a new `setNodeType` and its JNI binding to Yoga's existing `YGNodeSetNodeType`. ## Why this is needed Installing a measure function makes a Yoga node a text node, which is rounded to the pixel grid as text: its fractional size is rounded up, and its position down, so its content is not truncated. A container measured through a callback should round as a container does, each edge to the nearest pixel. The C API can select that (`YGNodeSetNodeType`); the Java binding could not. - Measured: of three nodes flexed to a third of a 100 wide row each, the first, given a measure function, ends at 33.33 and comes out 34 wide; without one, 33. ## What this diff does **`YogaNode.setNodeType(nodeType)`,** a new public open method that does nothing by default, so a `YogaNode` subclass built against an earlier class does not fail with `AbstractMethodError`. `YogaNodeJNIBase` overrides it through a new native method, `YogaNative.jni_YGNodeSetNodeTypeJNI`, which `YGJNIVanilla.cpp` registers and implements with `YGNodeSetNodeType`. `setMeasureFunction` still sets the type (text for a function, default for null), so a caller selects the type after it. ## What a Yoga user sees **A new public Yoga API.** **The Java and native halves must ship together.** `registerNatives` is strict: a Java class declaring `jni_YGNodeSetNodeTypeJNI` with a native library that lacks it, or the reverse, fails when the class registers. Changelog: [Android][Added] - Add `YogaNode.setNodeType` to select pixel rounding for measured nodes Reviewed By: christophpurrer Differential Revision: D125292521 fbshipit-source-id: 3300bd4f48a0504bb29a7c1bd261538020f6196f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
X-link: react/react-native#59235
X-link: facebook/litho#1093
In one sentence. A Java
YogaNodewith a measure function can now select Yoga's default pixel rounding, through a newsetNodeTypeand its JNI binding to Yoga's existingYGNodeSetNodeType.Why this is needed
Installing a measure function makes a Yoga node a text node, which is rounded to the pixel grid as text: its fractional size is rounded up, and its position down, so its content is not truncated. A container measured through a callback should round as a container does, each edge to the nearest pixel. The C API can select that (
YGNodeSetNodeType); the Java binding could not.What this diff does
YogaNode.setNodeType(nodeType), a new public open method that does nothing by default, so aYogaNodesubclass built against an earlier class does not fail withAbstractMethodError.YogaNodeJNIBaseoverrides it through a new native method,YogaNative.jni_YGNodeSetNodeTypeJNI, whichYGJNIVanilla.cppregisters and implements withYGNodeSetNodeType.setMeasureFunctionstill sets the type (text for a function, default for null), so a caller selects the type after it.What a Yoga user sees
A new public Yoga API.
The Java and native halves must ship together.
registerNativesis strict: a Java class declaringjni_YGNodeSetNodeTypeJNIwith a native library that lacks it, or the reverse, fails when the class registers.Changelog:
[Android][Added] - Add
YogaNode.setNodeTypeto select pixel rounding for measured nodesReviewed By: christophpurrer
Differential Revision: D125292521