Skip to content

Commit 571d89b

Browse files
NickGerlemanOthinn
authored andcommitted
Fix align-content of cross-stretched container (facebook#41964)
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
1 parent 650becf commit 571d89b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,8 +1743,9 @@ static void calculateLayoutImpl(
17431743
float leadPerLine = 0;
17441744
float currentLead = leadingPaddingAndBorderCross;
17451745

1746-
const float unclampedCrossDim =
1747-
node->styleDefinesDimension(crossAxis, crossAxisownerSize)
1746+
const float unclampedCrossDim = sizingModeCrossDim == SizingMode::StretchFit
1747+
? availableInnerCrossDim + paddingAndBorderAxisCross
1748+
: node->styleDefinesDimension(crossAxis, crossAxisownerSize)
17481749
? yoga::resolveValue(
17491750
node->getResolvedDimension(dimension(crossAxis)),
17501751
crossAxisownerSize)

0 commit comments

Comments
 (0)