diff options
-rw-r--r-- | components/selectors/parser.rs | 10 | ||||
-rw-r--r-- | components/style/matching.rs | 2 | ||||
-rw-r--r-- | components/style/stylist.rs | 30 |
3 files changed, 18 insertions, 24 deletions
diff --git a/components/selectors/parser.rs b/components/selectors/parser.rs index 2f83d43c893..f53380c2b22 100644 --- a/components/selectors/parser.rs +++ b/components/selectors/parser.rs @@ -476,12 +476,12 @@ pub enum Component<Impl: SelectorImpl> { // // CSS3 Negation only takes a simple simple selector, but we still need to // treat it as a compound selector because it might be a type selector which - // we represent as a namespace and and localname. + // we represent as a namespace and a localname. // - // Note: if/when we upgrade this to CSS4, which supports combinators, we need - // to think about how this should interact with visit_complex_selector, and - // what the consumers of those APIs should do about the presence of combinators - // in negation. + // Note: if/when we upgrade this to CSS4, which supports combinators, we + // need to think about how this should interact with visit_complex_selector, + // and what the consumers of those APIs should do about the presence of + // combinators in negation. Negation(Box<[Component<Impl>]>), FirstChild, LastChild, OnlyChild, Root, diff --git a/components/style/matching.rs b/components/style/matching.rs index 72b98a9d154..b3696a0b7b7 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -199,6 +199,8 @@ fn element_matches_candidate<E: TElement>(element: &E, debug_assert!(data.has_current_styles()); let current_styles = data.styles(); + debug!("Sharing style between {:?} and {:?}", element, candidate_element); + Ok(current_styles.primary.clone()) } diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 29cb600e651..8791498f687 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -336,20 +336,12 @@ impl Stylist { self.dependencies.note_selector(selector); if needs_revalidation(selector) { - // For revalidation, we can skip everything left of the first ancestor - // combinator. - let revalidation_sel = selector.inner.slice_to_first_ancestor_combinator(); - - // Because of the slicing we do above, we can often end up with - // adjacent duplicate selectors when we have selectors like - // body > foo, td > foo, th > foo, etc. Doing a check for - // adjacent duplicates here reduces the number of revalidation - // selectors for Gecko's UA sheet by 30%. - let duplicate = self.selectors_for_cache_revalidation.last() - .map_or(false, |x| x.complex == revalidation_sel.complex); - if !duplicate { - self.selectors_for_cache_revalidation.push(revalidation_sel); - } + // For revalidation, we can skip everything left of + // the first ancestor combinator. + let revalidation_sel = + selector.inner.slice_to_first_ancestor_combinator(); + + self.selectors_for_cache_revalidation.push(revalidation_sel); } } } @@ -844,7 +836,7 @@ impl Stylist { flags_setter: &mut F) -> BitVec where E: TElement, - F: FnMut(&E, ElementSelectorFlags) + F: FnMut(&E, ElementSelectorFlags), { use selectors::matching::StyleRelations; use selectors::matching::matches_selector; @@ -957,8 +949,8 @@ impl SelectorVisitor for RevalidationVisitor { Component::OnlyOfType => { false }, - Component::NonTSPseudoClass(ref p) if p.needs_cache_revalidation() => { - false + Component::NonTSPseudoClass(ref p) => { + !p.needs_cache_revalidation() }, _ => { true @@ -984,8 +976,8 @@ pub fn needs_revalidation(selector: &Selector<SelectorImpl>) -> bool { } // If none of the simple selectors in the rightmost sequence required - // revalidaiton, we need revalidation if and only if the combinator is - // a sibling combinator. + // revalidation, we need revalidation if and only if the combinator is a + // sibling combinator. iter.next_sequence().map_or(false, |c| c.is_sibling()) } |