Add `YGMeasureModeMinContent` and support for computing min/max content sizes of nodes
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18.9k
- Forks
- 1.6k
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
Objective
Help make Yoga's flexbox implementation spec compliant.
Context
The spec defines both min-content and max-content sizes, and both are needed to correctly implement CSS layout algorithms. But Yoga currently only supports max-content sizing, which it calls YGMeasureModeUndefined
// The spec describes four different layout modes: "fill available", "max
// content", "min content", and "fit content". Of these, we don't use "min
// content" because we don't support default minimum main sizes (see above
// for details). Each of our measure modes maps to a layout mode from the
// spec (https://www.w3.org/TR/CSS3-sizing/#terms):
// - YGMeasureModeUndefined: max content
// - YGMeasureModeExactly: fill available
// - YGMeasureModeAtMost: fit content
//
// When calling YGNodelayoutImpl and YGLayoutNodeInternal, if the caller
// passes an available size of undefined then it must also pass a measure
// mode of YGMeasureModeUndefined in that dimension.
https://github.com/facebook/yoga/blob/974473aa99a2432b2f083446fc5ff9f71c4a3b08/yoga/Yoga.cpp#L2687
Steps
- Rename
YGMeasureModeUndefinedvariant ofYGMeasureModeenum toYGMeasureModeMaxContent - Add
YGMeasureModeMinContentvariant toYGMeasureModeenum - Implement min-content sizing logic. This mostly involves passing through min-content to children. But also requires different sizing behaviour when sizing
flex-wrap: wrapnodes.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the YGMeasureMode enum and the layout paths named in yoga/Yoga.cpp, especially YGNodelayoutImpl and YGLayoutNodeInternal. Trace how YGMeasureModeUndefined currently represents max-content sizing, then determine the changes needed for a distinct min-content mode and wrapped nodes. Done means the enum is renamed, min-content sizing is implemented, and Yoga follows the stated CSS sizing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100