From 2495302991e113c8c2880ef9387d6259e2105ab5 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Tue, 29 Aug 2023 11:49:08 +0200 Subject: [PATCH] LibWeb: Reset auto_placement_cursor_x after adding new column in GFC We need to start looking from the beginning of current row if adding new implicit column track made enough space to accomodate spanning item This fixes placement for spanning grid items when `grid-auto-flow` is specified to `column`. --- .../grid/auto-flow-column-spanning-item.txt | 16 ++++++++++++++++ .../grid/auto-flow-column-spanning-item.html | 9 +++++++++ .../LibWeb/Layout/GridFormattingContext.cpp | 1 + 3 files changed, 26 insertions(+) create mode 100644 Tests/LibWeb/Layout/expected/grid/auto-flow-column-spanning-item.txt create mode 100644 Tests/LibWeb/Layout/input/grid/auto-flow-column-spanning-item.html diff --git a/Tests/LibWeb/Layout/expected/grid/auto-flow-column-spanning-item.txt b/Tests/LibWeb/Layout/expected/grid/auto-flow-column-spanning-item.txt new file mode 100644 index 0000000000..2012138754 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/grid/auto-flow-column-spanning-item.txt @@ -0,0 +1,16 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x33.46875 [BFC] children: not-inline + Box at (8,8) content-size 784x17.46875 [GFC] children: not-inline + BlockContainer
at (8,8) content-size 156.796875x17.46875 [BFC] children: not-inline + BlockContainer at (164.796875,8) content-size 627.1875x17.46875 [BFC] children: inline + line 0 width: 27.15625, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 3, rect: [164.796875,8 27.15625x17.46875] + "foo" + TextNode <#text> + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x33.46875] + PaintableBox (Box) [8,8 784x17.46875] + PaintableWithLines (BlockContainer
) [8,8 156.796875x17.46875] + PaintableWithLines (BlockContainer
.item) [164.796875,8 627.1875x17.46875] + TextPaintable (TextNode<#text>) diff --git a/Tests/LibWeb/Layout/input/grid/auto-flow-column-spanning-item.html b/Tests/LibWeb/Layout/input/grid/auto-flow-column-spanning-item.html new file mode 100644 index 0000000000..532f244d12 --- /dev/null +++ b/Tests/LibWeb/Layout/input/grid/auto-flow-column-spanning-item.html @@ -0,0 +1,9 @@ +
foo
\ No newline at end of file diff --git a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp index f5ee83544d..754be9ed64 100644 --- a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp @@ -606,6 +606,7 @@ void GridFormattingContext::place_item_with_no_declared_position(Box const& chil auto_placement_cursor_y++; } else { m_occupation_grid.set_max_column_index(auto_placement_cursor_x); + auto_placement_cursor_x = 0; auto_placement_cursor_y = m_occupation_grid.min_row_index(); } }