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
This commit is contained in:
Bobby Holley 2017-04-26 18:34:29 -07:00
parent 6e413653e7
commit f4d81b010b
3 changed files with 12 additions and 3 deletions

View file

@ -342,6 +342,12 @@ impl NonTSPseudoClass {
apply_non_ts_list!(pseudo_class_state) 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. /// Convert NonTSPseudoClass to Gecko's CSSPseudoClassType.
pub fn to_gecko_pseudoclasstype(&self) -> Option<CSSPseudoClassType> { pub fn to_gecko_pseudoclasstype(&self) -> Option<CSSPseudoClassType> {
macro_rules! gecko_type { macro_rules! gecko_type {

View file

@ -235,6 +235,11 @@ impl NonTSPseudoClass {
ServoNonZeroBorder => ElementState::empty(), 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 /// The abstract struct we implement the selector parser implementation on top

View file

@ -953,9 +953,7 @@ impl SelectorVisitor for RevalidationVisitor {
Component::OnlyOfType => { Component::OnlyOfType => {
false false
}, },
// FIXME(emilio): This sets the "revalidation" flag for :any, which is Component::NonTSPseudoClass(ref p) if p.needs_cache_revalidation() => {
// probably expensive given we use it a lot in UA sheets.
Component::NonTSPseudoClass(ref p) if p.state_flag().is_empty() => {
false false
}, },
_ => { _ => {