Increase BFC root height to contain floats

This commit is contained in:
Oriol Brufau 2023-06-25 22:56:57 +02:00
parent 9829931c27
commit e38083a96e
11 changed files with 9 additions and 22 deletions

View file

@ -96,10 +96,18 @@ impl BlockFormattingContext {
.collapsed_through
);
// The content height of a BFC root should include any float participating in that BFC
// (https://drafts.csswg.org/css2/#root-height), we implement this by imagining there is
// an element with `clear: both` after the actual contents.
let clearance = sequential_layout_state.map_or(Length::zero(), |sequential_layout_state| {
sequential_layout_state.calculate_clearance(ClearSide::Both)
});
IndependentLayout {
fragments: flow_layout.fragments,
content_block_size: flow_layout.content_block_size +
flow_layout.collapsible_margins_in_children.end.solve(),
flow_layout.collapsible_margins_in_children.end.solve() +
clearance,
}
}
}