mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
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:
parent
fac050325c
commit
39de0a068e
2 changed files with 104 additions and 35 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue