mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Add simple parsing and matching support for :has
Parsing is behind a config value `layout.css.has-selectors.enabled`. This change does not support p:has(> a) combinators, but will handle them gracefully, just not matching on them. Differential Revision: https://phabricator.services.mozilla.com/D149515
This commit is contained in:
parent
dcdf9f33d5
commit
3d0cf4dbf9
8 changed files with 85 additions and 10 deletions
|
@ -332,12 +332,14 @@ where
|
|||
Component::NonTSPseudoClass(..) => {
|
||||
specificity.class_like_selectors += 1;
|
||||
},
|
||||
Component::Negation(ref list) | Component::Is(ref list) => {
|
||||
Component::Negation(ref list) |
|
||||
Component::Is(ref list) |
|
||||
Component::Has(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.
|
||||
// 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.
|
||||
let mut max = 0;
|
||||
for selector in &**list {
|
||||
max = std::cmp::max(selector.specificity(), max);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue