mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +00:00
LibWeb: Account for float's container offsets in BFC root auto height
When calculating the automatic height of a BFC root, we stretch it to contain the bottommost margin edge of floating boxes. Before this change, we assumed that floating boxes had coordinates relative to the BFC root, when they're actually relative to the floating box's containing block. This may or may not be the BFC root, so we have to use margin_box_in_ancestor_coordinate_space() to apply offsets from all boxes in the containing block chain (up to the BFC root).
This commit is contained in:
parent
8ff7c52cf4
commit
34025442ff
1 changed files with 6 additions and 5 deletions
|
@ -345,11 +345,12 @@ float FormattingContext::compute_auto_height_for_block_formatting_context_root(L
|
|||
// whose bottom margin edge is below the element's bottom content edge,
|
||||
// then the height is increased to include those edges.
|
||||
for (auto* floating_box : state.get(root).floating_descendants()) {
|
||||
auto const& floating_box_state = state.get(*floating_box);
|
||||
float floating_box_bottom = floating_box_state.offset.y() + floating_box_state.content_height() + floating_box_state.margin_box_bottom();
|
||||
|
||||
if (!bottom.has_value() || floating_box_bottom > bottom.value())
|
||||
bottom = floating_box_bottom;
|
||||
// NOTE: Floating box coordinates are relative to their own containing block,
|
||||
// which may or may not be the BFC root.
|
||||
auto margin_box = margin_box_rect_in_ancestor_coordinate_space(*floating_box, root, state);
|
||||
float floating_box_bottom_margin_edge = margin_box.bottom() + 1;
|
||||
if (!bottom.has_value() || floating_box_bottom_margin_edge > bottom.value())
|
||||
bottom = floating_box_bottom_margin_edge;
|
||||
}
|
||||
|
||||
return max(0.0f, bottom.value_or(0) - top.value_or(0));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue