From f4d81b010b621ceb47a35c921f8cdf1a7959dff9 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 26 Apr 2017 18:34:29 -0700 Subject: [PATCH] Properly handle -moz-any for revalidation selectors. Note that, while the comment is correct that there is a fair amount of -moz-any usage in the UA sheet, it's always used as an ancestor selector, and thus ignored for our purposes. Nevertheless, it's straightforward enough to support properly, so we do that here. MozReview-Commit-ID: Kz1yNfPUIaP --- components/style/gecko/selector_parser.rs | 6 ++++++ components/style/servo/selector_parser.rs | 5 +++++ components/style/stylist.rs | 4 +--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/components/style/gecko/selector_parser.rs b/components/style/gecko/selector_parser.rs index b87824fc33f..4add99e36e8 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 e0277b31480..0335b249cb1 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 62f1795f25c..a990dc253b9 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 }, _ => {