1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:47:35 +00:00

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

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; auto const& line_boxes = state.get(block_container).line_boxes;
top = 0; top = 0;
if (!line_boxes.is_empty()) { 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(); float fragment_top = fragment.offset().y() - fragment.border_box_top();
if (!top.has_value() || fragment_top < *top) if (!top.has_value() || fragment_top < *top)
top = fragment_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(); float fragment_bottom = fragment.offset().y() + fragment.height() + fragment.border_box_bottom();
if (!bottom.has_value() || fragment_bottom > *bottom) if (!bottom.has_value() || fragment_bottom > *bottom)
bottom = fragment_bottom; bottom = fragment_bottom;