diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2020-04-17 13:37:59 +0000 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2020-04-18 03:48:15 +0200 |
commit | 83ea321096d7afc7b92c2bacd98aabbb8ca96d06 (patch) | |
tree | 5bc005e62d10d2f4e285ec4a9d30f8c2f47e5779 /components/style/servo | |
parent | 66f14773c6c0ded0634751e1ada6fdf5c6ca8d69 (diff) | |
download | servo-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/style/servo')
-rw-r--r-- | components/style/servo/selector_parser.rs | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/components/style/servo/selector_parser.rs b/components/style/servo/selector_parser.rs index 2537cae9f83..75dd041b9c0 100644 --- a/components/style/servo/selector_parser.rs +++ b/components/style/servo/selector_parser.rs @@ -19,7 +19,7 @@ use crate::{Atom, CaseSensitivityExt, LocalName, Namespace, Prefix}; use cssparser::{serialize_identifier, CowRcStr, Parser as CssParser, SourceLocation, ToCss}; use fxhash::FxHashMap; use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint}; -use selectors::parser::{SelectorParseErrorKind, Visit}; +use selectors::parser::SelectorParseErrorKind; use selectors::visitor::SelectorVisitor; use std::fmt; use std::mem; @@ -315,8 +315,16 @@ impl ::selectors::parser::NonTSPseudoClass for NonTSPseudoClass { fn has_zero_specificity(&self) -> bool { false } + + fn visit<V>(&self, _: &mut V) -> bool + where + V: SelectorVisitor<Impl = Self::Impl>, + { + true + } } + impl ToCss for NonTSPseudoClass { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where @@ -352,17 +360,6 @@ impl ToCss for NonTSPseudoClass { } } -impl Visit for NonTSPseudoClass { - type Impl = SelectorImpl; - - fn visit<V>(&self, _: &mut V) -> bool - where - V: SelectorVisitor<Impl = Self::Impl>, - { - true - } -} - impl NonTSPseudoClass { /// Gets a given state flag for this pseudo-class. This is used to do /// selector matching, and it's set from the DOM. |