mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Implement parsing / selector-matching for :is() and :where().
This implements the easy / straight-forward parts of the :where / :is selectors. The biggest missing piece is to handle properly invalidation when there are combinators present inside the :where. That's the hard part of this, actually. But this is probably worth landing in the interim. This fixes some of the visitors that were easy to fix. Differential Revision: https://phabricator.services.mozilla.com/D70788
This commit is contained in:
parent
66f14773c6
commit
83ea321096
10 changed files with 338 additions and 223 deletions
|
@ -330,6 +330,19 @@ where
|
|||
specificity.class_like_selectors += 1;
|
||||
}
|
||||
},
|
||||
Component::Is(ref list) => {
|
||||
// https://drafts.csswg.org/selectors/#specificity-rules:
|
||||
//
|
||||
// The specificity of an :is() pseudo-class is replaced by the
|
||||
// specificity of the most specific complex selector in its
|
||||
// selector list argument.
|
||||
let mut max = 0;
|
||||
for selector in &**list {
|
||||
max = std::cmp::max(selector.specificity(), max);
|
||||
}
|
||||
*specificity += Specificity::from(max);
|
||||
},
|
||||
Component::Where(..) |
|
||||
Component::ExplicitUniversalType |
|
||||
Component::ExplicitAnyNamespace |
|
||||
Component::ExplicitNoNamespace |
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue