style: Collect ::part() rules during CascadeData rebuilds.

Unlike for :host() or ::slotted(), or regular rules, we don't need a whole
SelectorMap<>, so gotta make the code a bit more generic.

Differential Revision: https://phabricator.services.mozilla.com/D32646
This commit is contained in:
Emilio Cobos Álvarez 2019-06-11 17:42:32 +00:00
parent fac050325c
commit 39de0a068e
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
2 changed files with 104 additions and 35 deletions

View file

@ -606,6 +606,31 @@ impl<Impl: SelectorImpl> Selector<Impl> {
self.0.header.header.is_part()
}
#[inline]
pub fn part(&self) -> Option<&Impl::PartName> {
if !self.is_part() {
return None;
}
let mut iter = self.iter();
if self.has_pseudo_element() {
// Skip the pseudo-element.
for _ in &mut iter {}
let combinator = iter.next_sequence()?;
debug_assert_eq!(combinator, Combinator::PseudoElement);
}
for component in iter {
if let Component::Part(ref part) = *component {
return Some(part);
}
}
debug_assert!(false, "is_part() lied somehow?");
None
}
#[inline]
pub fn pseudo_element(&self) -> Option<&Impl::PseudoElement> {
if !self.has_pseudo_element() {