Skip to content

Commit

Permalink
Properly handle -moz-any for revalidation selectors.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bholley committed Apr 27, 2017
1 parent 6e41365 commit f4d81b0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions components/style/gecko/selector_parser.rs
Expand Up @@ -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<CSSPseudoClassType> {
macro_rules! gecko_type {
Expand Down
5 changes: 5 additions & 0 deletions components/style/servo/selector_parser.rs
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions components/style/stylist.rs
Expand Up @@ -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
},
_ => {
Expand Down

0 comments on commit f4d81b0

Please sign in to comment.