diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-12-10 14:23:27 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-12-14 06:28:11 +0100 |
commit | 7886e033aa7e813a9ed3becc456ee9ed059364cc (patch) | |
tree | 6ff62f4ec8593d29ef3e5fba392ee07304cb8b5c /components/selectors/builder.rs | |
parent | 0fa605d2439c4f640b7f180c18d768a7a14e7f1e (diff) | |
download | servo-7886e033aa7e813a9ed3becc456ee9ed059364cc.tar.gz servo-7886e033aa7e813a9ed3becc456ee9ed059364cc.zip |
selectors: Add parsing support for ::slotted().
Without turning it on yet, of course.
The reason why I didn't use the general PseudoElement mechanism is because this
pseudo is a bit of its own thing, and I found easier to make ::selectors know
about it (because you need to jump to the assigned slot) than the other way
around.
Also, we need to support ::slotted(..)::before and such, and supporting multiple
pseudo-elements like that breaks some other invariants around the SelectorMap,
and fixing those would require special-casing slotted a lot more in other parts
of the code.
Let me know if you think otherwise.
I also don't like much the boolean tuple return value, but I plan to do some
cleanup in the area in a bit, so it should go away soon, I'd hope.
Diffstat (limited to 'components/selectors/builder.rs')
-rw-r--r-- | components/selectors/builder.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/components/selectors/builder.rs b/components/selectors/builder.rs index c996a6a6491..b3d61b34706 100644 --- a/components/selectors/builder.rs +++ b/components/selectors/builder.rs @@ -264,12 +264,23 @@ fn complex_selector_specificity<Impl>(mut iter: slice::Iter<Component<Impl>>) -> Specificity where Impl: SelectorImpl { - fn simple_selector_specificity<Impl>(simple_selector: &Component<Impl>, - specificity: &mut Specificity) - where Impl: SelectorImpl + fn simple_selector_specificity<Impl>( + simple_selector: &Component<Impl>, + specificity: &mut Specificity, + ) + where + Impl: SelectorImpl { match *simple_selector { Component::Combinator(..) => unreachable!(), + // FIXME(emilio): Spec doesn't define any particular specificity for + // ::slotted(), so apply the general rule for pseudos per: + // + // https://github.com/w3c/csswg-drafts/issues/1915 + // + // Though other engines compute it dynamically, so maybe we should + // do that instead, eventually. + Component::Slotted(..) | Component::PseudoElement(..) | Component::LocalName(..) => { specificity.element_selectors += 1 |