Repository navigation
Add YogaLayoutableShadowNode::enableBaseline() - #60571
Open
YevheniiKotyrlo wants to merge 1 commit into
Open
YevheniiKotyrlo wants to merge 1 commit into
YevheniiKotyrlo wants to merge 1 commit into
Conversation
The baseline function is connected only by the constructor, when the `BaselineYogaNode` trait is among the traits it is given, and a clone takes its source's Yoga node. No member connects the function that calls `baseline()` with the layout context, which is private, after construction, so without a function of its own, Yoga aligns a leaf whose new props ask it to answer its own baseline at its bottom edge. `enableBaseline()` connects `yogaNodeBaselineCallbackConnector`, as `enableMeasurement()` connects the measure function, and dirties the node when the function was not connected yet, since a clone of a laid-out node copies its source's clean Yoga node. Signed-off-by: YevheniiKotyrlo <44449990+YevheniiKotyrlo@users.noreply.github.com>
YevheniiKotyrlo
force-pushed
the
feature/enable-baseline-after-construction
branch
from
December 4, 2026 19:14
0a17d15 to
d7d25a3
Compare
YevheniiKotyrlo
marked this pull request as ready for review
December 4, 2026 20:57
This was referenced Dec 4, 2026
Measure a node connected by enableMeasurement() again when its props or the font scale change
#60583
Open
This branch has not been deployed
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:
YogaLayoutableShadowNodeconnects Yoga's baseline function only in the constructor that builds a node from its first props, whenBaselineYogaNodeis among the traits it is given (YogaLayoutableShadowNode.cpp#L82-L86). A clone takes its source's traits and a copy of its source's Yoga node, and the function that callsbaseline(),yogaNodeBaselineCallbackConnector, is private, and no header declares the layout context it passes (YogaLayoutableShadowNode.cpp#L1011-L1012). So no member connects that function after construction, and without a function of its own, Yoga aligns a leaf whose new props ask it to answerbaseline()at its bottom edge in a row withalignItems: 'baseline'(#60560).Setting
BaselineYogaNodein the component'sBaseTraits()instead connects the function on every node of the component, and Yoga asks a node with a baseline function for its baseline before it looks at its children (Baseline.cpp#L18-L33), so the component's nodes that lay out children would answer the component's ownbaseline()in place of the baseline Yoga takes from their children (Baseline.cpp#L35-L62).This adds
enableBaseline()besideenableMeasurement(). A clone of a laid-out node copies its source's clean Yoga node, soenableBaseline()dirties the node when it connects the function; on a node already connected it changes nothing.Related: #60572 adds
getLayoutMargins(), and both add their tests at the end ofViewTest.cpp, so the second to merge keeps both; #60578 correctsenableMeasurement()'s comment; #60581 passes the source revision toshouldNewRevisionDirtyMeasurement()incompleteClone(); #60583 dirties a node connected byenableMeasurement()when its props or the font scale change. #60578, #60581 and #60583 merge with this without conflict. #59048 and #59139 add tests toViewTest.cpptoo, apart from this one's.Changelog:
[GENERAL] [ADDED] - Add
YogaLayoutableShadowNode::enableBaseline()to connect a shadow node's baseline function after construction, such as on a clone whose new props ask for a baselineTest Plan:
Added
ViewTest.enableBaselineAlignsACloneOnItsBaseline: a measured leaf, 10x40 with a baseline of 10, whose clone constructor callsenableBaseline()and whose new revisions keep their measurement, beside a 10x20 box in a row aligned on baselines. Laid out first, the box sits at y 20 and the leaf at y 0; cloned with new props and laid out again, the box sits at y 0 and the leaf at y 10; cloned once more, the tree needs no layout. The test fails without thesetDirty(true)and without the connection, where the first clone keeps the first layout, and without the early return, where the second clone lays the tree out again:In
reactnativecommunity/react-native-android:latest:CC=clang-18 CXX=clang++-18 ./gradlew :private:react-native-fantom:testReactCommon, astest_react_common_cxxruns it:100% tests passed, 0 tests failed out of 1655yarn format-cpp, thengit diff --exit-code -- . ':(exclude)packages/react-native/package.json' ':(exclude)yarn.lock', asFormatchecks its formatters' patch: leaves the tree unchangedyarn cxx-api-validatewith Doxygen 1.16.1, the step ofValidate C++ API Snapshots:All snapshot validations passedNot run here: the Android, iOS and Fantom builds.