Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: c3dbdf3e5964008fab9b6618989dd9f3ccae056c
https://github.com/WebKit/WebKit/commit/c3dbdf3e5964008fab9b6618989dd9f3ccae056c
Author: Sammy Gill <[email protected]>
Date: 2025-06-16 (Mon, 16 Jun 2025)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/layout-algorithm/grid-content-distribution-must-account-for-track-sizing-002-expected.txt
M Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp
M Source/WebCore/rendering/GridTrackSizingAlgorithm.h
M Source/WebCore/rendering/RenderGrid.cpp
M Source/WebCore/rendering/RenderGrid.h
Log Message:
-----------
[Grid] Fix
css-grid/layout-algorithm/grid-content-distribution-must-account-for-track-sizing-002
WPT.
https://bugs.webkit.org/show_bug.cgi?id=232667
rdar://problem/85252183
Reviewed by Alan Baradlay.
>From the grid spec regarding the first pass of column sizing:
"If calculating the layout of a grid item in this step depends on the
available space in the block axis, assume the available space that
it would have if any row with a definite max track sizing function
had that size and all other rows were infinite. If both the grid
container and all tracks have definite sizes, also apply
align-content to find the final effective size of any gaps spanned
by such items; otherwise ignore the effects of track alignment in
this estimation."
https://drafts.csswg.org/css-grid-2/#algo-grid-sizing
The WPT mentioned in the title has content of the following lines:
<grid style="display: inline-grid; grid-template-rows: 50px 50px; height:
200px;">
<item style="grid-row: span 2; writing-mode: vertical-lr;">
some text content inside of the grid item
</item>
</grid>
We end up computing an incorrect width for the grid because of the following:
1.) We call into RenderGrid::computeIntrinsicLogicalWidths to compute
its intrinsic sizes.
2.) The min/max-content sizes of the grid container are the sum of the
track sizes which requires running the track sizing algorithm.
3.) When sizing the columns we detect this case that the spec mentions
above, but we fail to apply the space from the align-content
space-between distribution.
In the test case, since the block size is definite (200px) and the row
sizes are all definite (50px each), we should be able to figure out how
the spacing from the content alignment should be calculated and
distributed.
* Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp:
(WebCore::GridTrackSizingAlgorithm::gridAreaBreadthForGridItem const):
We properly check for this case by seeing if the grid container has a
definite size via availableLogicalHeightForContentBox, which should
return std::nullopt if the available space is indefinite, and a helper
method to check that all of the row sizes are definite.
(WebCore::GridTrackSizingAlgorithm::hasAllLengthTrackSizingRows const):
Aforementioned helper method to check if the row track sizes are
definite. This is done by checking The GridTrackSizeType for each row to
make sure it is LengthTrackSizing to refer to the <track-breadth>
portion of the <track-size> syntax. We also need to check that
<track-breadth> is a length of percentage as opposed to something like
a flex value.
* Source/WebCore/rendering/GridTrackSizingAlgorithm.h:
* Source/WebCore/rendering/RenderGrid.cpp:
(WebCore::RenderGrid::hasDefiniteLogicalHeight const):
(WebCore::RenderGrid::availableLogicalHeightForContentBox const):
(WebCore::RenderGrid::layoutGrid):
This should just be a small code reshuffling so that
availableLogicalHeightForContextBox is available to use from the track
sizing algorithm. Instead of using a bool to keep track of whether we
are going to size the rows using a definite height and then compute that
height. We can attempt to compute this earlier and store the result in a
std::optional<LayoutUnit> that represents where or not the available
logical height is definite. We need to do this after the call to
updateLogicalWidth since aspect-ratio may use the grid's logical width
to compute the logical height.
Canonical link: https://commits.webkit.org/296300@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes