Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
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
- Loading branch information
Showing
9 changed files
with
96 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE HTML> | ||
<html><head> | ||
<meta charset="utf-8"> | ||
<title>CSS Grid Test: Subgrids with empty tracks and column gap</title> | ||
<link rel="author" title="Matt Woodrow" href="mailto:mattwoodrow@apple.com"> | ||
<link rel="help" href="https://drafts.csswg.org/css-grid-2"> | ||
</head> | ||
<body> | ||
<div style="width:100px; height: 100px; background-color: blue; position:relative; left:50px;"></div> | ||
</body> | ||
</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,11 @@ | ||
<!DOCTYPE HTML> | ||
<html><head> | ||
<meta charset="utf-8"> | ||
<title>CSS Grid Test: Subgrids with empty tracks and column gap</title> | ||
<link rel="author" title="Matt Woodrow" href="mailto:mattwoodrow@apple.com"> | ||
<link rel="help" href="https://drafts.csswg.org/css-grid-2"> | ||
</head> | ||
<body> | ||
<div style="width:100px; height: 100px; background-color: blue; position:relative; left:50px;"></div> | ||
</body> | ||
</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,16 @@ | ||
<!DOCTYPE HTML> | ||
<html><head> | ||
<meta charset="utf-8"> | ||
<title>CSS Grid Test: Subgrids with empty tracks and column gap</title> | ||
<link rel="author" title="Matt Woodrow" href="mailto:mattwoodrow@apple.com"> | ||
<link rel="help" href="https://drafts.csswg.org/css-grid-2"> | ||
<link rel="match" href="grid-gap-010-ref.html"> | ||
</head> | ||
<body> | ||
<div style="display:grid; grid-template-columns: auto 200px; width: 200px"> | ||
<div style="display:grid; grid-template-columns: subgrid; gap: 100px; grid-column: span 2"> | ||
<div style="width:100px; height: 100px; background-color: blue; grid-column: 2"></div> | ||
</div> | ||
</div> | ||
</body> | ||
</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,11 @@ | ||
<!DOCTYPE HTML> | ||
<html><head> | ||
<meta charset="utf-8"> | ||
<title>CSS Grid Test: Subgrids with empty tracks and column gap</title> | ||
<link rel="author" title="Matt Woodrow" href="mailto:mattwoodrow@apple.com"> | ||
<link rel="help" href="https://drafts.csswg.org/css-grid-2"> | ||
</head> | ||
<body> | ||
<div style="width:200px; height: 100px; background-color: blue; position:relative; left:175px;"></div> | ||
</body> | ||
</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,11 @@ | ||
<!DOCTYPE HTML> | ||
<html><head> | ||
<meta charset="utf-8"> | ||
<title>CSS Grid Test: Subgrids with empty tracks and column gap</title> | ||
<link rel="author" title="Matt Woodrow" href="mailto:mattwoodrow@apple.com"> | ||
<link rel="help" href="https://drafts.csswg.org/css-grid-2"> | ||
</head> | ||
<body> | ||
<div style="width:200px; height: 100px; background-color: blue; position:relative; left:175px;"></div> | ||
</body> | ||
</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,17 @@ | ||
<!DOCTYPE HTML> | ||
<html><head> | ||
<meta charset="utf-8"> | ||
<title>CSS Grid Test: Subgrids with column gap larger than the track size</title> | ||
<link rel="author" title="Matt Woodrow" href="mailto:mattwoodrow@apple.com"> | ||
<link rel="help" href="https://drafts.csswg.org/css-grid-2"> | ||
<link rel="match" href="grid-gap-011-ref.html"> | ||
</head> | ||
<body> | ||
<div style="display:grid; grid-template-columns: 100px 100px 100px; width: 300px"> | ||
<div style="display:grid; grid-template-columns: subgrid; gap: 150px; grid-column: span 3"> | ||
<div style="width:100px; height: 100px; background-color: blue; grid-column: 2"></div> | ||
<div style="width:100px; height: 100px; background-color: blue; grid-column: 3"></div> | ||
</div> | ||
</div> | ||
|
||
</body> |
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