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
This commit is contained in:
Emilio Cobos Álvarez 2020-04-17 13:37:59 +00:00
parent 66f14773c6
commit 83ea321096
10 changed files with 338 additions and 223 deletions

View file

@ -500,6 +500,15 @@ fn specific_bucket_for<'a>(component: &'a Component<SelectorImpl>) -> Bucket<'a>
// match the slotted <span>.
Component::Slotted(ref selector) => find_bucket(selector.iter()),
Component::Host(Some(ref selector)) => find_bucket(selector.iter()),
Component::Is(ref list) | Component::Where(ref list) => {
if list.len() == 1 {
find_bucket(list[0].iter())
} else {
// TODO(emilio): We should handle the multiple element case by
// inserting multiple entries in the map.
Bucket::Universal
}
},
_ => Bucket::Universal,
}
}