From f69931552b8db1e9a098d0bd939c326dfee0a278 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 7 Apr 2016 10:47:31 -0700 Subject: [PATCH] =?UTF-8?q?layout:=20Disallow=20margins=20from=20collapsin?= =?UTF-8?q?g=20through=20block=20formatting=20contexts=20per=20CSS=202.1?= =?UTF-8?q?=20=C2=A7=208.3.1.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #10449. --- components/layout/block.rs | 2 +- .../html4/margin-collapse-009.htm.ini | 3 -- tests/wpt/mozilla/meta/MANIFEST.json | 24 ++++++++++++++ ..._formatting_context_margin_collapse_a.html | 28 +++++++++++++++++ ...ormatting_context_margin_collapse_ref.html | 31 +++++++++++++++++++ 5 files changed, 84 insertions(+), 4 deletions(-) delete mode 100644 tests/wpt/metadata-css/css21_dev/html4/margin-collapse-009.htm.ini create mode 100644 tests/wpt/mozilla/tests/css/block_formatting_context_margin_collapse_a.html create mode 100644 tests/wpt/mozilla/tests/css/block_formatting_context_margin_collapse_ref.html diff --git a/components/layout/block.rs b/components/layout/block.rs index 4f69a9487d8..fa91b847b20 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -1751,7 +1751,7 @@ impl Flow for BlockFlow { self.base.position.size.block = self.fragment.border_box.size.block; } None - } else if self.is_root() || self.base.flags.is_float() || self.is_inline_block() { + } else if self.is_root() || self.formatting_context_type() != FormattingContextType::None { // Root element margins should never be collapsed according to CSS ยง 8.3.1. debug!("assign_block_size: assigning block_size for root flow {:?}", flow::base(self).debug_id()); diff --git a/tests/wpt/metadata-css/css21_dev/html4/margin-collapse-009.htm.ini b/tests/wpt/metadata-css/css21_dev/html4/margin-collapse-009.htm.ini deleted file mode 100644 index 6627a225d8a..00000000000 --- a/tests/wpt/metadata-css/css21_dev/html4/margin-collapse-009.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[margin-collapse-009.htm] - type: reftest - expected: FAIL diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 69c05eaecdc..121842c43ff 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -579,6 +579,18 @@ "url": "/_mozilla/css/block_formatting_context_float_placement_a.html" } ], + "css/block_formatting_context_margin_collapse_a.html": [ + { + "path": "css/block_formatting_context_margin_collapse_a.html", + "references": [ + [ + "/_mozilla/css/block_formatting_context_margin_collapse_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/block_formatting_context_margin_collapse_a.html" + } + ], "css/block_formatting_context_max_width_a.html": [ { "path": "css/block_formatting_context_max_width_a.html", @@ -7193,6 +7205,18 @@ "url": "/_mozilla/css/block_formatting_context_float_placement_a.html" } ], + "css/block_formatting_context_margin_collapse_a.html": [ + { + "path": "css/block_formatting_context_margin_collapse_a.html", + "references": [ + [ + "/_mozilla/css/block_formatting_context_margin_collapse_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/block_formatting_context_margin_collapse_a.html" + } + ], "css/block_formatting_context_max_width_a.html": [ { "path": "css/block_formatting_context_max_width_a.html", diff --git a/tests/wpt/mozilla/tests/css/block_formatting_context_margin_collapse_a.html b/tests/wpt/mozilla/tests/css/block_formatting_context_margin_collapse_a.html new file mode 100644 index 00000000000..787505d08c2 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/block_formatting_context_margin_collapse_a.html @@ -0,0 +1,28 @@ + + + + + +
+ diff --git a/tests/wpt/mozilla/tests/css/block_formatting_context_margin_collapse_ref.html b/tests/wpt/mozilla/tests/css/block_formatting_context_margin_collapse_ref.html new file mode 100644 index 00000000000..3dfb8717acf --- /dev/null +++ b/tests/wpt/mozilla/tests/css/block_formatting_context_margin_collapse_ref.html @@ -0,0 +1,31 @@ + + + + +
+ +