From 21e2ed522bb75591e8ebb944c9bf0f06ebb619c6 Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 11 Nov 2017 19:21:51 +0000 Subject: [PATCH 1/5] fix block size for absolute replaced element Absolutely replaced elements with padding were incorrectly setting their block size to include twice the padding values. This attempts to stop that extra padding for replaced elements but leave the working flow for non replaced elements --- components/layout/block.rs | 7 +++- tests/wpt/mozilla/meta/MANIFEST.json | 41 +++++++++++++++++++ .../tests/css/absolute_div_with_padding.html | 24 +++++++++++ .../css/absolute_div_with_padding_ref.html | 20 +++++++++ .../tests/css/absolute_img_with_padding.html | 15 +++++++ .../css/absolute_img_with_padding_ref.html | 6 +++ 6 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 tests/wpt/mozilla/tests/css/absolute_div_with_padding.html create mode 100644 tests/wpt/mozilla/tests/css/absolute_div_with_padding_ref.html create mode 100644 tests/wpt/mozilla/tests/css/absolute_img_with_padding.html create mode 100644 tests/wpt/mozilla/tests/css/absolute_img_with_padding_ref.html diff --git a/components/layout/block.rs b/components/layout/block.rs index 57ebe2755021..6355ecea7ccb 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -1300,7 +1300,12 @@ impl BlockFlow { self.base.position.start.b = solution.block_start + self.fragment.margin.block_start } - let block_size = solution.block_size + self.fragment.border_padding.block_start_end(); + let block_size = if self.fragment.is_replaced() { + solution.block_size + } else { + (solution.block_size + self.fragment.border_padding.block_start_end()) + }; + self.fragment.border_box.size.block = block_size; self.base.position.size.block = block_size; diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 26c3042306c4..fa320f79cd26 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -73,6 +73,18 @@ {} ] ], + "css/absolute_div_with_padding.html": [ + [ + "/_mozilla/css/absolute_div_with_padding.html", + [ + [ + "/_mozilla/css/absolute_div_with_padding_ref.html", + "==" + ] + ], + {} + ] + ], "css/absolute_hypothetical_float.html": [ [ "/_mozilla/css/absolute_hypothetical_float.html", @@ -109,6 +121,18 @@ {} ] ], + "css/absolute_img_with_padding.html": [ + [ + "/_mozilla/css/absolute_img_with_padding.html", + [ + [ + "/_mozilla/css/absolute_img_with_padding_ref.html", + "==" + ] + ], + {} + ] + ], "css/absolute_inline_containing_block_a.html": [ [ "/_mozilla/css/absolute_inline_containing_block_a.html", @@ -7906,6 +7930,11 @@ {} ] ], + "css/absolute_img_with_padding_ref.html": [ + [ + {} + ] + ], "css/absolute_inline_containing_block_ref.html": [ [ {} @@ -60876,6 +60905,10 @@ "e38f77f3a7691b11abeece839aba62ce9246ff6a", "support" ], + "css/absolute_div_with_padding.html": [ + "6bfd1ae130e22c3083070a3574f827ded86f6724", + "reftest" + ], "css/absolute_hypothetical_float.html": [ "1abe08648b55df2390cb2b6561923aa576212fbf", "reftest" @@ -60900,6 +60933,14 @@ "400117a1d118ee05db150877aa81bb414f4e7200", "support" ], + "css/absolute_img_with_padding.html": [ + "15896a5c1c77109c26624248d3df213788eb186c", + "reftest" + ], + "css/absolute_img_with_padding_ref.html": [ + "3f949e99ab09c5f8ce352a7987330d99023d7f0d", + "support" + ], "css/absolute_inline_containing_block_a.html": [ "8174a236497815db250a3b11aeb322e0e9c7c74f", "reftest" diff --git a/tests/wpt/mozilla/tests/css/absolute_div_with_padding.html b/tests/wpt/mozilla/tests/css/absolute_div_with_padding.html new file mode 100644 index 000000000000..29c43bcdfced --- /dev/null +++ b/tests/wpt/mozilla/tests/css/absolute_div_with_padding.html @@ -0,0 +1,24 @@ + + + + + +
+
+
diff --git a/tests/wpt/mozilla/tests/css/absolute_div_with_padding_ref.html b/tests/wpt/mozilla/tests/css/absolute_div_with_padding_ref.html new file mode 100644 index 000000000000..98de730211ed --- /dev/null +++ b/tests/wpt/mozilla/tests/css/absolute_div_with_padding_ref.html @@ -0,0 +1,20 @@ + + + + +
+
+
diff --git a/tests/wpt/mozilla/tests/css/absolute_img_with_padding.html b/tests/wpt/mozilla/tests/css/absolute_img_with_padding.html new file mode 100644 index 000000000000..fb93f0613719 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/absolute_img_with_padding.html @@ -0,0 +1,15 @@ + + +CSS Test: Absolute position image with padding should not increase in size + + + + img + diff --git a/tests/wpt/mozilla/tests/css/absolute_img_with_padding_ref.html b/tests/wpt/mozilla/tests/css/absolute_img_with_padding_ref.html new file mode 100644 index 000000000000..ec668a3b9405 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/absolute_img_with_padding_ref.html @@ -0,0 +1,6 @@ + + +CSS Test: Absolute position image with padding should not increase in size + + img + From e926bef7963bf9bd41c970c07d0f28e0380e0a56 Mon Sep 17 00:00:00 2001 From: Bob Date: Mon, 20 Nov 2017 15:57:45 +0000 Subject: [PATCH 2/5] add title to absolute div test case --- tests/wpt/mozilla/tests/css/absolute_div_with_padding.html | 2 +- tests/wpt/mozilla/tests/css/absolute_div_with_padding_ref.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/wpt/mozilla/tests/css/absolute_div_with_padding.html b/tests/wpt/mozilla/tests/css/absolute_div_with_padding.html index 29c43bcdfced..cddbbba8def0 100644 --- a/tests/wpt/mozilla/tests/css/absolute_div_with_padding.html +++ b/tests/wpt/mozilla/tests/css/absolute_div_with_padding.html @@ -1,6 +1,6 @@ - +CSS Test: Absolute position div with padding should not increase in size