diff --git a/components/style/gecko/selector_parser.rs b/components/style/gecko/selector_parser.rs index b87824fc33fe..4add99e36e89 100644 --- a/components/style/gecko/selector_parser.rs +++ b/components/style/gecko/selector_parser.rs @@ -342,6 +342,12 @@ impl NonTSPseudoClass { apply_non_ts_list!(pseudo_class_state) } + /// Returns true if the given pseudoclass should trigger style sharing cache revalidation. + pub fn needs_cache_revalidation(&self) -> bool { + self.state_flag().is_empty() && + !matches!(*self, NonTSPseudoClass::MozAny(_)) + } + /// Convert NonTSPseudoClass to Gecko's CSSPseudoClassType. pub fn to_gecko_pseudoclasstype(&self) -> Option { macro_rules! gecko_type { diff --git a/components/style/servo/selector_parser.rs b/components/style/servo/selector_parser.rs index e0277b31480e..0335b249cb1f 100644 --- a/components/style/servo/selector_parser.rs +++ b/components/style/servo/selector_parser.rs @@ -235,6 +235,11 @@ impl NonTSPseudoClass { ServoNonZeroBorder => ElementState::empty(), } } + + /// Returns true if the given pseudoclass should trigger style sharing cache revalidation. + pub fn needs_cache_revalidation(&self) -> bool { + self.state_flag().is_empty() + } } /// The abstract struct we implement the selector parser implementation on top diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 62f1795f25c9..a990dc253b94 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -953,9 +953,7 @@ impl SelectorVisitor for RevalidationVisitor { Component::OnlyOfType => { false }, - // FIXME(emilio): This sets the "revalidation" flag for :any, which is - // probably expensive given we use it a lot in UA sheets. - Component::NonTSPseudoClass(ref p) if p.state_flag().is_empty() => { + Component::NonTSPseudoClass(ref p) if p.needs_cache_revalidation() => { false }, _ => {