1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 21:28:14 +00:00

LibWeb: Store bottom edge location with each LineBox

Previously we were computing the bottom edge of a line box by finding
the bottommost fragment on the line.

That method didn't give correct results for line boxes with no fragments
(which is exactly what you get when inserting a bunch of <br> elements.)

To cover all situations, we now keep track of the bottommost edge in the
LineBox object itself.
This commit is contained in:
Andreas Kling 2022-02-27 13:34:34 +01:00
parent 4b6295e667
commit c6cf240f9a
4 changed files with 11 additions and 8 deletions

View file

@ -225,11 +225,7 @@ float FormattingContext::compute_auto_height_for_block_level_element(FormattingS
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;
}
bottom = line_boxes.last().bottom();
}
} else {
// If it has block-level children, the height is the distance between