aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2018-01-19 13:32:44 +0100
committerEmilio Cobos Álvarez <emilio@crisal.io>2018-01-19 13:32:44 +0100
commit9f00a2fdc00308666f947d261476a51a90a9113e (patch)
tree933a7d0ed305e79a02aba3e9b0d5657a17162eed
parent8e25c9e6747941afcff30ba227cddcbb4261d10a (diff)
downloadservo-9f00a2fdc00308666f947d261476a51a90a9113e.tar.gz
servo-9f00a2fdc00308666f947d261476a51a90a9113e.zip
selectors: add an is_nested method to MatchingContext, instead of nesting_level.
-rw-r--r--components/selectors/context.rs6
-rw-r--r--components/selectors/matching.rs9
2 files changed, 8 insertions, 7 deletions
diff --git a/components/selectors/context.rs b/components/selectors/context.rs
index 4df494eca98..75abfea9f18 100644
--- a/components/selectors/context.rs
+++ b/components/selectors/context.rs
@@ -182,10 +182,10 @@ where
}
}
- /// How many times deep are we in a selector.
+ /// Whether we're matching a nested selector.
#[inline]
- pub fn nesting_level(&self) -> usize {
- self.nesting_level
+ pub fn is_nested(&self) -> bool {
+ self.nesting_level != 0
}
/// The quirks mode of the document.
diff --git a/components/selectors/matching.rs b/components/selectors/matching.rs
index 97679e989a9..6b1fae8cc32 100644
--- a/components/selectors/matching.rs
+++ b/components/selectors/matching.rs
@@ -286,7 +286,7 @@ where
// If this is the special pseudo-element mode, consume the ::pseudo-element
// before proceeding, since the caller has already handled that part.
if context.matching_mode == MatchingMode::ForStatelessPseudoElement &&
- context.nesting_level() == 0 {
+ !context.is_nested() {
// Consume the pseudo.
match *iter.next().unwrap() {
Component::PseudoElement(ref pseudo) => {
@@ -342,7 +342,7 @@ fn matches_hover_and_active_quirk<Impl: SelectorImpl>(
return MatchesHoverAndActiveQuirk::No;
}
- if context.nesting_level() != 0 {
+ if context.is_nested() {
return MatchesHoverAndActiveQuirk::No;
}
@@ -718,9 +718,10 @@ where
}
Component::NonTSPseudoClass(ref pc) => {
if context.matches_hover_and_active_quirk == MatchesHoverAndActiveQuirk::Yes &&
- context.shared.nesting_level() == 0 &&
+ !context.shared.is_nested() &&
E::Impl::is_active_or_hover(pc) &&
- !element.is_link() {
+ !element.is_link()
+ {
return false;
}