style: Implement parsing and serialization for nth-child(An+B of selector list) and :nth-last-child(An+B of selector list)

:nth-{,last-}child parsing is disabled by default for now by pref
layout.css.nth-child-of.enabled.

Differential Revision: https://phabricator.services.mozilla.com/D165895
This commit is contained in:
Zach Hoffman 2023-01-07 14:32:42 +00:00 committed by Martin Robinson
parent b7d64ee6a4
commit 1c8408e97e
6 changed files with 123 additions and 11 deletions

View file

@ -388,7 +388,8 @@ fn hover_and_active_quirk_applies<Impl: SelectorImpl>(
Component::PseudoElement(_) |
Component::Negation(_) |
Component::Empty |
Component::Nth(_) => false,
Component::Nth(_) |
Component::NthOf(_) => false,
Component::NonTSPseudoClass(ref pseudo_class) => pseudo_class.is_active_or_hover(),
_ => true,
})
@ -803,6 +804,10 @@ where
Component::Nth(ref nth_data) => {
matches_generic_nth_child(element, context.shared, nth_data)
},
Component::NthOf(ref nth_of_data) => {
// TODO(zrhoffman, bug 1808228): Use selectors() when matching
matches_generic_nth_child(element, context.shared, nth_of_data.nth_data())
},
Component::Is(ref list) | Component::Where(ref list) => context.shared.nest(|context| {
for selector in &**list {
if matches_complex_selector(selector.iter(), element, context) {