selectors: add an is_nested method to MatchingContext, instead of nesting_level.

This commit is contained in:
Emilio Cobos Álvarez 2018-01-19 13:32:44 +01:00
parent 8e25c9e674
commit 9f00a2fdc0
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 8 additions and 7 deletions

View file

@ -182,10 +182,10 @@ where
} }
} }
/// How many times deep are we in a selector. /// Whether we're matching a nested selector.
#[inline] #[inline]
pub fn nesting_level(&self) -> usize { pub fn is_nested(&self) -> bool {
self.nesting_level self.nesting_level != 0
} }
/// The quirks mode of the document. /// The quirks mode of the document.

View file

@ -286,7 +286,7 @@ where
// If this is the special pseudo-element mode, consume the ::pseudo-element // If this is the special pseudo-element mode, consume the ::pseudo-element
// before proceeding, since the caller has already handled that part. // before proceeding, since the caller has already handled that part.
if context.matching_mode == MatchingMode::ForStatelessPseudoElement && if context.matching_mode == MatchingMode::ForStatelessPseudoElement &&
context.nesting_level() == 0 { !context.is_nested() {
// Consume the pseudo. // Consume the pseudo.
match *iter.next().unwrap() { match *iter.next().unwrap() {
Component::PseudoElement(ref pseudo) => { Component::PseudoElement(ref pseudo) => {
@ -342,7 +342,7 @@ fn matches_hover_and_active_quirk<Impl: SelectorImpl>(
return MatchesHoverAndActiveQuirk::No; return MatchesHoverAndActiveQuirk::No;
} }
if context.nesting_level() != 0 { if context.is_nested() {
return MatchesHoverAndActiveQuirk::No; return MatchesHoverAndActiveQuirk::No;
} }
@ -718,9 +718,10 @@ where
} }
Component::NonTSPseudoClass(ref pc) => { Component::NonTSPseudoClass(ref pc) => {
if context.matches_hover_and_active_quirk == MatchesHoverAndActiveQuirk::Yes && 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) && E::Impl::is_active_or_hover(pc) &&
!element.is_link() { !element.is_link()
{
return false; return false;
} }