aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <infra@servo.org>2023-06-09 00:20:05 +0200
committerGitHub <noreply@github.com>2023-06-09 00:20:05 +0200
commitcb0c0bf3ce2816526c8009cd70a2f09e64042a72 (patch)
treeca7b95e21c34e2f41d81d2e21f110720677c4531
parent0a70b276259a749de45c9fb655a281e98a2ffeab (diff)
parent5e1f059de245eaa7399bd6d5207b79c3834ecdf3 (diff)
downloadservo-cb0c0bf3ce2816526c8009cd70a2f09e64042a72.tar.gz
servo-cb0c0bf3ce2816526c8009cd70a2f09e64042a72.zip
Auto merge of #29856 - Loirooriol:improve-margin-collapse, r=mrobinson
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`. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #29858 - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
-rw-r--r--components/layout_2020/flow/mod.rs11
-rw-r--r--tests/wpt/metadata-layout-2020/css/CSS2/margin-padding-clear/margin-collapse-025.xht.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/CSS2/margin-padding-clear/margin-collapse-037.xht.ini2
3 files changed, 6 insertions, 9 deletions
diff --git a/components/layout_2020/flow/mod.rs b/components/layout_2020/flow/mod.rs
index fcd2c2b1837..e23c8db33e8 100644
--- a/components/layout_2020/flow/mod.rs
+++ b/components/layout_2020/flow/mod.rs
@@ -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(
diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/margin-padding-clear/margin-collapse-025.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/margin-padding-clear/margin-collapse-025.xht.ini
deleted file mode 100644
index 41403961633..00000000000
--- a/tests/wpt/metadata-layout-2020/css/CSS2/margin-padding-clear/margin-collapse-025.xht.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[margin-collapse-025.xht]
- expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/margin-padding-clear/margin-collapse-037.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/margin-padding-clear/margin-collapse-037.xht.ini
deleted file mode 100644
index 049aa133c56..00000000000
--- a/tests/wpt/metadata-layout-2020/css/CSS2/margin-padding-clear/margin-collapse-037.xht.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[margin-collapse-037.xht]
- expected: FAIL