diff --git a/Tests/LibWeb/Layout/expected/grid/abspos-item-with-grid-area-aligned-in-center.txt b/Tests/LibWeb/Layout/expected/grid/abspos-item-with-grid-area-aligned-in-center.txt new file mode 100644 index 00000000000..b3343224989 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/grid/abspos-item-with-grid-area-aligned-in-center.txt @@ -0,0 +1,11 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (1,1) content-size 798x220 [BFC] children: not-inline + BlockContainer at (10,10) content-size 780x202 children: not-inline + Box at (11,11) content-size 200x200 positioned [GFC] children: not-inline + BlockContainer at (137,37) content-size 48x48 positioned [BFC] children: not-inline + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x222] + PaintableWithLines (BlockContainer) [9,9 782x204] + PaintableBox (Box
.grid) [10,10 202x202] + PaintableWithLines (BlockContainer
.abspos-item) [136,36 50x50] diff --git a/Tests/LibWeb/Layout/input/grid/abspos-item-with-grid-area-aligned-in-center.html b/Tests/LibWeb/Layout/input/grid/abspos-item-with-grid-area-aligned-in-center.html new file mode 100644 index 00000000000..5208fd84e6e --- /dev/null +++ b/Tests/LibWeb/Layout/input/grid/abspos-item-with-grid-area-aligned-in-center.html @@ -0,0 +1,26 @@ +
\ No newline at end of file diff --git a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp index 8e357a2ee91..500df930d43 100644 --- a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp @@ -1936,8 +1936,7 @@ void GridFormattingContext::layout_absolutely_positioned_element(Box const& box) compute_height_for_absolutely_positioned_element(box, available_space, BeforeOrAfterInsideLayout::After); if (computed_values.inset().left().is_auto() && computed_values.inset().right().is_auto()) { - auto containing_block_width = containing_block_state.content_width(); - auto width_left_for_alignment = containing_block_width - box_state.margin_box_width(); + auto width_left_for_alignment = grid_area_rect.width() - box_state.margin_box_width(); switch (justification_for_item(box)) { case CSS::JustifyItems::Normal: case CSS::JustifyItems::Stretch: @@ -1962,8 +1961,7 @@ void GridFormattingContext::layout_absolutely_positioned_element(Box const& box) } if (computed_values.inset().top().is_auto() && computed_values.inset().bottom().is_auto()) { - auto containing_block_height = containing_block_state.content_height(); - auto height_left_for_alignment = containing_block_height - box_state.margin_box_height(); + auto height_left_for_alignment = grid_area_rect.height() - box_state.margin_box_height(); switch (alignment_for_item(box)) { case CSS::AlignItems::Baseline: // FIXME: Not implemented