From 4b6295e66729001b48bbbd74f857d268d8414c69 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 27 Feb 2022 13:13:54 +0100 Subject: [PATCH] LibWeb: For height:auto blocks, measure from top of *top* line box We were incorrectly checking for negative top edges in the *last* line box only. --- Userland/Libraries/LibWeb/Layout/FormattingContext.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp index e441fd354c..b3a731d9d2 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -218,10 +218,14 @@ float FormattingContext::compute_auto_height_for_block_level_element(FormattingS auto const& line_boxes = state.get(block_container).line_boxes; top = 0; if (!line_boxes.is_empty()) { - for (auto& fragment : line_boxes.last().fragments()) { + // Find the top edge (if negative). + for (auto const& fragment : line_boxes.first().fragments()) { float fragment_top = fragment.offset().y() - fragment.border_box_top(); if (!top.has_value() || fragment_top < *top) top = fragment_top; + } + // Find the bottom edge. + for (auto const& fragment : line_boxes.last().fragments()) { float fragment_bottom = fragment.offset().y() + fragment.height() + fragment.border_box_bottom(); if (!bottom.has_value() || fragment_bottom > *bottom) bottom = fragment_bottom;