Repository navigation
Conversation
Summary: `YGNodeSetMeasureFuncFollowsMeasureModes(node, false)` tells Yoga that the node's measure function doesn't size as the measure modes describe (max-content for `Undefined`, fit-content for `AtMost`, stretch-fit for `Exactly`), for example because it fills the space it is given or picks a layout by it. Yoga then infers nothing about the node from a measurement under other constraints. - The default is `true`, today's behaviour. - With it `false`, the layout cache and the measurement cache reuse the node's measurement only under the same constraints. A node in a column is then measured twice in one layout: with no height bound, then at exactly the height it measured. - For automatic minimum sizing (on when `YGErrataMinSizeUndefinedInsteadOfAuto` is cleared), its measure function isn't called with `AtMost 0`. Its min-content size is the one set with `YGNodeSetMinContentWidth`/`Height`, if any; otherwise its padding and border plus what its `YGMinContentMeasureFunc` returns, or plus 0 without one. - No effect on the layout of a node without a measure function. Changing the value marks the node dirty; clones and moves keep it; `YGNodeReset` restores `true`. The deprecated `YGNodeCanUseCachedMeasurement` keeps its signature and behaviour. - Java and Kotlin: `YogaNode.setMeasureFunctionFollowsMeasureModes` and `YogaNode.measureFunctionFollowsMeasureModes`, open with defaults so existing subclasses keep working. JavaScript: `setMeasureFuncFollowsMeasureModes` and `getMeasureFuncFollowsMeasureModes`. Documented in "Integrating with external layout systems". Tree captures record it, and the benchmark reads it back. - React Native's C++ API snapshots gain the new `facebook::yoga::Node` methods and the new `canUseCachedMeasurement` parameter. - Cost with the default: a bit read and a never-taken branch per cache check of a node with a measure function. On Yoga's C benchmark (`YGBenchmark.c`, opt build) that is +0.04% instructions against the parent commit (`perf stat`, two runs each). Nothing uses this yet: Litho's custom layouts will set it on their Yoga nodes. Changelog: [General][Added] - Add `YGNodeSetMeasureFuncFollowsMeasureModes` to opt out of measure-mode sizing assumptions Reviewed By: adityasharat Differential Revision: D132244372
|
@pentiumao has exported this pull request. If you are a Meta employee, you can view the originating Diff in D132244372. |
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:
YGNodeSetMeasureFuncFollowsMeasureModes(node, false)tells Yoga that the node's measure functiondoesn't size as the measure modes describe (max-content for
Undefined, fit-content forAtMost,stretch-fit for
Exactly), for example because it fills the space it is given or picks a layout byit. Yoga then infers nothing about the node from a measurement under other constraints.
true, today's behaviour.false, the layout cache and the measurement cache reuse the node's measurement onlyunder the same constraints. A node in a column is then measured twice in one layout: with no
height bound, then at exactly the height it measured.
YGErrataMinSizeUndefinedInsteadOfAutois cleared), itsmeasure function isn't called with
AtMost 0. Its min-content size is the one set withYGNodeSetMinContentWidth/Height, if any; otherwise its padding and border plus what itsYGMinContentMeasureFuncreturns, or plus 0 without one.dirty; clones and moves keep it;
YGNodeResetrestorestrue. The deprecatedYGNodeCanUseCachedMeasurementkeeps its signature and behaviour.YogaNode.setMeasureFunctionFollowsMeasureModesandYogaNode.measureFunctionFollowsMeasureModes, open with defaults so existing subclasses keepworking. JavaScript:
setMeasureFuncFollowsMeasureModesandgetMeasureFuncFollowsMeasureModes.Documented in "Integrating with external layout systems". Tree captures record it, and the
benchmark reads it back.
facebook::yoga::Nodemethods and the newcanUseCachedMeasurementparameter.measure function. On Yoga's C benchmark (
YGBenchmark.c, opt build) that is +0.04%instructions against the parent commit (
perf stat, two runs each).Nothing uses this yet: Litho's custom layouts will set it on their Yoga nodes.
Changelog:
[General][Added] - Add
YGNodeSetMeasureFuncFollowsMeasureModesto opt out of measure-mode sizing assumptionsReviewed By: adityasharat
Differential Revision: D132244372