Skip to content

Commit

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

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
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Dec 17, 2023
1 parent 464d166 commit 3e18b3b
Show file tree
Hide file tree
Showing 5 changed files with 1,500 additions and 5 deletions.
36 changes: 36 additions & 0 deletions gentest/fixtures/YGAlignContentTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,39 @@
<div style="height: 100px; width: 120px;"></div>
<div style="height: 50px; width: 120px;"></div>
</div>

<div id="align_content_flex_start_stretch_doesnt_influence_line_box_dim" style="width: 400px; flex-direction: row; padding-top: 20px; padding-bottom: 20px; padding-left: 20px; padding-right: 20px;">
<div style="height: 100px; width: 100px; margin-right: 20px;"></div>
<div style="flex-direction: row; flex-wrap: wrap; flex-shrink: 1; flex-grow: 1; align-content: flex-start;">
<div style="height: 30px; width: 30px; margin-right: 20px;"></div>
<div style="height: 30px; width: 30px; margin-right: 20px;"></div>
<div style="height: 30px; width: 30px; margin-right: 20px;"></div>
<div style="height: 30px; width: 30px; margin-right: 20px;"></div>
<div style="height: 30px; width: 30px; margin-right: 20px;"></div>
</div>
<div style="height: 50px; width: 50px; margin-left: 20px;"></div>
</div>

<div id="align_content_stretch_stretch_does_influence_line_box_dim" style="width: 400px; flex-direction: row; padding-top: 20px; padding-bottom: 20px; padding-left: 20px; padding-right: 20px;">
<div style="height: 100px; width: 100px; margin-right: 20px;"></div>
<div style="flex-direction: row; flex-wrap: wrap; flex-shrink: 1; flex-grow: 1; align-content: stretch;">
<div style="height: 30px; width: 30px; margin-right: 20px;"></div>
<div style="height: 30px; width: 30px; margin-right: 20px;"></div>
<div style="height: 30px; width: 30px; margin-right: 20px;"></div>
<div style="height: 30px; width: 30px; margin-right: 20px;"></div>
<div style="height: 30px; width: 30px; margin-right: 20px;"></div>
</div>
<div style="height: 50px; width: 50px; margin-left: 20px;"></div>
</div>

<div id="align_content_space_evenly_stretch_does_influence_line_box_dim" style="width: 400px; flex-direction: row; padding-top: 20px; padding-bottom: 20px; padding-left: 20px; padding-right: 20px;">
<div style="height: 100px; width: 100px; margin-right: 20px;"></div>
<div style="flex-direction: row; flex-wrap: wrap; flex-shrink: 1; flex-grow: 1; align-content: stretch;">
<div style="height: 30px; width: 30px; margin-right: 20px;"></div>
<div style="height: 30px; width: 30px; margin-right: 20px;"></div>
<div style="height: 30px; width: 30px; margin-right: 20px;"></div>
<div style="height: 30px; width: 30px; margin-right: 20px;"></div>
<div style="height: 30px; width: 30px; margin-right: 20px;"></div>
</div>
<div style="height: 50px; width: 50px; margin-left: 20px;"></div>
</div>
Loading

0 comments on commit 3e18b3b

Please sign in to comment.