Add YGMeasureModeMinContent and support for computing min/max content sizes of nodes #1298

Open
opened 2023-05-15 08:11:58 -07:00 by nicoburns · 0 comments
nicoburns commented 2023-05-15 08:11:58 -07:00 (Migrated from github.com)

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.

974473aa99/yoga/Yoga.cpp (L2687)

Steps

  • Rename YGMeasureModeUndefined variant of YGMeasureMode enum to YGMeasureModeMaxContent
  • Add YGMeasureModeMinContent variant to YGMeasureMode enum
  • Implement min-content sizing logic. This mostly involves passing through min-content to children. But also requires different sizing behaviour when sizing flex-wrap: wrap nodes.
# 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` ```cxx // 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 `YGMeasureModeUndefined` variant of `YGMeasureMode` enum to `YGMeasureModeMaxContent` - Add `YGMeasureModeMinContent` variant to `YGMeasureMode` enum - Implement min-content sizing logic. This mostly involves passing through min-content to children. But also requires different sizing behaviour when sizing `flex-wrap: wrap` nodes.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DaddyFrosty/yoga#1298
No description provided.