selectors: Deindent some selector-matching code.

MozReview-Commit-ID: B0ixSTcRS4S
This commit is contained in:
Emilio Cobos Álvarez 2017-10-26 17:21:06 +02:00
parent dd5cd29a61
commit 22dc480272
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -533,10 +533,12 @@ where
return SelectorMatchingResult::NotMatchedAndRestartFromClosestLaterSibling; return SelectorMatchingResult::NotMatchedAndRestartFromClosestLaterSibling;
} }
match combinator { let combinator = match combinator {
None => SelectorMatchingResult::Matched, None => return SelectorMatchingResult::Matched,
Some(c) => { Some(c) => c,
let (mut next_element, candidate_not_found) = match c { };
let (mut next_element, candidate_not_found) = match combinator {
Combinator::NextSibling | Combinator::LaterSibling => { Combinator::NextSibling | Combinator::LaterSibling => {
// Only ancestor combinators are allowed while looking for // Only ancestor combinators are allowed while looking for
// relevant links, so switch to not looking. // relevant links, so switch to not looking.
@ -571,41 +573,45 @@ where
flags_setter, flags_setter,
Rightmost::No, Rightmost::No,
); );
match (result, c) {
match (result, combinator) {
// Return the status immediately. // Return the status immediately.
(SelectorMatchingResult::Matched, _) => return result, (SelectorMatchingResult::Matched, _) |
(SelectorMatchingResult::NotMatchedGlobally, _) => return result, (SelectorMatchingResult::NotMatchedGlobally, _) |
(_, Combinator::NextSibling) => {
return result;
}
// Upgrade the failure status to // Upgrade the failure status to
// NotMatchedAndRestartFromClosestDescendant. // NotMatchedAndRestartFromClosestDescendant.
(_, Combinator::PseudoElement) | (_, Combinator::PseudoElement) |
(_, Combinator::Child) => return SelectorMatchingResult::NotMatchedAndRestartFromClosestDescendant, (_, Combinator::Child) => {
return SelectorMatchingResult::NotMatchedAndRestartFromClosestDescendant;
}
// Return the status directly. // If the failure status is
(_, Combinator::NextSibling) => return result, // NotMatchedAndRestartFromClosestDescendant and combinator is
// Combinator::LaterSibling, give up this Combinator::LaterSibling
// If the failure status is NotMatchedAndRestartFromClosestDescendant // matching and restart from the closest descendant combinator.
// and combinator is Combinator::LaterSibling, give up this Combinator::LaterSibling matching (SelectorMatchingResult::NotMatchedAndRestartFromClosestDescendant, Combinator::LaterSibling) => {
// and restart from the closest descendant combinator. return result;
(SelectorMatchingResult::NotMatchedAndRestartFromClosestDescendant, Combinator::LaterSibling) }
=> return result,
// The Combinator::Descendant combinator and the status is // The Combinator::Descendant combinator and the status is
// NotMatchedAndRestartFromClosestLaterSibling or // NotMatchedAndRestartFromClosestLaterSibling or
// NotMatchedAndRestartFromClosestDescendant, // NotMatchedAndRestartFromClosestDescendant, or the
// or the Combinator::LaterSibling combinator and the status is // Combinator::LaterSibling combinator and the status is
// NotMatchedAndRestartFromClosestDescendant // NotMatchedAndRestartFromClosestDescendant, we can continue to
// can continue to matching on the next candidate element. // matching on the next candidate element.
_ => {}, _ => {},
} }
next_element = if siblings { next_element = if siblings {
element.prev_sibling_element() element.prev_sibling_element()
} else { } else {
element.parent_element() element.parent_element()
}; };
} }
}
}
} }
/// Determines whether the given element matches the given single selector. /// Determines whether the given element matches the given single selector.