diff --git a/Libraries/LibWeb/Layout/GridFormattingContext.cpp b/Libraries/LibWeb/Layout/GridFormattingContext.cpp index 4899f56807b..78bd751b129 100644 --- a/Libraries/LibWeb/Layout/GridFormattingContext.cpp +++ b/Libraries/LibWeb/Layout/GridFormattingContext.cpp @@ -2120,7 +2120,7 @@ void GridFormattingContext::layout_absolutely_positioned_element(Box const& box) // `Node::containing_block()` is not aware of that. Therefore, we need to // find the closest grid item ancestor in order to identify grid area it belongs to. NodeWithStyle const* containing_grid_item = &box; - while (containing_grid_item->parent() && !containing_grid_item->parent()->display().is_grid_inside()) + while (containing_grid_item->parent() && containing_grid_item->parent() != &grid_container()) containing_grid_item = containing_grid_item->parent(); auto const& computed_values = containing_grid_item->computed_values(); diff --git a/Tests/LibWeb/Layout/expected/grid/gfc-between-relpos-gfc-and-abspos-item.txt b/Tests/LibWeb/Layout/expected/grid/gfc-between-relpos-gfc-and-abspos-item.txt new file mode 100644 index 00000000000..4c516da78c3 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/grid/gfc-between-relpos-gfc-and-abspos-item.txt @@ -0,0 +1,18 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x16 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x0 children: not-inline + Box at (8,8) content-size 784x0 positioned [GFC] children: not-inline + Box at (8,8) content-size 784x0 [GFC] children: not-inline + BlockContainer
at (8,8) content-size 784x0 [BFC] children: not-inline + BlockContainer at (8,8) content-size 0x0 positioned [BFC] children: not-inline + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x16] + PaintableWithLines (BlockContainer) [8,8 784x0] + PaintableBox (Box
.outer) [8,8 784x0] + PaintableBox (Box
.middle) [8,8 784x0] + PaintableWithLines (BlockContainer
) [8,8 784x0] + PaintableWithLines (BlockContainer
.abs) [8,8 0x0] + +SC for Viewport<#document> [0,0 800x600] [children: 1] (z-index: auto) + SC for BlockContainer [0,0 800x16] [children: 0] (z-index: auto) diff --git a/Tests/LibWeb/Layout/input/grid/gfc-between-relpos-gfc-and-abspos-item.html b/Tests/LibWeb/Layout/input/grid/gfc-between-relpos-gfc-and-abspos-item.html new file mode 100644 index 00000000000..327b92807c5 --- /dev/null +++ b/Tests/LibWeb/Layout/input/grid/gfc-between-relpos-gfc-and-abspos-item.html @@ -0,0 +1,5 @@ +
\ No newline at end of file