style: Record attribute dependencies within the selector list of :nth-child(... of <selector list>)

There are separate filters for IDs, classes, attribute local names, and
element state.

Also, we invalidate siblings of elements matched against the selector
list of :nth-child(... of <selector list>) by marking matched elements
with NODE_HAS_SLOW_SELECTOR_NTH_OF.

The only remaining invalidation case invalidation case is
`:nth-child(An+B of :has())` (bug 1818155), which should not block
shipping `layout.css.nth-child-of.enabled`, because :has(...) is still
being implemented (bug 418039).

Depends on D172352

Differential Revision: https://phabricator.services.mozilla.com/D171936
This commit is contained in:
Zach Hoffman 2023-03-15 06:56:21 +00:00 committed by Martin Robinson
parent c7f8845665
commit 356e886d26
7 changed files with 261 additions and 28 deletions

View file

@ -12,6 +12,7 @@ use crate::builder::{
};
use crate::context::QuirksMode;
use crate::sink::Push;
use crate::visitor::SelectorListKind;
pub use crate::visitor::SelectorVisitor;
use bitflags::bitflags;
use cssparser::{match_ignore_ascii_case, parse_nth, *};
@ -1625,14 +1626,15 @@ impl<Impl: SelectorImpl> Component<Impl> {
return false;
}
},
Negation(ref list) | Is(ref list) | Where(ref list) => {
if !visitor.visit_selector_list(&list) {
let list_kind = SelectorListKind::from_component(self);
debug_assert!(!list_kind.is_empty());
if !visitor.visit_selector_list(list_kind, &list) {
return false;
}
},
NthOf(ref nth_of_data) => {
if !visitor.visit_selector_list(nth_of_data.selectors()) {
if !visitor.visit_selector_list(SelectorListKind::NTH_OF, nth_of_data.selectors()) {
return false;
}
},