diff --git a/Libraries/LibWeb/Layout/GridFormattingContext.cpp b/Libraries/LibWeb/Layout/GridFormattingContext.cpp index 1343fd7543c..f468f0b9c42 100644 --- a/Libraries/LibWeb/Layout/GridFormattingContext.cpp +++ b/Libraries/LibWeb/Layout/GridFormattingContext.cpp @@ -351,6 +351,14 @@ GridFormattingContext::PlacementPosition GridFormattingContext::resolve_grid_pos } } + if (!placement_start.is_positioned() && placement_end.is_positioned() && !placement_end.is_span()) { + if (result.span == 0) + result.span = 1; + result.start = result.end - result.span; + if (result.start < 0) + result.start = 0; + } + if (placement_start.is_positioned() && placement_end.is_positioned()) { if (result.start > result.end) swap(result.start, result.end); diff --git a/Tests/LibWeb/Layout/expected/grid/placement-auto-negative.txt b/Tests/LibWeb/Layout/expected/grid/placement-auto-negative.txt new file mode 100644 index 00000000000..2e3ed4e825a --- /dev/null +++ b/Tests/LibWeb/Layout/expected/grid/placement-auto-negative.txt @@ -0,0 +1,22 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x64 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x48 children: not-inline + Box at (8,8) content-size 784x48 [GFC] children: not-inline + BlockContainer <(anonymous)> (not painted) [BFC] children: inline + TextNode <#text> + BlockContainer at (8,8) content-size 48x48 [BFC] children: not-inline + BlockContainer <(anonymous)> (not painted) [BFC] children: inline + TextNode <#text> + BlockContainer at (56,8) content-size 48x48 [BFC] children: not-inline + BlockContainer <(anonymous)> (not painted) [BFC] children: inline + TextNode <#text> + BlockContainer <(anonymous)> at (8,56) content-size 784x0 children: inline + TextNode <#text> + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x64] + PaintableWithLines (BlockContainer) [8,8 784x48] + PaintableBox (Box
.a) [8,8 784x48] + PaintableWithLines (BlockContainer
.b) [8,8 48x48] + PaintableWithLines (BlockContainer
.c) [56,8 48x48] + PaintableWithLines (BlockContainer(anonymous)) [8,56 784x0] diff --git a/Tests/LibWeb/Layout/input/grid/placement-auto-negative.html b/Tests/LibWeb/Layout/input/grid/placement-auto-negative.html new file mode 100644 index 00000000000..cd9d25a2449 --- /dev/null +++ b/Tests/LibWeb/Layout/input/grid/placement-auto-negative.html @@ -0,0 +1,24 @@ + + +
+
+
+