mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Improve margin collapse in layout-2020
According to https://drafts.csswg.org/css2/#collapsing-margins, bottom margins should only collapse with the last child if `height` is `auto`. Also, the note mentions `min-height: 0`, but the normative text doesn't have such requirement, so I'm dropping it, matching WebKit. The previous logic is moved into the case of collapsing the top and bottom margins of the same element, since this can happen either with `height: auto` or `height: 0`, and requires `min-height: 0`.
This commit is contained in:
parent
1bd1441d0b
commit
5e1f059de2
3 changed files with 6 additions and 9 deletions
|
@ -483,8 +483,7 @@ fn layout_in_flow_non_replaced_block_level(
|
|||
let end_margin_can_collapse_with_children = block_is_same_formatting_context &&
|
||||
pbm.padding.block_end == Length::zero() &&
|
||||
pbm.border.block_end == Length::zero() &&
|
||||
block_size.auto_is(|| Length::zero()) == Length::zero() &&
|
||||
min_box_size.block == Length::zero();
|
||||
block_size == LengthOrAuto::Auto;
|
||||
|
||||
let mut clearance = Length::zero();
|
||||
let parent_containing_block_position_info;
|
||||
|
@ -570,9 +569,11 @@ fn layout_in_flow_non_replaced_block_level(
|
|||
content_block_size += collapsible_margins_in_children.end.solve();
|
||||
}
|
||||
block_margins_collapsed_with_children.collapsed_through =
|
||||
start_margin_can_collapse_with_children &&
|
||||
end_margin_can_collapse_with_children &&
|
||||
collapsible_margins_in_children.collapsed_through;
|
||||
collapsible_margins_in_children.collapsed_through &&
|
||||
block_is_same_formatting_context &&
|
||||
pbm.padding_border_sums.block == Length::zero() &&
|
||||
block_size.auto_is(|| Length::zero()) == Length::zero() &&
|
||||
min_box_size.block == Length::zero();
|
||||
},
|
||||
NonReplacedContents::EstablishesAnIndependentFormattingContext(non_replaced) => {
|
||||
let independent_layout = non_replaced.layout(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue