From 43278ed349158ac2ef76bda36509c6bb80713911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 26 Jul 2017 01:55:37 +0200 Subject: [PATCH] style: Don't skip computation of pseudo-elements of display: none elements. We have optimizations to avoid doing selector-matching when the style attribute changes, so, given you can toggle the display property and the pseudo-elements will suddenly become effective, we can't really skip them. Furthermore, we assume that if an element has an ElementStyles, they're up-to-date and we can use them for getComputedStyle, so it's pretty easy to prove that we do the wrong thing when calling getComputedStyle with a pseudo-element on a display: none root. Bug: 1384065 Reviewed-by: heycam MozReview-Commit-ID: BIOqevGZyrm --- components/style/style_resolver.rs | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/components/style/style_resolver.rs b/components/style/style_resolver.rs index 306aba45e19..71be0609a6e 100644 --- a/components/style/style_resolver.rs +++ b/components/style/style_resolver.rs @@ -140,19 +140,10 @@ where parent_style: Option<&ComputedValues>, layout_parent_style: Option<&ComputedValues>, ) -> ElementStyles { - use properties::longhands::display::computed_value::T as display; - let primary_style = self.resolve_primary_style(parent_style, layout_parent_style); let mut pseudo_styles = EagerPseudoStyles::default(); - if primary_style.style.get_box().clone_display() == display::none { - return ElementStyles { - // FIXME(emilio): Remove the Option<>. - primary: Some(primary_style.style), - pseudos: pseudo_styles, - } - } if self.element.implemented_pseudo_element().is_none() { let layout_parent_style_for_pseudo = @@ -237,7 +228,6 @@ where &mut self, inputs: ElementCascadeInputs, ) -> ElementStyles { - use properties::longhands::display::computed_value::T as display; with_default_parent_styles(self.element, move |parent_style, layout_parent_style| { let primary_style = PrimaryStyle { style: self.cascade_style_and_visited( @@ -249,16 +239,7 @@ where }; let mut pseudo_styles = EagerPseudoStyles::default(); - let pseudo_array = inputs.pseudos.into_array(); - if pseudo_array.is_none() || - primary_style.style.get_box().clone_display() == display::none { - return ElementStyles { - primary: Some(primary_style.style), - pseudos: pseudo_styles, - } - } - - { + if let Some(mut pseudo_array) = inputs.pseudos.into_array() { let layout_parent_style_for_pseudo = if primary_style.style.is_display_contents() { layout_parent_style @@ -266,7 +247,7 @@ where Some(&*primary_style.style) }; - for (i, mut inputs) in pseudo_array.unwrap().iter_mut().enumerate() { + for (i, mut inputs) in pseudo_array.iter_mut().enumerate() { if let Some(inputs) = inputs.take() { let pseudo = PseudoElement::from_eager_index(i); pseudo_styles.set(