Repository navigation
Add YogaLayoutableShadowNode::getLayoutMargins() - #60572
Open
YevheniiKotyrlo wants to merge 1 commit into
Open
YevheniiKotyrlo wants to merge 1 commit into
YevheniiKotyrlo wants to merge 1 commit into
Conversation
LayoutMetrics carries a node's borders and paddings but not its margins, and the Yoga node that holds them is protected. getLayoutMargins() reads the margins of the node's last layout by physical edge. Signed-off-by: YevheniiKotyrlo <44449990+YevheniiKotyrlo@users.noreply.github.com>
YevheniiKotyrlo
force-pushed
the
feature/yoga-layoutable-shadow-node-layout-margins
branch
from
December 4, 2026 19:32
016c405 to
624329a
Compare
YevheniiKotyrlo
marked this pull request as ready for review
December 4, 2026 21:44
Collaborator
|
Thanks for this. Could you share the use case behind |
This was referenced Dec 5, 2026
Contributor
Author
|
It's for |
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:
LayoutMetricscarries a laid-out node's frame, borders and paddings but not its margins, andyogaNode_isprotected, so C++ that reads a node from the mounted tree, such as aUIManagerMountHook, has no read of the margins the node was laid out with.This adds
EdgeInsets YogaLayoutableShadowNode::getLayoutMargins() const, which reads them from the node's Yoga layout by physical edge, aslayoutMetricsFromYogaNodereads the borders and paddings. It returns a value, so no reference to the Yoga node leaves the class.Adding margins to
LayoutMetricsinstead would addUpdatemutations for changes in a node's resolved margins alone, sinceShadowView::operator==compareslayoutMetrics.An
automargin reads 0, which is what Yoga stores for it (react/yoga#2224).Related: #60571 adds
enableBaseline(), 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::getLayoutMargins(), the margins a node was laid out withTest Plan:
YogaLayoutableShadowNodeTest.layoutMarginsAreResolvedPhysicalEdges, inViewTest.cpp, lays out a 100 × 100 view withmarginStart: 10andmarginTop: 10%in a 300 × 200 right-to-left root, and expects{left: 0, top: 30, right: 10, bottom: 0}: the start margin on the right, and the percentage against the root's width, not its height.On 624329a, each job's commands run locally:
test_react_common_cxx:100% tests passed, 0 tests failed out of 1655, the new test among them.validate_cxx_api_snapshots(Doxygen 1.16.1): passes with each of the 12 snapshots listingpublic facebook::react::EdgeInsets getLayoutMargins() const;.format:yarn format-javascript,format-cpp,format-kotlin,format-javaandformat-python, thengit diff --exit-codeleaving outpackages/react-native/package.jsonandyarn.lock, asformat.ymldoes: exit 0.Not run here:
format-swift,lint,test_jsandbuild_js_types(no Swift or JavaScript changes), and the Android, iOS and Fantom builds.