aboutsummaryrefslogtreecommitdiffstats
path: root/components/selectors/builder.rs
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2018-04-07 19:46:00 +0200
committerEmilio Cobos Álvarez <emilio@crisal.io>2018-04-09 12:19:05 +0200
commitdb5db13559ec3ddfadb9e86fe87f6896b80ed0a9 (patch)
tree6fb3a0c5d761b29e0e59ffb8733f137bbc4eff52 /components/selectors/builder.rs
parent5d6db3585469e5653fad2a1b82fa5ab24f8991c4 (diff)
downloadservo-db5db13559ec3ddfadb9e86fe87f6896b80ed0a9.tar.gz
servo-db5db13559ec3ddfadb9e86fe87f6896b80ed0a9.zip
style: Implement the non-functional :host selector.
Kinda tricky because :host only matches rules on the shadow root where the rules come from. So we need to be careful during invalidation and style sharing. I didn't use the non_ts_pseudo_class_list bits because as soon as we implement the :host(..) bits we're going to need to special-case it anyway. The general schema is the following: * Rightmost featureless :host selectors are handled inserting them in the host_rules hashmap. Note that we only insert featureless stuff there. We could insert all of them and just filter during matching, but that's slightly annoying. * The other selectors, like non-featureless :host or what not, are added to the normal cascade data. This is harmless, since the shadow host rules are never matched against the host, so we know they'll just never match, and avoids adding more special-cases. * Featureless :host selectors to the left of a combinator are handled during matching, in the special-case of next_element_for_combinator in selectors. This prevents this from being more invasive, and keeps the usual fast path slim, but it's a bit hard to match the spec and the implementation. We could keep a copy of the SelectorIter instead in the matching context to make the handling of featureless-ness explicit in match_non_ts_pseudo_class, but we'd still need the special-case anyway, so I'm not fond of it. * We take advantage of one thing that makes this sound. As you may have noticed, if you had `root` element which is a ShadowRoot, and you matched something like `div:host` against it, using a MatchingContext with current_host == root, we'd incorrectly report a match. But this is impossible due to the following constraints: * Shadow root rules aren't matched against the host during styling (except these featureless selectors). * DOM APIs' current_host needs to be the _containing_ host, not the element itself if you're a Shadow host. Bug: 992245 Reviewed-by: xidorn MozReview-Commit-ID: KayYNfTXb5h
Diffstat (limited to 'components/selectors/builder.rs')
-rw-r--r--components/selectors/builder.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/components/selectors/builder.rs b/components/selectors/builder.rs
index 2220477b553..b81c729eea5 100644
--- a/components/selectors/builder.rs
+++ b/components/selectors/builder.rs
@@ -314,6 +314,7 @@ fn complex_selector_specificity<Impl>(mut iter: slice::Iter<Component<Impl>>)
Component::FirstChild | Component::LastChild |
Component::OnlyChild | Component::Root |
Component::Empty | Component::Scope |
+ Component::Host |
Component::NthChild(..) |
Component::NthLastChild(..) |
Component::NthOfType(..) |