Element collapsing thru should collapse with its children (#32060)

If the top and bottom margins of an element collapse through, then this
patch treats the bottom margin as collapsing with its children, even if
`height` doesn't compute to zero.

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Oriol Brufau 2024-04-12 17:06:12 +02:00 committed by GitHub
parent 95654b789c
commit bc7cced03c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 62 additions and 9 deletions

View file

@ -641,9 +641,6 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
let computed_block_size = style.content_block_size();
let start_margin_can_collapse_with_children =
pbm.padding.block_start == Au::zero() && pbm.border.block_start == Au::zero();
let end_margin_can_collapse_with_children = pbm.padding.block_end == Au::zero() &&
pbm.border.block_end == Au::zero() &&
computed_block_size.is_auto();
let mut clearance = None;
let parent_containing_block_position_info;
@ -745,6 +742,17 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
));
}
}
let collapsed_through = collapsible_margins_in_children.collapsed_through &&
pbm.padding_border_sums.block == Au::zero() &&
block_size_is_zero_or_auto(computed_block_size, containing_block) &&
block_size_is_zero_or_auto(style.min_block_size(), containing_block);
block_margins_collapsed_with_children.collapsed_through = collapsed_through;
let end_margin_can_collapse_with_children = collapsed_through ||
(pbm.padding.block_end == Au::zero() &&
pbm.border.block_end == Au::zero() &&
computed_block_size.is_auto());
if end_margin_can_collapse_with_children {
block_margins_collapsed_with_children
.end
@ -753,12 +761,6 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
content_block_size += collapsible_margins_in_children.end.solve().into();
}
block_margins_collapsed_with_children.collapsed_through = collapsible_margins_in_children
.collapsed_through &&
pbm.padding_border_sums.block == Au::zero() &&
block_size_is_zero_or_auto(computed_block_size, containing_block) &&
block_size_is_zero_or_auto(style.min_block_size(), containing_block);
let block_size = containing_block_for_children.block_size.auto_is(|| {
content_block_size
.clamp_between_extremums(min_box_size.block, max_box_size.block)