Skip to content

Commit 4d86d7f

Browse files
sammygillannevk
authored andcommitted
[GFC] Grid container min/max sizes ignore box-sizing: border-box.
constraintsForGridContent() passed the grid container's computed min/max-width and min/max-height straight to the track sizing algorithm, which works in terms of the content box. When the container has box-sizing: border-box these values include its border and padding, so GFC overestimated the container's minimum and maximum content size. For an indefinite block size this inflated the free space used to stretch auto rows and to clamp the flex fraction, making rows (and the grid) too tall. Convert the min/max sizes to content-box sizes with the same RenderBox helpers legacy layout uses. WebKit-Bug: https://bugs.webkit.org/show_bug.cgi?id=326424 WebKit-Canonical-Link: https://commits.webkit.org/322856@main
1 parent 2f26f1c commit 4d86d7f

3 files changed

Lines changed: 131 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!DOCTYPE HTML>
2+
<title>CSS Grid Layout Test: border-box min and max height when computing the flex row</title>
3+
<link rel="author" title="Sammy Gill" href="mailto:[email protected]"/>
4+
<link rel="help" href="https://drafts.csswg.org/css-grid/#algo-flex-tracks"/>
5+
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#box-sizing"/>
6+
<link href="/css/support/grid.css" rel="stylesheet"/>
7+
<meta name="assert" content="This test ensures that minimum and maximum heights on a grid container with box-sizing: border-box exclude its border and padding when computing the flex fraction for grid rows."/>
8+
<style>
9+
.grid {
10+
margin: 3px;
11+
grid: minmax(10px, 1fr) minmax(10px, 4fr) / 50px;
12+
grid-row-gap: 33px;
13+
border: 5px dashed;
14+
padding: 2px;
15+
box-sizing: border-box;
16+
}
17+
18+
.float { float: left; }
19+
20+
.item:nth-child(1) { background-color: purple; }
21+
.item:nth-child(2) { background-color: blue; }
22+
</style>
23+
24+
<script src="/resources/testharness.js"></script>
25+
<script src="/resources/testharnessreport.js"></script>
26+
<script src="/resources/check-layout-th.js"></script>
27+
<body onload="checkLayout('.grid')">
28+
<div id="log"></div>
29+
30+
<p>This test PASS if all the grids in the same row look the same.</p>
31+
32+
<div class="grid float" style="max-height: 84px" data-expected-width="64" data-expected-height="84">
33+
<div class="item" data-expected-width="50" data-expected-height="10"></div>
34+
<div class="item" data-expected-width="50" data-expected-height="27"></div>
35+
</div>
36+
<div class="grid float" style="min-height: 84px; max-height: 74px" data-expected-width="64" data-expected-height="84">
37+
<div class="item" data-expected-width="50" data-expected-height="10"></div>
38+
<div class="item" data-expected-width="50" data-expected-height="27"></div>
39+
</div>
40+
<div class="grid float" style="height: 84px" data-expected-width="64" data-expected-height="84">
41+
<div class="item" data-expected-width="50" data-expected-height="10"></div>
42+
<div class="item" data-expected-width="50" data-expected-height="27"></div>
43+
</div>
44+
45+
<br clear="all">
46+
47+
<div class="grid float" style="min-height: 122px" data-expected-width="64" data-expected-height="122">
48+
<div class="item" data-expected-width="50" data-expected-height="15"></div>
49+
<div class="item" data-expected-width="50" data-expected-height="60"></div>
50+
</div>
51+
<div class="grid float" style="min-height: 122px; max-height: 74px" data-expected-width="64" data-expected-height="122">
52+
<div class="item" data-expected-width="50" data-expected-height="15"></div>
53+
<div class="item" data-expected-width="50" data-expected-height="60"></div>
54+
</div>
55+
<div class="grid float" style="height: 122px" data-expected-width="64" data-expected-height="122">
56+
<div class="item" data-expected-width="50" data-expected-height="15"></div>
57+
<div class="item" data-expected-width="50" data-expected-height="60"></div>
58+
</div>
59+
</body>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>CSS Grid Layout Test: stretch alignment respects border-box min size constraints of the grid container with border</title>
4+
<link rel="author" title="Sammy Gill" href="mailto:[email protected]">
5+
<link rel="help" href="https://drafts.csswg.org/css-grid-1/#algo-stretch">
6+
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#box-sizing">
7+
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht">
8+
<meta name="assert" content="The test checks that during the last step of the track sizing algorithm (stretch auto tracks), a min-height on a grid container with box-sizing: border-box excludes the container's border.">
9+
<style>
10+
#reference-overlapped-red {
11+
position: absolute;
12+
background-color: red;
13+
width: 100px;
14+
height: 100px;
15+
z-index: -1;
16+
}
17+
18+
#grid {
19+
display: grid;
20+
grid-template-columns: auto;
21+
box-sizing: border-box;
22+
width: 100px;
23+
min-height: 100px;
24+
border: 10px solid green;
25+
}
26+
27+
#test-item-overlapping-green {
28+
background: green;
29+
}
30+
</style>
31+
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
32+
33+
<div id="reference-overlapped-red"></div>
34+
<div id="grid">
35+
<div id="test-item-overlapping-green"></div>
36+
</div>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>CSS Grid Layout Test: stretch alignment respects border-box min size constraints of the grid container with padding</title>
4+
<link rel="author" title="Sammy Gill" href="mailto:[email protected]">
5+
<link rel="help" href="https://drafts.csswg.org/css-grid-1/#algo-stretch">
6+
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#box-sizing">
7+
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht">
8+
<meta name="assert" content="The test checks that during the last step of the track sizing algorithm (stretch auto tracks), a min-height on a grid container with box-sizing: border-box excludes the container's padding.">
9+
<style>
10+
#reference-overlapped-red {
11+
position: absolute;
12+
background-color: red;
13+
width: 100px;
14+
height: 100px;
15+
z-index: -1;
16+
}
17+
18+
#grid {
19+
display: grid;
20+
grid-template-columns: auto;
21+
box-sizing: border-box;
22+
width: 100px;
23+
min-height: 100px;
24+
padding: 10px; background: green;
25+
}
26+
27+
#test-item-overlapping-green {
28+
background: green;
29+
}
30+
</style>
31+
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
32+
33+
<div id="reference-overlapped-red"></div>
34+
<div id="grid">
35+
<div id="test-item-overlapping-green"></div>
36+
</div>

0 commit comments

Comments
 (0)