From e67f5c75855ba109156811a50a0f7da96f74dea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 24 Feb 2017 21:28:56 +0100 Subject: [PATCH 1/2] style: Adjust float if the element is positioned per CSS 2.1 section 9.7 We've found crashes related to this in Gecko. --- .../style/properties/properties.mako.rs | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index c3b60b7df0e..81ae2e74fb5 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1953,10 +1953,14 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D, % endif computed_values::display::T::flex | computed_values::display::T::inline_flex); - let (blockify_root, blockify_item) = match flags.contains(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP) { - false => (is_root_element, is_item), - true => (false, false), - }; + + let (blockify_root, blockify_item) = + if flags.contains(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP) { + (false, false) + } else { + (is_root_element, is_item) + }; + if positioned || floated || blockify_root || blockify_item { use computed_values::display::T; @@ -2013,6 +2017,15 @@ pub fn apply_declarations<'a, F, I>(viewport_size: Size2D, } } + // CSS 2.1 section 9.7: + // + // If 'position' has the value 'absolute' or 'fixed', [...] the computed + // value of 'float' is 'none'. + // + if positioned && floated { + style.mutate_box().set_float(longhands::float::computed_value::T::none); + } + // This implements an out-of-date spec. The new spec moves the handling of // this to layout, which Gecko implements but Servo doesn't. // From 19e4f72685831254ce7657f2f93bc0ca1b0d8d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 25 Feb 2017 20:18:11 +0100 Subject: [PATCH 2/2] Tests for float computing to none when an element is absolutely positioned. --- tests/wpt/mozilla/meta/MANIFEST.json | 10 ++++++++++ tests/wpt/mozilla/tests/css/float-abspos.html | 20 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/wpt/mozilla/tests/css/float-abspos.html diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 434afa7e5a2..9ecaa48d559 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -11036,6 +11036,12 @@ {} ] ], + "css/float-abspos.html": [ + [ + "/_mozilla/css/float-abspos.html", + {} + ] + ], "css/float_relative_to_position.html": [ [ "/_mozilla/css/float_relative_to_position.html", @@ -20895,6 +20901,10 @@ "2712a0a76b5eeb4d0f2b4a45277d04791a8ff206", "support" ], + "css/float-abspos.html": [ + "d34a9ce0be290bc3c46aa80eb136a91460957346", + "testharness" + ], "css/float_clearance_a.html": [ "372652bf4c345098f864cfc52ad0fb274308b22c", "reftest" diff --git a/tests/wpt/mozilla/tests/css/float-abspos.html b/tests/wpt/mozilla/tests/css/float-abspos.html new file mode 100644 index 00000000000..f691c1756f0 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/float-abspos.html @@ -0,0 +1,20 @@ + + +A positioned element's float value computes to "none" + + + + +
+