Truly independent web browser
LibWeb: Measure subgrids with an indefinite size in the sized axis
Andreas Klingdb9e752ccad1
diff --git a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rsindex 04bf3cc0fd1..502c5f00275 100644--- a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs@@ -3720,6 +3720,13 @@ impl<'pass> GridFormattingContext<'pass> {if !axis.is_column() && live.has_definite_inline_size {available.inline_size = AvailableSize::definite(live.content_inline_size);}+ // NB: The subgrid's size in the axis being sized depends on the tracks it contributes to, so it is not known+ // yet, and percentages against it (such as those of its gaps) resolve as for an indefinite size.+ if axis.is_column() {+ available.inline_size = AvailableSize::Indefinite;+ } else {+ available.block_size = AvailableSize::Indefinite;+ }let input = LayoutInput::new(available,self.track_sizing_constraints(),diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-grid/subgrid/grid-gap-003-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-grid/subgrid/grid-gap-003-ref.htmlnew file mode 100644index 00000000000..44053f0505a--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-grid/subgrid/grid-gap-003-ref.html@@ -0,0 +1,68 @@+<!DOCTYPE HTML>+<!--+ Any copyright is dedicated to the Public Domain.+ http://creativecommons.org/publicdomain/zero/1.0/+-->+<html><head>+ <meta charset="utf-8">+ <title>Reference: subgrid with border-bottom and percentage gap</title>+ <link rel="author" title="Mats Palmgren" href="mailto:[email protected]">+ <style>+html,body {+ color:black; background-color:white; font:12px/1 monospace; padding:0; margin:0;+}++.grid {+ display: grid;+ grid: 0 15px 15px 0 0 40px / repeat(5, auto);+ place-content: start;+ border: 1px solid;+}++.subgrid {+ display: grid;+ grid: repeat(4, auto) / auto auto;+ gap: 3px 8px;+ background: lightgrey;+ grid-column: 2 / span 5;+ grid-row: 2 / span 5;+ background: grey;+ width: 40px;+ height: 30px;+}++.subgrid > * { background: lightgrey; }++x {+ min-width:10px;+ min-height:0px;+}+x:nth-child(2n+1) { background: silver; }+x:nth-child(2n+2) { background: magenta; }+x:nth-child(2n+3) { background: pink; }+x:nth-child(2n+4) { background: grey; }++e { display:block; width: 20px; height:15px; background:black; }++f {+ grid-area: 4/2/span 1/span 5;+ background: lightblue!important;+ height: 40px;+}+ </style>+</head>+<body>++<div class="grid">+<x style="grid-row:1; height:0"></x><x style="grid-row:2"></x><x style="grid-row:3"></x><x style="grid-row:4"></x><x style="grid-row:5"></x><x style="grid-row:6"></x>+<f></f>+<div class="subgrid">+<c><e></e></c>+<d><e></e></d>+<c><e></e></c>+<d><e></e></d>+</div>+</div>++</body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-grid/subgrid/grid-gap-003.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-grid/subgrid/grid-gap-003.htmlnew file mode 100644index 00000000000..9bfd4a55f99--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-grid/subgrid/grid-gap-003.html@@ -0,0 +1,66 @@+<!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 with border-bottom and percentage gap</title>+ <link rel="author" title="Mats Palmgren" href="mailto:[email protected]">+ <link rel="help" href="https://drafts.csswg.org/css-grid-2">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-grid/subgrid/grid-gap-003-ref.html">+ <style>+html,body {+ color:black; background-color:white; font:12px/1 monospace; padding:0; margin:0;+}++.grid {+ display: grid;+ grid: repeat(4, auto) / repeat(5, auto);+ place-content: start;+ border: 1px solid;+}++.subgrid {+ display: grid;+ grid: subgrid / auto auto;+ gap: 20% 20%;+ background: lightgrey;+ grid-column: 2 / span 5;+ grid-row: 2 / span 5;+ min-width:10px;+ min-height:0;+ border: 0 solid lightblue;+ border-bottom-width: 40px;+ background: grey;+}++.subgrid > * { background: lightgrey; }++x {+ min-width:10px;+ min-height:0px;+}+x:nth-child(2n+1) { background: silver; }+x:nth-child(2n+2) { background: magenta; }+x:nth-child(2n+3) { background: pink; }+x:nth-child(2n+4) { background: grey; }++e { display:block; width: 20px; height:15px; background:black; }++ </style>+</head>+<body>++<div class="grid">+<x style="grid-row:1"></x><x style="grid-row:2"></x><x style="grid-row:3"></x><x style="grid-row:4"></x><x style="grid-row:5"></x><x style="grid-row:6"></x>+<div class="subgrid">+<c><e></e></c>+<d><e></e></d>+<c><e></e></c>+<d><e></e></d>+</div>+</div>++</body>+</html>