[webkit-changes] [WebKit/WebKit] 87d76d: Use unclamped subgrid track sizes to compute track...

mattwoodrow noreply at github.com
Sun Nov 13 14:57:25 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 87d76d7dac687152f8f064a087dd79b02a889203
      https://github.com/WebKit/WebKit/commit/87d76d7dac687152f8f064a087dd79b02a889203
  Author: Matt Woodrow <mattwoodrow at apple.com>
  Date:   2022-11-13 (Sun, 13 Nov 2022)

  Changed paths:
    A LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-010-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-010-ref.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-010.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-011-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-011-ref.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-011.html
    M Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp
    M Source/WebCore/rendering/GridTrackSizingAlgorithm.h
    M Source/WebCore/rendering/RenderGrid.cpp

  Log Message:
  -----------
  Use unclamped subgrid track sizes to compute track positions, so that 'gap' is accounted for correctly.
https://bugs.webkit.org/show_bug.cgi?id=245936
<rdar://100939450>

Reviewed by Alan Baradlay.

When computing subgrid track sizes, we copy the sizing from the parent grid, and then adjust for any gap differences
specific to the current subgrid. This value gets clamped a minimum of 0, losing data about cases where the track size
wasn't expanded to include the subgrid's gap (because the track sizing function didn't allow it, or there were no items
within the subgrid that got contributed to that track to include it).

When we convert from track sizes to track positions, we use the size array and pad it by the gap value (as we do for normal
grids), and fail to account for the fact that the gaps weren't always compensated for in the sizes.

This changes us to store the unclamped value, and makes all of the other callers use a getter which applies clamping. Track
position computation uses the unclamped sizes so that we can always add the gap back in.

An alternative approach here would be to have a subgrid-specific codepath in populateGridPositionsForDirection, which instead
of using the size array, just copies the position array from the parent. We could the adjust for gap separately for each position
(so that we don't accumulate incorrect gaps), or apply the gap when we set the item position within the subgrid.

* LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-010-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-010-ref.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-010.html: Added.

Adds a new WPT where no items get added to the first column, and ensures that we don't add space for a gap in that
column.

* LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-011-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-011-ref.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-grid/subgrid/grid-gap-011.html: Added.

Adds a WPT where the column widths are fixed, and the subgrid tries to add gaps that would cover more than
the entire middle column. Ensures that the positioning of the item in the third column doesn't accumulate extra
left padding from the overlap.

* Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp:
(WebCore::GridTrack::baseSize const):
(WebCore::GridTrack::unclampedBaseSize const):
(WebCore::GridTrack::growthLimit const):
(WebCore::GridTrack::growthLimitIfNotInfinite const):
(WebCore::GridTrack::ensureGrowthLimitIsBiggerThanBaseSize):
(WebCore::GridTrackSizingAlgorithm::copyUsedTrackSizesForSubgrid):
* Source/WebCore/rendering/GridTrackSizingAlgorithm.h:
(WebCore::GridTrack::isGrowthLimitBiggerThanBaseSize const):
* Source/WebCore/rendering/RenderGrid.cpp:
(WebCore::RenderGrid::populateGridPositionsForDirection):

Canonical link: https://commits.webkit.org/256621@main




More information about the webkit-changes mailing list