diff --git a/Libraries/LibWeb/Layout/FormattingContext.cpp b/Libraries/LibWeb/Layout/FormattingContext.cpp index 66ba7c450dc..c678bf09b71 100644 --- a/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -1245,6 +1245,15 @@ void FormattingContext::layout_absolutely_positioned_element(Box const& box, Ava box_state.set_has_definite_height(true); } + // NOTE: BFC is special, as their abspos auto height depends on performing inside layout. + // For other formatting contexts, the height we've resolved early is good. + // See FormattingContext::compute_auto_height_for_absolutely_positioned_element() + // for the special-casing of BFC roots. + if (!creates_block_formatting_context(box)) { + box_state.set_has_definite_width(true); + box_state.set_has_definite_height(true); + } + auto independent_formatting_context = layout_inside(box, LayoutMode::Normal, box_state.available_inner_space_or_constraints_from(available_space)); compute_height_for_absolutely_positioned_element(box, available_space, BeforeOrAfterInsideLayout::After); diff --git a/Tests/LibWeb/Layout/expected/abspos-non-bfc-root-with-min-height-constraint.txt b/Tests/LibWeb/Layout/expected/abspos-non-bfc-root-with-min-height-constraint.txt new file mode 100644 index 00000000000..8c8e57c4e22 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/abspos-non-bfc-root-with-min-height-constraint.txt @@ -0,0 +1,13 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x0 [BFC] children: not-inline + Box
at (8,8) content-size 31.15625x300 positioned flex-container(row) [FFC] children: not-inline + BlockContainer