Skip to content

YogaNode.setNodeType selects a measured node's pixel rounding (#59235) - #59235

Closed
pentiumao wants to merge 1 commit into
react:mainfrom
pentiumao:export-D125292521
Closed

pentiumao wants to merge 1 commit into
react:mainfrom
pentiumao:export-D125292521

Conversation

@pentiumao

@pentiumao pentiumao commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

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-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 20, 2026
@meta-codesync

meta-codesync Bot commented Oct 20, 2026

Copy link
Copy Markdown

@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/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 meta-codesync Bot changed the title YogaNode.setNodeType selects a measured node's pixel rounding YogaNode.setNodeType selects a measured node's pixel rounding (#59235) Oct 20, 2026
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 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
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

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/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
…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/yoga that referenced this pull request Oct 20, 2026
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

Pull Request resolved: #2046
@meta-codesync meta-codesync Bot closed this in 928fd14 Oct 20, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Oct 20, 2026
@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @pentiumao in 928fd14

When will my fix make it into a release? | How to file a pick request?

@meta-codesync

meta-codesync Bot commented Oct 20, 2026

Copy link
Copy Markdown

This pull request has been merged in 928fd14.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants