Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

### Added

- Initial support for CSS Grid Level 3 [Grid Lanes](https://drafts.csswg.org/css-grid-3/) behind the new `grid_lanes` feature (#1270). `Display::GridLanes` lays items out in a waterfall along the stacking axis of a container whose tracks are defined in the other axis (`GridLanesDirection`; `Style::grid_lanes_direction` / `GridContainerStyle::grid_lanes_direction()`), with the auto-placement tie threshold set by `Style::fit_tolerance` / `GridContainerStyle::fit_tolerance()` (a `LengthPercentage`; `infinite` is `LengthPercentage::length(f32::INFINITY)`). The new trait getters have default implementations. Auto-placed items contribute to intrinsic grid-axis track sizes through the spec's virtual-item optimization (#1272). Containers whose `grid_auto_flow` is dense backfill items into skipped spaces (#1274). Stacking-axis alignment and absolutely positioned children follow in later releases
- Initial support for CSS Grid Level 3 [Grid Lanes](https://drafts.csswg.org/css-grid-3/) behind the new `grid_lanes` feature (#1270). `Display::GridLanes` lays items out in a waterfall along the stacking axis of a container whose tracks are defined in the other axis (`GridLanesDirection`; `Style::grid_lanes_direction` / `GridContainerStyle::grid_lanes_direction()`), with the auto-placement tie threshold set by `Style::fit_tolerance` / `GridContainerStyle::fit_tolerance()` (a `LengthPercentage`; `infinite` is `LengthPercentage::length(f32::INFINITY)`). The new trait getters have default implementations. Auto-placed items contribute to intrinsic grid-axis track sizes through the spec's virtual-item optimization (#1272). Containers whose `grid_auto_flow` is dense backfill items into skipped spaces (#1274). `align_content`/`justify_content` in the stacking axis moves the stacking range as a whole, and items adjacent to a gap (the last item in a track, or one followed by a spanning item) align within their margin box plus that gap with `align_self`/`justify_self`; baseline alignment in the stacking axis falls back to `start` (#1275). Absolutely positioned children follow in a later release
- `CoreStyle::is_replaced()` (defaulting to `false`; `Style::item_is_replaced`) now identifies [replaced elements](https://html.spec.whatwg.org/multipage/rendering.html#replaced-elements) for absolute positioning: only these (and tables) are exempt from being stretched between their insets under `normal` alignment. `CoreStyle::is_compressible_replaced()` now has its css-sizing meaning of [compressible replaced element](https://drafts.csswg.org/css-sizing-3/#compressible) — replaced elements *plus* form controls with an intrinsic size (`input`, `select`, `textarea`, `progress`, `meter`) — and is what block layout consults when deciding that an auto-width block-level box takes its intrinsic width rather than being stretched (matching browsers, where a block-level `<input>` keeps its intrinsic width but a `position: absolute; left: 0; right: 0` one is stretched). `Style` gains `item_is_compressible_replaced` for the form-control case; `item_is_replaced: true` continues to imply both.
- `AlignSelf::is_stretch_or_normal` returns whether an alignment's keyword is `Stretch` or `Normal`
- `AlignItems`, `AlignItemsKeyword` and `AlignmentSafety` now implement `Default` (`AlignItems::NORMAL`, `AlignItemsKeyword::Normal` and `AlignmentSafety::Default`)
Expand Down
171 changes: 137 additions & 34 deletions src/compute/grid/lanes.rs

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions test_fixtures/grid_lanes/grid_lanes_align_content_center.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../../scripts/gentest/test_helper.js"></script>
<link rel="stylesheet" type="text/css" href="../../scripts/gentest/test_base_style.css">
<title>
Grid Lanes: align-content centers the stacking range
</title>
</head>
<body>

<div id="test-root" style="display: grid-lanes; grid-template-columns: 40px 40px 40px; width: 120px; height: 100px; align-content: center;">
<div style="height: 30px;"></div>
<div style="height: 20px;"></div>
<div style="height: 10px;"></div>
<div style="height: 20px;"></div>
</div>

</body>
</html>
20 changes: 20 additions & 0 deletions test_fixtures/grid_lanes/grid_lanes_align_content_end.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../../scripts/gentest/test_helper.js"></script>
<link rel="stylesheet" type="text/css" href="../../scripts/gentest/test_base_style.css">
<title>
Grid Lanes: align-content end shifts the stacking range to the end edge
</title>
</head>
<body>

<div id="test-root" style="display: grid-lanes; grid-template-columns: 40px 40px 40px; width: 120px; height: 100px; align-content: end;">
<div style="height: 30px;"></div>
<div style="height: 20px;"></div>
<div style="height: 10px;"></div>
<div style="height: 20px;"></div>
</div>

</body>
</html>
20 changes: 20 additions & 0 deletions test_fixtures/grid_lanes/grid_lanes_align_content_safe_end.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../../scripts/gentest/test_helper.js"></script>
<link rel="stylesheet" type="text/css" href="../../scripts/gentest/test_base_style.css">
<title>
Grid Lanes: safe end alignment falls back to start when the stacking range overflows
</title>
</head>
<body>

<div id="test-root" style="display: grid-lanes; grid-template-columns: 40px 40px 40px; width: 120px; height: 40px; align-content: safe end;">
<div style="height: 30px;"></div>
<div style="height: 20px;"></div>
<div style="height: 10px;"></div>
<div style="height: 40px;"></div>
</div>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../../scripts/gentest/test_helper.js"></script>
<link rel="stylesheet" type="text/css" href="../../scripts/gentest/test_base_style.css">
<title>
Grid Lanes: distributed content alignment falls back in the stacking axis
</title>
</head>
<body>

<div id="test-root" style="display: grid-lanes; grid-template-columns: 40px 40px 40px; width: 120px; height: 100px; align-content: space-around;">
<div style="height: 30px;"></div>
<div style="height: 20px;"></div>
<div style="height: 10px;"></div>
<div style="height: 20px;"></div>
</div>

</body>
</html>
21 changes: 21 additions & 0 deletions test_fixtures/grid_lanes/grid_lanes_align_items_center.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../../scripts/gentest/test_helper.js"></script>
<link rel="stylesheet" type="text/css" href="../../scripts/gentest/test_base_style.css">
<title>
Grid Lanes: align-items center within the gap below the last items in each track
</title>
</head>
<body>

<div id="test-root" style="display: grid-lanes; grid-template-columns: 40px 40px 40px; width: 120px; height: 100px; align-items: center;">
<div style="height: 30px;"></div>
<div style="height: 10px;"></div>
<div style="height: 20px;"></div>
<div style="height: 20px;"></div>
<div style="height: 10px;"></div>
</div>

</body>
</html>
21 changes: 21 additions & 0 deletions test_fixtures/grid_lanes/grid_lanes_align_items_end.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../../scripts/gentest/test_helper.js"></script>
<link rel="stylesheet" type="text/css" href="../../scripts/gentest/test_base_style.css">
<title>
Grid Lanes: align-items end moves items next to a gap to the end of the gap
</title>
</head>
<body>

<div id="test-root" style="display: grid-lanes; grid-template-columns: 40px 40px 40px; width: 120px; height: 100px; align-items: end;">
<div style="height: 30px;"></div>
<div style="height: 10px;"></div>
<div style="height: 20px;"></div>
<div style="height: 10px; grid-column: span 3;"></div>
<div style="height: 15px;"></div>
</div>

</body>
</html>
21 changes: 21 additions & 0 deletions test_fixtures/grid_lanes/grid_lanes_align_items_gap.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../../scripts/gentest/test_helper.js"></script>
<link rel="stylesheet" type="text/css" href="../../scripts/gentest/test_base_style.css">
<title>
Grid Lanes: the stacking-axis gutter is excluded from the alignment container
</title>
</head>
<body>

<div id="test-root" style="display: grid-lanes; grid-template-columns: 40px 40px 40px; width: 120px; height: 100px; row-gap: 6px; align-items: end;">
<div style="height: 30px;"></div>
<div style="height: 10px;"></div>
<div style="height: 20px;"></div>
<div style="height: 10px; grid-column: span 3;"></div>
<div style="height: 15px;"></div>
</div>

</body>
</html>
22 changes: 22 additions & 0 deletions test_fixtures/grid_lanes/grid_lanes_align_items_normal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../../scripts/gentest/test_helper.js"></script>
<link rel="stylesheet" type="text/css" href="../../scripts/gentest/test_base_style.css">
<title>
Grid Lanes: normal alignment stretches auto-height items into the adjacent gap
</title>
</head>
<body>

<div id="test-root" style="display: grid-lanes; grid-template-columns: 40px 40px 40px; width: 120px; height: 100px;">
<div style="height: 30px;"></div>
<div style="display: block; min-height: 10px;"></div>
<div style="height: 20px;"></div>
<div style="height: 10px; grid-column: span 3;"></div>
<div style="display: block; min-height: 10px;"></div>
<div style="height: 15px;"></div>
</div>

</body>
</html>
21 changes: 21 additions & 0 deletions test_fixtures/grid_lanes/grid_lanes_align_items_rtl.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../../scripts/gentest/test_helper.js"></script>
<link rel="stylesheet" type="text/css" href="../../scripts/gentest/test_base_style.css">
<title>
Grid Lanes: justify-items end in a row-direction rtl container
</title>
</head>
<body>

<div id="test-root" style="display: grid-lanes; grid-lanes-direction: row; grid-template-rows: 30px 30px 30px; height: 90px; width: 120px; direction: rtl; justify-items: end;">
<div style="width: 30px;"></div>
<div style="width: 10px;"></div>
<div style="width: 20px;"></div>
<div style="width: 10px; grid-row: span 3;"></div>
<div style="width: 15px;"></div>
</div>

</body>
</html>
22 changes: 22 additions & 0 deletions test_fixtures/grid_lanes/grid_lanes_align_items_stretch.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../../scripts/gentest/test_helper.js"></script>
<link rel="stylesheet" type="text/css" href="../../scripts/gentest/test_base_style.css">
<title>
Grid Lanes: align-items stretch grows auto-height items into the adjacent gap
</title>
</head>
<body>

<div id="test-root" style="display: grid-lanes; grid-template-columns: 40px 40px 40px; width: 120px; height: 100px; align-items: stretch;">
<div style="height: 30px;"></div>
<div style="display: block; min-height: 10px;"></div>
<div style="height: 20px;"></div>
<div style="height: 10px; grid-column: span 3;"></div>
<div style="display: block; min-height: 10px;"></div>
<div style="height: 15px;"></div>
</div>

</body>
</html>
21 changes: 21 additions & 0 deletions test_fixtures/grid_lanes/grid_lanes_align_self_mixed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../../scripts/gentest/test_helper.js"></script>
<link rel="stylesheet" type="text/css" href="../../scripts/gentest/test_base_style.css">
<title>
Grid Lanes: align-self overrides align-items per item in the stacking axis
</title>
</head>
<body>

<div id="test-root" style="display: grid-lanes; grid-template-columns: 40px 40px 40px; width: 120px; height: 100px; align-items: start;">
<div style="height: 30px;"></div>
<div style="height: 10px; align-self: end;"></div>
<div style="height: 20px; align-self: center;"></div>
<div style="height: 10px; grid-column: span 3;"></div>
<div style="height: 15px; align-self: end;"></div>
</div>

</body>
</html>
22 changes: 22 additions & 0 deletions test_fixtures/grid_lanes/grid_lanes_dense_align_items_end.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../../scripts/gentest/test_helper.js"></script>
<link rel="stylesheet" type="text/css" href="../../scripts/gentest/test_base_style.css">
<title>
Grid Lanes: dense-packed items take part in stacking-axis alignment
</title>
</head>
<body>

<div id="test-root" style="display: grid-lanes; grid-template-columns: 40px 40px 40px; width: 120px; height: 100px; grid-auto-flow: dense; grid-lanes-pack: dense; align-items: end;">
<div style="height: 30px;"></div>
<div style="height: 10px;"></div>
<div style="height: 20px;"></div>
<div style="height: 10px; grid-column: span 2;"></div>
<div style="height: 10px;"></div>
<div style="height: 15px;"></div>
</div>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../../scripts/gentest/test_helper.js"></script>
<link rel="stylesheet" type="text/css" href="../../scripts/gentest/test_base_style.css">
<title>
Grid Lanes: justify-content centers the stacking range in a row-direction container
</title>
</head>
<body>

<div id="test-root" style="display: grid-lanes; grid-lanes-direction: row; grid-template-rows: 30px 30px 30px; height: 90px; width: 120px; justify-content: center;">
<div style="width: 30px;"></div>
<div style="width: 20px;"></div>
<div style="width: 10px;"></div>
<div style="width: 20px;"></div>
</div>

</body>
</html>
21 changes: 21 additions & 0 deletions test_fixtures/grid_lanes/grid_lanes_justify_items_end_row.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../../scripts/gentest/test_helper.js"></script>
<link rel="stylesheet" type="text/css" href="../../scripts/gentest/test_base_style.css">
<title>
Grid Lanes: justify-items end in a row-direction container
</title>
</head>
<body>

<div id="test-root" style="display: grid-lanes; grid-lanes-direction: row; grid-template-rows: 30px 30px 30px; height: 90px; width: 120px; justify-items: end;">
<div style="width: 30px;"></div>
<div style="width: 10px;"></div>
<div style="width: 20px;"></div>
<div style="width: 10px; grid-row: span 3;"></div>
<div style="width: 15px;"></div>
</div>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<test name="grid_lanes_align_content_center__border_box_ltr" use-rounding="true">
<viewport width="max-content" height="max-content"/>
<input>
<div display="grid-lanes" direction="ltr" position="absolute" align-content="center" width="120px" height="100px" fit-tolerance="10px" grid-template-columns="40px 40px 40px">
<div direction="ltr" position="relative" height="30px"/>
<div direction="ltr" position="relative" height="20px"/>
<div direction="ltr" position="relative" height="10px"/>
<div direction="ltr" position="relative" height="20px"/>
</div>
</input>
<expectations>
<node x="0" y="0" width="120" height="100">
<node x="0" y="30" width="40" height="30"/>
<node x="40" y="30" width="40" height="20"/>
<node x="80" y="30" width="40" height="10"/>
<node x="40" y="50" width="40" height="20"/>
</node>
</expectations>
</test>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<test name="grid_lanes_align_content_center__border_box_rtl" use-rounding="true">
<viewport width="max-content" height="max-content"/>
<input>
<div display="grid-lanes" direction="rtl" position="absolute" align-content="center" width="120px" height="100px" fit-tolerance="10px" grid-template-columns="40px 40px 40px">
<div direction="rtl" position="relative" height="30px"/>
<div direction="rtl" position="relative" height="20px"/>
<div direction="rtl" position="relative" height="10px"/>
<div direction="rtl" position="relative" height="20px"/>
</div>
</input>
<expectations>
<node x="0" y="0" width="120" height="100">
<node x="80" y="30" width="40" height="30"/>
<node x="40" y="30" width="40" height="20"/>
<node x="0" y="30" width="40" height="10"/>
<node x="40" y="50" width="40" height="20"/>
</node>
</expectations>
</test>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<test name="grid_lanes_align_content_center__content_box_ltr" use-rounding="true">
<viewport width="max-content" height="max-content"/>
<input>
<div display="grid-lanes" box-sizing="content-box" direction="ltr" position="absolute" align-content="center" width="120px" height="100px" fit-tolerance="10px" grid-template-columns="40px 40px 40px">
<div box-sizing="content-box" direction="ltr" position="relative" height="30px"/>
<div box-sizing="content-box" direction="ltr" position="relative" height="20px"/>
<div box-sizing="content-box" direction="ltr" position="relative" height="10px"/>
<div box-sizing="content-box" direction="ltr" position="relative" height="20px"/>
</div>
</input>
<expectations>
<node x="0" y="0" width="120" height="100">
<node x="0" y="30" width="40" height="30"/>
<node x="40" y="30" width="40" height="20"/>
<node x="80" y="30" width="40" height="10"/>
<node x="40" y="50" width="40" height="20"/>
</node>
</expectations>
</test>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<test name="grid_lanes_align_content_center__content_box_rtl" use-rounding="true">
<viewport width="max-content" height="max-content"/>
<input>
<div display="grid-lanes" box-sizing="content-box" direction="rtl" position="absolute" align-content="center" width="120px" height="100px" fit-tolerance="10px" grid-template-columns="40px 40px 40px">
<div box-sizing="content-box" direction="rtl" position="relative" height="30px"/>
<div box-sizing="content-box" direction="rtl" position="relative" height="20px"/>
<div box-sizing="content-box" direction="rtl" position="relative" height="10px"/>
<div box-sizing="content-box" direction="rtl" position="relative" height="20px"/>
</div>
</input>
<expectations>
<node x="0" y="0" width="120" height="100">
<node x="80" y="30" width="40" height="30"/>
<node x="40" y="30" width="40" height="20"/>
<node x="0" y="30" width="40" height="10"/>
<node x="40" y="50" width="40" height="20"/>
</node>
</expectations>
</test>
Loading
Loading