mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
selectors: Deindent some selector-matching code.
MozReview-Commit-ID: B0ixSTcRS4S
This commit is contained in:
parent
dd5cd29a61
commit
22dc480272
1 changed files with 75 additions and 69 deletions
|
@ -533,10 +533,12 @@ where
|
|||
return SelectorMatchingResult::NotMatchedAndRestartFromClosestLaterSibling;
|
||||
}
|
||||
|
||||
match combinator {
|
||||
None => SelectorMatchingResult::Matched,
|
||||
Some(c) => {
|
||||
let (mut next_element, candidate_not_found) = match c {
|
||||
let combinator = match combinator {
|
||||
None => return SelectorMatchingResult::Matched,
|
||||
Some(c) => c,
|
||||
};
|
||||
|
||||
let (mut next_element, candidate_not_found) = match combinator {
|
||||
Combinator::NextSibling | Combinator::LaterSibling => {
|
||||
// Only ancestor combinators are allowed while looking for
|
||||
// relevant links, so switch to not looking.
|
||||
|
@ -571,41 +573,45 @@ where
|
|||
flags_setter,
|
||||
Rightmost::No,
|
||||
);
|
||||
match (result, c) {
|
||||
|
||||
match (result, combinator) {
|
||||
// Return the status immediately.
|
||||
(SelectorMatchingResult::Matched, _) => return result,
|
||||
(SelectorMatchingResult::NotMatchedGlobally, _) => return result,
|
||||
(SelectorMatchingResult::Matched, _) |
|
||||
(SelectorMatchingResult::NotMatchedGlobally, _) |
|
||||
(_, Combinator::NextSibling) => {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Upgrade the failure status to
|
||||
// NotMatchedAndRestartFromClosestDescendant.
|
||||
(_, Combinator::PseudoElement) |
|
||||
(_, Combinator::Child) => return SelectorMatchingResult::NotMatchedAndRestartFromClosestDescendant,
|
||||
(_, Combinator::Child) => {
|
||||
return SelectorMatchingResult::NotMatchedAndRestartFromClosestDescendant;
|
||||
}
|
||||
|
||||
// Return the status directly.
|
||||
(_, Combinator::NextSibling) => return result,
|
||||
|
||||
// If the failure status is NotMatchedAndRestartFromClosestDescendant
|
||||
// and combinator is Combinator::LaterSibling, give up this Combinator::LaterSibling matching
|
||||
// and restart from the closest descendant combinator.
|
||||
(SelectorMatchingResult::NotMatchedAndRestartFromClosestDescendant, Combinator::LaterSibling)
|
||||
=> return result,
|
||||
// If the failure status is
|
||||
// NotMatchedAndRestartFromClosestDescendant and combinator is
|
||||
// Combinator::LaterSibling, give up this Combinator::LaterSibling
|
||||
// matching and restart from the closest descendant combinator.
|
||||
(SelectorMatchingResult::NotMatchedAndRestartFromClosestDescendant, Combinator::LaterSibling) => {
|
||||
return result;
|
||||
}
|
||||
|
||||
// The Combinator::Descendant combinator and the status is
|
||||
// NotMatchedAndRestartFromClosestLaterSibling or
|
||||
// NotMatchedAndRestartFromClosestDescendant,
|
||||
// or the Combinator::LaterSibling combinator and the status is
|
||||
// NotMatchedAndRestartFromClosestDescendant
|
||||
// can continue to matching on the next candidate element.
|
||||
// NotMatchedAndRestartFromClosestDescendant, or the
|
||||
// Combinator::LaterSibling combinator and the status is
|
||||
// NotMatchedAndRestartFromClosestDescendant, we can continue to
|
||||
// matching on the next candidate element.
|
||||
_ => {},
|
||||
}
|
||||
|
||||
next_element = if siblings {
|
||||
element.prev_sibling_element()
|
||||
} else {
|
||||
element.parent_element()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Determines whether the given element matches the given single selector.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue