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.
This commit is contained in:
Andreas Kling 2022-02-27 13:13:54 +01:00
parent 19954dfdf8
commit 4b6295e667
Notes: sideshowbarker 2024-07-17 18:07:29 +09:00

View File

@ -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;