mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
Auto merge of #17867 - emilio:pseudo-display-none, r=heycam
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
This commit is contained in:
commit
f61528d297
1 changed files with 2 additions and 21 deletions
|
@ -140,19 +140,10 @@ where
|
||||||
parent_style: Option<&ComputedValues>,
|
parent_style: Option<&ComputedValues>,
|
||||||
layout_parent_style: Option<&ComputedValues>,
|
layout_parent_style: Option<&ComputedValues>,
|
||||||
) -> ElementStyles {
|
) -> ElementStyles {
|
||||||
use properties::longhands::display::computed_value::T as display;
|
|
||||||
|
|
||||||
let primary_style =
|
let primary_style =
|
||||||
self.resolve_primary_style(parent_style, layout_parent_style);
|
self.resolve_primary_style(parent_style, layout_parent_style);
|
||||||
|
|
||||||
let mut pseudo_styles = EagerPseudoStyles::default();
|
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() {
|
if self.element.implemented_pseudo_element().is_none() {
|
||||||
let layout_parent_style_for_pseudo =
|
let layout_parent_style_for_pseudo =
|
||||||
|
@ -237,7 +228,6 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
inputs: ElementCascadeInputs,
|
inputs: ElementCascadeInputs,
|
||||||
) -> ElementStyles {
|
) -> ElementStyles {
|
||||||
use properties::longhands::display::computed_value::T as display;
|
|
||||||
with_default_parent_styles(self.element, move |parent_style, layout_parent_style| {
|
with_default_parent_styles(self.element, move |parent_style, layout_parent_style| {
|
||||||
let primary_style = PrimaryStyle {
|
let primary_style = PrimaryStyle {
|
||||||
style: self.cascade_style_and_visited(
|
style: self.cascade_style_and_visited(
|
||||||
|
@ -249,16 +239,7 @@ where
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut pseudo_styles = EagerPseudoStyles::default();
|
let mut pseudo_styles = EagerPseudoStyles::default();
|
||||||
let pseudo_array = inputs.pseudos.into_array();
|
if let Some(mut 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,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
let layout_parent_style_for_pseudo =
|
let layout_parent_style_for_pseudo =
|
||||||
if primary_style.style.is_display_contents() {
|
if primary_style.style.is_display_contents() {
|
||||||
layout_parent_style
|
layout_parent_style
|
||||||
|
@ -266,7 +247,7 @@ where
|
||||||
Some(&*primary_style.style)
|
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() {
|
if let Some(inputs) = inputs.take() {
|
||||||
let pseudo = PseudoElement::from_eager_index(i);
|
let pseudo = PseudoElement::from_eager_index(i);
|
||||||
pseudo_styles.set(
|
pseudo_styles.set(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue