Skip to content

Commit

Permalink
[GridNG] Don't consider a subgridded axis size in ExpandFlexibleTracks
Browse files Browse the repository at this point in the history
1. Fixing a bug where `ExpandFlexibleTracks` considered the contribution
   size of a subgrid in its subgridded axis, triggering a DCHECK when
   its `NGGridLayoutTrackCollection` is not able perform the sizing
   algorithm since it's inherited by the subgrid's parent grid.

   From https://drafts.csswg.org/css-grid-2/#subgrid-size-contribution,
   in this scenario we should treat the subgrid contribution size as
   empty and not consider it when resolving the size of an `fr`.

2. Adding test coverage to the WPT suite for this issue.

(cherry picked from commit 99b1299)

Bug: 1447363
Change-Id: I0a31399a3cb29ffcfa696bc5cdf583150280a1d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4571270
Commit-Queue: Ethan Jimenez <ethavar@microsoft.com>
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1150050}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4574058
Reviewed-by: Alison Maher <almaher@microsoft.com>
Cr-Commit-Position: refs/branch-heads/5790@{#150}
Cr-Branched-From: 1d71a33-refs/heads/main@{#1148114}
  • Loading branch information
ethanjv authored and Chromium LUCI CQ committed May 30, 2023
1 parent 92d381e commit b487d5e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
Expand Up @@ -2915,7 +2915,8 @@ void NGGridLayoutAlgorithm::ExpandFlexibleTracks(
// finding the size of an fr using all the grid tracks that the item
// crosses and a space to fill of the item’s max-content contribution.
for (auto& grid_item : sizing_data.grid_items) {
if (grid_item.IsSpanningFlexibleTrack(track_direction)) {
if (grid_item.IsConsideredForSizing(track_direction) &&
grid_item.IsSpanningFlexibleTrack(track_direction)) {
double grid_item_fr_size =
FindFrSize(GetSetIteratorForItem(grid_item, track_collection),
ContributionSizeForGridItem(
Expand Down
@@ -0,0 +1,42 @@
<!DOCTYPE HTML>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html>
<head>
<meta charset="utf-8">
<title>CSS Grid Test: Subgrid contribution size to flexible tracks</title>
<link rel="author" title="Ethan Jimenez" href="mailto:ethavar@microsoft.com">
<link rel="help" href="https://drafts.csswg.org/css-grid-2/#subgrid-size-contribution">
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht">
<style>
.grid {
background: red;
display: inline-grid;
grid-template: repeat(4, minmax(0, 1fr)) / repeat(10, minmax(0, 1fr));
}
.subgrid {
width: 50px;
height: 50px;
background: green;
display: grid;
grid-row: 1 / -1;
grid-column: 1 / -1;
grid-template: subgrid / subgrid;
}
.item {
width: 10px;
height: 25px;
}
</style>
</head>
<body>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div class="grid">
<div class="subgrid">
<div class="item"></div>
</div>
</div>
</body>
</html>
Expand Up @@ -8,7 +8,7 @@
<meta charset="utf-8">
<title>CSS Grid Test: Subgrid with no grid items accommodates border and padding</title>
<link rel="author" title="Ethan Jimenez" href="mailto:ethavar@microsoft.com">
<link rel="help" href="https://drafts.csswg.org/css-grid-2">
<link rel="help" href="https://drafts.csswg.org/css-grid-2/#subgrid-edge-placeholders">
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht">
<style>
.wrapper {
Expand Down
Expand Up @@ -8,7 +8,7 @@
<meta charset="utf-8">
<title>CSS Grid Test: Subgrid with no grid items accommodates gutter size and padding</title>
<link rel="author" title="Ethan Jimenez" href="mailto:ethavar@microsoft.com">
<link rel="help" href="https://drafts.csswg.org/css-grid-2">
<link rel="help" href="https://drafts.csswg.org/css-grid-2/#subgrid-edge-placeholders">
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht">
<style>
.wrapper {
Expand Down

0 comments on commit b487d5e

Please sign in to comment.