style: Move nth-related logic to the NthSelectorData type for reuse

Drive-by, but selector_list_specificity() was also renamed to
max_selector_list_specificity().

Differential Revision: https://phabricator.services.mozilla.com/D166263
This commit is contained in:
Zach Hoffman 2023-01-09 06:06:27 +00:00 committed by Martin Robinson
parent 1c8408e97e
commit 39b056cf70
2 changed files with 50 additions and 42 deletions

View file

@ -331,7 +331,7 @@ where
// specificity of a regular pseudo-class with that of its
// selector argument S.
specificity.class_like_selectors += 1;
*specificity += selector_list_specificity(nth_of_data.selectors());
*specificity += max_selector_list_specificity(nth_of_data.selectors());
},
Component::Negation(ref list) | Component::Is(ref list) | Component::Has(ref list) => {
// https://drafts.csswg.org/selectors/#specificity-rules:
@ -339,7 +339,7 @@ where
// The specificity of an :is(), :not(), or :has() pseudo-class
// is replaced by the specificity of the most specific complex
// selector in its selector list argument.
*specificity += selector_list_specificity(list);
*specificity += max_selector_list_specificity(list);
},
Component::Where(..) |
Component::ExplicitUniversalType |
@ -353,7 +353,7 @@ where
}
/// Finds the maximum specificity of elements in the list and returns it.
fn selector_list_specificity<Impl: SelectorImpl>(list: &[Selector<Impl>]) -> Specificity {
fn max_selector_list_specificity<Impl: SelectorImpl>(list: &[Selector<Impl>]) -> Specificity {
let max = list
.iter()
.map(|selector| selector.specificity())