-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FlexNG] Expand row cross size for fragmentation
Previously, for flex rows, when items expanded as a result of fragmentation, we would only adjust the subsequent rows' offsets based on the expansion amount. However, we also want to expand the row block-size to allow items in that row to stretch to the newly expanded size. Because flex items in a row can break before, we couldn't implement this in the same way as grid (i.e. by storing the results and offsets and then adding them to the builder once all expansion is handled). Otherwise, we could end up with a child break before added to the builder before the previous items in the row had been added. Instead, we need to abort layout and re-run with the updated row block-sizes (using the newly added layout result status of kNeedsRelayoutWithRowCrossSizeChanges and the newly added RelayoutWithNewRowSizes() method). Since we will re-layout as we go, we can no longer wait to detect the row expansion until items have completed layout, but we need to find the max row expansion in each fragmentainer as we go (and as items cross the current row block-size). As such, we now calculate row expansion without making use of NGFlexItem's total_remaining_block_size (as we do for columns). Because more than one row can expand per fragmentainer, we can avoid aborting layout more than once by adjusting subsequent row offsets as expansion is discovered and by keeping track of the expansion of all rows in a given fragmentainer (there should only be at most two row expansions at a time, though). While testing, I ran into a few additional issues: 1. I had noticed a bug with how row expansion was handled for items that broke before. We would previously adjust the offset of all items in the row rather than just the offset of the item itself. This is now fixed by not updating |line_output.item_offset_adjustment| in this case. 2. When checking if the |broke_before_row| is associated with the current row, we can't just check if we are at an item at index 0 since a previous item may have broken as a result of overflow. Check instead if the current item is at index 0 and that it broke before. 3. When adding |item_offset_adjustment| of one row to the next, check if the last item has a break token or if the line has seen all children so that we do so even if the last item overflows. (But if the last item overflowed, we only want to adjust |item_offset_adjustment| if there aren't any additional break tokens to process, in which case the next row would have already started making progress). Note: We will stop row expansion if the container's consumed block-size hits the max to avoid infinite expansion. This keeps the following test from timing out: external/wpt/css/css-break/flexbox/flexbox-fragmentation-layout-001-crash.html multi-line-row-flex-fragmentation-016.html was previously incorrect since item stretching as a result of row expansion was not yet implemented. The test is now updated to account for the new behavior. Bug: 660611 Change-Id: If4fca22d10a43052a2f0218333d3a74752762b79 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3561235 Reviewed-by: Morten Stenshorne <mstensho@chromium.org> Commit-Queue: Alison Maher <almaher@microsoft.com> Cr-Commit-Position: refs/heads/main@{#988612}
- Loading branch information
1 parent
f3b5358
commit 9142fd2
Showing
13 changed files
with
380 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
213 changes: 180 additions & 33 deletions
213
third_party/blink/renderer/core/layout/ng/flex/ng_flex_layout_algorithm.cc
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...k/web_tests/external/wpt/css/css-break/flexbox/multi-line-row-flex-fragmentation-052.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<title> | ||
Multi-line row flex fragmentation: Row expansion and stretching. | ||
</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-flexbox-1/#pagination"> | ||
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> | ||
<style> | ||
#flex { | ||
display: flex; | ||
flex-wrap: wrap; | ||
} | ||
#flex > div { | ||
background: green; | ||
width: 10px; | ||
} | ||
</style> | ||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> | ||
<div style="width: 100px; height: 100px; columns: 5; column-gap: 0; column-fill: auto; position: relative; background: red;"> | ||
<div style="position: absolute; top: 50px; width: 10px; height: 50px; background: green;"></div> | ||
<div style="position: absolute; top: 50px; left: 40px; width: 20px; height: 50px; background: green;"></div> | ||
<div style="position: absolute; left: 70px; width: 10px; height: 50px; background: green;"></div> | ||
<div style="position: absolute; top: 70px; left: 60px; width: 10px; height: 30px; background: green;"></div> | ||
<div id="flex"> | ||
<div style="width: 20px; height: 50px;"></div> | ||
<div style="margin-top: 40px; height: 60px; contain: size;"></div> | ||
<div></div> | ||
<div style="width: 20px; height: 90px;"></div> | ||
<div style="margin-top: 40px; height: 70px; contain: size;"></div> | ||
<div style="margin-top: 100px; height: 50px; contain: size;"></div> | ||
<div style="height: 100px; break-before: column;"></div> | ||
<div></div> | ||
</div> | ||
</div> |
37 changes: 37 additions & 0 deletions
37
...k/web_tests/external/wpt/css/css-break/flexbox/multi-line-row-flex-fragmentation-053.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE html> | ||
<title> | ||
Multi-line row flex fragmentation: Row expansion and stretching with item overflow. | ||
</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-flexbox-1/#pagination"> | ||
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> | ||
<style> | ||
#flex { | ||
display: flex; | ||
flex-wrap: wrap; | ||
} | ||
#flex > div { | ||
background: green; | ||
width: 50%; | ||
} | ||
</style> | ||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> | ||
<div style="width: 100px; height: 100px; columns: 5; column-gap: 0; column-fill: auto; position: relative; background: red;"> | ||
<div id="flex"> | ||
<div> | ||
<div style="height: 30px;"></div> | ||
<div style="height: 50px; break-before: column;"></div> <!-- The break-before forces the grid-item into the next column, and grows the row. --> | ||
</div> | ||
<div></div> | ||
<div> | ||
<div style="height: 30px;"></div> | ||
<div style="height: 10px; break-before: column;"></div> <!-- The break-before forces the grid-item into the next column, and grows the row. --> | ||
</div> | ||
<div></div> | ||
<div></div> | ||
<div style="height: 100px;"> | ||
<div style="height: 200px;"></div> | ||
</div> | ||
<div style="height: 190px;"></div> | ||
<div></div> | ||
</div> | ||
</div> |
32 changes: 32 additions & 0 deletions
32
...k/web_tests/external/wpt/css/css-break/flexbox/multi-line-row-flex-fragmentation-054.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<title> | ||
Multi-line row flex fragmentation: Row expansion and stretching. | ||
</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-flexbox-1/#pagination"> | ||
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> | ||
<style> | ||
#flex { | ||
display: flex; | ||
flex-wrap: wrap; | ||
} | ||
#flex > div { | ||
background: green; | ||
width: 10px; | ||
} | ||
</style> | ||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> | ||
<div style="width: 100px; height: 100px; columns: 5; column-gap: 0; column-fill: auto; position: relative; background: red;"> | ||
<div style="position: absolute; top: 40px; left: 20px; width: 20px; height: 60px; background: green;"></div> | ||
<div id="flex"> | ||
<div> | ||
<div style="contain: size; width: 10px; height: 80px;"></div> | ||
<div style="contain: size; width: 10px; height: 30px;"></div> | ||
</div> | ||
<div> | ||
<div style="contain: size; width: 10px; height: 70px;"></div> | ||
<div style="contain: size; width: 10px; height: 40px;"></div> | ||
</div> | ||
<div style="width: 20px; height: 100px; break-inside: avoid;"></div> | ||
<div style="height: 200px; width: 20px;"></div> | ||
</div> | ||
</div> |
27 changes: 27 additions & 0 deletions
27
...k/web_tests/external/wpt/css/css-break/flexbox/multi-line-row-flex-fragmentation-055.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<title> | ||
Multi-line row flex fragmentation: Item overflow and stretching. | ||
</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-flexbox-1/#pagination"> | ||
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> | ||
<style> | ||
#flex { | ||
display: flex; | ||
flex-wrap: wrap; | ||
} | ||
#flex > div { | ||
background: green; | ||
width: 50%; | ||
} | ||
</style> | ||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> | ||
<div style="width: 100px; height: 100px; columns: 5; column-gap: 0; column-fill: auto; position: relative; background: red;"> | ||
<div id="flex"> | ||
<div style="height: 100px;"> | ||
<div style="height: 200px;"></div> | ||
</div> | ||
<div></div> | ||
<div style="height: 400px;"></div> | ||
<div></div> | ||
</div> | ||
</div> |
27 changes: 27 additions & 0 deletions
27
.../web_tests/external/wpt/css/css-break/flexbox/single-line-row-flex-fragmentation-029.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<title> | ||
Single-line row flex fragmentation: Row expansion, stretching and column balancing. | ||
</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-flexbox-1/#pagination"> | ||
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> | ||
<style> | ||
#flex { | ||
display: flex; | ||
} | ||
#flex > div { | ||
background: green; | ||
width: 25px; | ||
} | ||
</style> | ||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> | ||
<div style="width: 100px; height: 100px; background: red;"> | ||
<div style="width: 100px; columns: 2; column-gap: 0;"> | ||
<div id="flex"> | ||
<div></div> | ||
<div> | ||
<div style="contain: size; width: 10px; height: 70px;"></div> | ||
<div style="contain: size; width: 10px; height: 100px;"></div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |