style: Reuse list_matches_complex_selector() where possible

It can be reused for the Is, Where, and Negation components.

Differential Revision: https://phabricator.services.mozilla.com/D166267
This commit is contained in:
Zach Hoffman 2023-01-18 21:20:02 +00:00 committed by Martin Robinson
parent 93de6edbc9
commit fa297196ef

View file

@ -824,22 +824,12 @@ where
nth_of_data.nth_data(),
nth_of_data.selectors(),
),
Component::Is(ref list) | Component::Where(ref list) => context.shared.nest(|context| {
for selector in &**list {
if matches_complex_selector(selector.iter(), element, context) {
return true;
}
}
false
}),
Component::Negation(ref list) => context.shared.nest_for_negation(|context| {
for selector in &**list {
if matches_complex_selector(selector.iter(), element, context) {
return false;
}
}
true
}),
Component::Is(ref list) | Component::Where(ref list) => context
.shared
.nest(|context| list_matches_complex_selector(list, element, context)),
Component::Negation(ref list) => context
.shared
.nest_for_negation(|context| !list_matches_complex_selector(list, element, context)),
Component::Has(ref list) => context
.shared
.nest(|context| has_children_matching(list, element, context)),