From b4a2e2f17c4618f03cfe7d6654c3332b1309a426 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Thu, 27 Apr 2017 17:52:37 -0700 Subject: [PATCH] Clean up note_selector a bit and stop handling combinators in two places. MozReview-Commit-ID: HhVi72K4yp0 --- components/style/restyle_hints.rs | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/components/style/restyle_hints.rs b/components/style/restyle_hints.rs index 9d3d8814ac7..8710e590421 100644 --- a/components/style/restyle_hints.rs +++ b/components/style/restyle_hints.rs @@ -18,7 +18,7 @@ use selectors::{Element, MatchAttr}; use selectors::matching::{ElementSelectorFlags, StyleRelations}; use selectors::matching::matches_selector; use selectors::parser::{AttrSelector, Combinator, Component, Selector}; -use selectors::parser::{SelectorInner, SelectorIter, SelectorMethods}; +use selectors::parser::{SelectorInner, SelectorMethods}; use selectors::visitor::SelectorVisitor; use std::clone::Clone; @@ -482,27 +482,13 @@ struct Dependency { /// of them is sensitive to attribute or state changes. struct SensitivitiesVisitor { sensitivities: Sensitivities, - hint: RestyleHint, } impl SelectorVisitor for SensitivitiesVisitor { type Impl = SelectorImpl; - - fn visit_complex_selector(&mut self, - _: SelectorIter, - combinator: Option) -> bool { - self.hint |= combinator_to_restyle_hint(combinator); - - true - } - fn visit_simple_selector(&mut self, s: &Component) -> bool { self.sensitivities.states.insert(selector_to_state(s)); - - if !self.sensitivities.attrs { - self.sensitivities.attrs = is_attr_selector(s); - } - + self.sensitivities.attrs |= is_attr_selector(s); true } } @@ -547,9 +533,9 @@ impl DependencySet { while let Some(current) = next.take() { // Set up our visitor. let mut visitor = SensitivitiesVisitor { - sensitivities: Sensitivities::new(), - hint: combinator_to_restyle_hint(combinator), + sensitivities: Sensitivities::new() }; + let mut hint = combinator_to_restyle_hint(combinator); if is_pseudo_element { // TODO(emilio): use more fancy restyle hints to avoid restyling @@ -560,7 +546,7 @@ impl DependencySet { // restyle_descendants to handle all of them (::before and // ::after, because we find them in the subtree, and other lazy // pseudos for the same reason). - visitor.hint |= RESTYLE_SELF | RESTYLE_DESCENDANTS; + hint |= RESTYLE_SELF | RESTYLE_DESCENDANTS; is_pseudo_element = false; } @@ -584,7 +570,7 @@ impl DependencySet { if !visitor.sensitivities.is_empty() { self.add_dependency(Dependency { sensitivities: visitor.sensitivities, - hint: visitor.hint, + hint: hint, selector: SelectorInner::new(current), }) }