aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/selectors/matching.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/components/selectors/matching.rs b/components/selectors/matching.rs
index 84ddde2b261..0ab6c7e29e0 100644
--- a/components/selectors/matching.rs
+++ b/components/selectors/matching.rs
@@ -225,8 +225,10 @@ impl RelevantLinkStatus {
-> RelevantLinkStatus
where E: Element,
{
+ // If a relevant link was previously found, we no longer want to look
+ // for links. Only the nearest ancestor link is considered relevant.
if *self != RelevantLinkStatus::Looking {
- return *self
+ return RelevantLinkStatus::NotLooking
}
if !element.is_link() {
@@ -407,7 +409,7 @@ pub fn matches_complex_selector<E, F>(complex_selector: &Selector<E::Impl>,
match matches_complex_selector_internal(iter,
element,
context,
- RelevantLinkStatus::Looking,
+ &mut RelevantLinkStatus::Looking,
flags_setter) {
SelectorMatchingResult::Matched => true,
_ => false
@@ -417,13 +419,13 @@ pub fn matches_complex_selector<E, F>(complex_selector: &Selector<E::Impl>,
fn matches_complex_selector_internal<E, F>(mut selector_iter: SelectorIter<E::Impl>,
element: &E,
context: &mut MatchingContext,
- relevant_link: RelevantLinkStatus,
+ relevant_link: &mut RelevantLinkStatus,
flags_setter: &mut F)
-> SelectorMatchingResult
where E: Element,
F: FnMut(&E, ElementSelectorFlags),
{
- let mut relevant_link = relevant_link.examine_potential_link(element, context);
+ *relevant_link = relevant_link.examine_potential_link(element, context);
let matches_all_simple_selectors = selector_iter.all(|simple| {
matches_simple_selector(simple, element, context, &relevant_link, flags_setter)
@@ -449,7 +451,7 @@ fn matches_complex_selector_internal<E, F>(mut selector_iter: SelectorIter<E::Im
Combinator::NextSibling | Combinator::LaterSibling => {
// Only ancestor combinators are allowed while looking for
// relevant links, so switch to not looking.
- relevant_link = RelevantLinkStatus::NotLooking;
+ *relevant_link = RelevantLinkStatus::NotLooking;
(element.prev_sibling_element(),
SelectorMatchingResult::NotMatchedAndRestartFromClosestDescendant)
}