Skip to content

Commit

Permalink
Fix align-content of cross-stretched container (facebook#41964)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#41964

X-link: facebook/yoga#1524

D52087013 (facebook#1513) fixed some issues, including where measuring under max-content or fit-content, align-content stretch would consume the entire available cross-dimensions, instead of only sizing to definite dimension, like the spec dicates.

I missed a case, where flexbox considers a container as having a definite cross-size if it is being stretched, even if it doesn't have a definite length.

https://www.w3.org/TR/css-flexbox-1/#definite-sizes

> 3. Once the cross size of a flex line has been determined, items in auto-sized flex containers are also considered definite for the purpose of layout;

> 1. If a single-line flex container has a definite cross size, the outer cross size of any stretched flex items is the flex container’s inner cross size (clamped to the flex item’s min and max cross size) and is considered definite.

We handle `align-items: stretch` of a flex container after cross-size determination by laying out the child under stretch-fit (previously YGMeasureModeExactly) constraint. This checks that case, and sizing the line container to specified cross-dim if we are told to stretch to it.

We could probably afford to merge this a bit with later with what is currently step 9, where we end up redoing some of this same math.

Reviewed By: yungsters

Differential Revision: D52234980

fbshipit-source-id: 475773a352fd01f63a4b21e93a55519726dc0da7
  • Loading branch information
NickGerleman authored and Othinn committed Jan 9, 2024
1 parent 650becf commit 571d89b
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1743,8 +1743,9 @@ static void calculateLayoutImpl(
float leadPerLine = 0;
float currentLead = leadingPaddingAndBorderCross;

const float unclampedCrossDim =
node->styleDefinesDimension(crossAxis, crossAxisownerSize)
const float unclampedCrossDim = sizingModeCrossDim == SizingMode::StretchFit
? availableInnerCrossDim + paddingAndBorderAxisCross
: node->styleDefinesDimension(crossAxis, crossAxisownerSize)
? yoga::resolveValue(
node->getResolvedDimension(dimension(crossAxis)),
crossAxisownerSize)
Expand Down

0 comments on commit 571d89b

Please sign in to comment.