aboutsummaryrefslogtreecommitdiffstats
path: root/components/selectors/builder.rs
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2020-04-17 13:37:59 +0000
committerEmilio Cobos Álvarez <emilio@crisal.io>2020-04-18 03:48:15 +0200
commit83ea321096d7afc7b92c2bacd98aabbb8ca96d06 (patch)
tree5bc005e62d10d2f4e285ec4a9d30f8c2f47e5779 /components/selectors/builder.rs
parent66f14773c6c0ded0634751e1ada6fdf5c6ca8d69 (diff)
downloadservo-83ea321096d7afc7b92c2bacd98aabbb8ca96d06.tar.gz
servo-83ea321096d7afc7b92c2bacd98aabbb8ca96d06.zip
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
Diffstat (limited to 'components/selectors/builder.rs')
-rw-r--r--components/selectors/builder.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/components/selectors/builder.rs b/components/selectors/builder.rs
index 7a58e35d17f..4e295a1598f 100644
--- a/components/selectors/builder.rs
+++ b/components/selectors/builder.rs
@@ -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 |