From 84290ed7c8f1f8d2695e6aa7d5f1aa3587e86412 Mon Sep 17 00:00:00 2001 From: martinfalisse Date: Mon, 26 Sep 2022 14:04:05 +0200 Subject: [PATCH] Base+LibWeb: Make sure grid positions don't cause out of bounds Add some tests to the test page to make sure that different combinations of GridTrackPlacement don't cause out of bounds issues. --- Base/res/html/misc/display-grid.html | 13 ++++++++----- .../LibWeb/Layout/GridFormattingContext.cpp | 6 ++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Base/res/html/misc/display-grid.html b/Base/res/html/misc/display-grid.html index eb7a33af17..fcf9c9d116 100644 --- a/Base/res/html/misc/display-grid.html +++ b/Base/res/html/misc/display-grid.html @@ -46,15 +46,18 @@
1
2
3
+
6
- +

If you can see this message then the test passed.

-
1
-
2
-
3
-
4
+
2
+
3
+
4
+
5
+
1
+
6
diff --git a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp index 7b607cd0fd..f41e0ecf5c 100644 --- a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp @@ -251,6 +251,9 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const if (row_start != row_end) row_span = row_end - row_start; } + // FIXME: Have yet to find the spec for this. + if (!child_box.computed_values().grid_row_start().is_position() && child_box.computed_values().grid_row_end().is_position() && row_end == 1) + row_start = 1; // If the placement contains two spans, remove the one contributed by the end grid-placement // property. @@ -361,6 +364,9 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const if (column_start < 0) column_start = 1; } + // FIXME: Have yet to find the spec for this. + if (!child_box.computed_values().grid_column_start().is_position() && child_box.computed_values().grid_column_end().is_position() && column_end == 1) + column_start = 1; // If a name is given as a , only lines with that name are counted. If not enough // lines with that name exist, all implicit grid lines on the side of the explicit grid