aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorOriol Brufau <obrufau@igalia.com>2024-04-12 17:06:12 +0200
committerGitHub <noreply@github.com>2024-04-12 15:06:12 +0000
commitbc7cced03c982cc32c941fec40e66fb5814470cb (patch)
tree8a11c58a112ff9cb0ed2087c2863b5196d8f3209 /components
parent95654b789cce4acb1bb7b755053c4ae6b1cdc07e (diff)
downloadservo-bc7cced03c982cc32c941fec40e66fb5814470cb.tar.gz
servo-bc7cced03c982cc32c941fec40e66fb5814470cb.zip
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>
Diffstat (limited to 'components')
-rw-r--r--components/layout_2020/flow/mod.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/components/layout_2020/flow/mod.rs b/components/layout_2020/flow/mod.rs
index fe14cd4bb37..fd0fc6bc745 100644
--- a/components/layout_2020/flow/mod.rs
+++ b/components/layout_2020/flow/mod.rs
@@ -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)