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] 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. //