From 03990fcb89da3def0d39b584f617fce4a6108c7d Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Fri, 26 Mar 2021 16:49:46 -0400 Subject: [PATCH] LibWeb: Consider floating children when computing auto-height The case for computing auto-height of block elements which have block- level children was erroneously skipping some children: 1. If the block element itself is absolute or floating, all children were skipped due to a likely typo ("box" vs. "child_box" inside the for-each loop). 2. Floating children should only be skipped if the block element's 'overflow' property computes to 'visible', per section 10.6.3 of the CSS height property spec. If the property computes to another value, section 10.6.7 only indicates that absolutely positioned children should be skipped. --- Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index cffd2a20e67..0a5918b2e79 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -290,7 +290,9 @@ float BlockFormattingContext::compute_auto_height_for_block_level_element(const // the top margin-edge of the topmost block-level child box // and the bottom margin-edge of the bottommost block-level child box. box.for_each_child_of_type([&](Layout::Box& child_box) { - if (box.is_absolutely_positioned() || box.is_floating()) + if (child_box.is_absolutely_positioned()) + return IterationDecision::Continue; + if ((box.computed_values().overflow_y() == CSS::Overflow::Visible) && child_box.is_floating()) return IterationDecision::Continue; float child_box_top = child_box.effective_offset().y() - child_box.box_model().margin_box().top;