diff --git a/Libraries/LibWeb/Layout/FormattingContext.cpp b/Libraries/LibWeb/Layout/FormattingContext.cpp index 6acb33d1c6f..9e7df9fdbf7 100644 --- a/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -1170,9 +1170,9 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el box_state.set_content_height(used_height.to_px(box)); // do not set calculated insets or margins on the first pass, there will be a second pass - if (before_or_after_inside_layout == BeforeOrAfterInsideLayout::Before) + if (box.computed_values().height().is_auto() && before_or_after_inside_layout == BeforeOrAfterInsideLayout::Before) return; - + box_state.set_has_definite_height(true); box_state.inset_top = top.to_px(box, height_of_containing_block); box_state.inset_bottom = bottom.to_px(box, height_of_containing_block); box_state.margin_top = margin_top.to_px(box, width_of_containing_block); @@ -1255,7 +1255,9 @@ void FormattingContext::layout_absolutely_positioned_element(Box const& box, Ava 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); + if (box.computed_values().height().is_auto()) { + compute_height_for_absolutely_positioned_element(box, available_space, BeforeOrAfterInsideLayout::After); + } CSSPixelPoint used_offset; @@ -1350,8 +1352,9 @@ void FormattingContext::compute_height_for_absolutely_positioned_replaced_elemen box_state.set_content_height(height); // do not set calculated insets or margins on the first pass, there will be a second pass - if (before_or_after_inside_layout == BeforeOrAfterInsideLayout::Before) + if (box.computed_values().height().is_auto() && before_or_after_inside_layout == BeforeOrAfterInsideLayout::Before) return; + box_state.set_has_definite_height(true); box_state.inset_top = to_px(top); box_state.inset_bottom = to_px(bottom); box_state.margin_top = to_px(margin_top); diff --git a/Tests/LibWeb/Layout/expected/block-and-inline/percentage-height-abspos-box-with-percentage-height-child.txt b/Tests/LibWeb/Layout/expected/block-and-inline/percentage-height-abspos-box-with-percentage-height-child.txt new file mode 100644 index 00000000000..f3839de3425 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/block-and-inline/percentage-height-abspos-box-with-percentage-height-child.txt @@ -0,0 +1,13 @@ +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 positioned children: not-inline + BlockContainer
at (8,8) content-size 120x0 positioned [BFC] children: not-inline + BlockContainer at (18,18) content-size 100x0 children: not-inline + BlockContainer at (18,18) content-size 100x30 children: not-inline + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x16] + PaintableWithLines (BlockContainer) [8,8 784x0] + PaintableWithLines (BlockContainer
) [8,8 120x0] overflow: [8,8 120x40] + PaintableWithLines (BlockContainer
#asset-grid) [8,8 120x20] overflow: [18,18 100x30] + PaintableWithLines (BlockContainer
#virtual-timeline) [18,18 100x30] diff --git a/Tests/LibWeb/Layout/input/block-and-inline/percentage-height-abspos-box-with-percentage-height-child.html b/Tests/LibWeb/Layout/input/block-and-inline/percentage-height-abspos-box-with-percentage-height-child.html new file mode 100644 index 00000000000..2205c6d8ba9 --- /dev/null +++ b/Tests/LibWeb/Layout/input/block-and-inline/percentage-height-abspos-box-with-percentage-height-child.html @@ -0,0 +1,18 @@ +
\ No newline at end of file