style: Make pseudo-elements work with :host.

Imported WebKit's test as a WPT.

Bug: 1465291
Reviewed-by: xidorn
MozReview-Commit-ID: 19ZThuoqKLW
This commit is contained in:
Emilio Cobos Álvarez 2018-06-04 16:27:00 +02:00
parent 8d069d127a
commit 8821ad72f4
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 35 additions and 28 deletions

View file

@ -544,10 +544,26 @@ impl<Impl: SelectorImpl> Selector<Impl> {
}
/// Whether this selector is a featureless :host selector, with no
/// combinators to the left.
/// combinators to the left, and optionally has a pseudo-element to the
/// right.
#[inline]
pub fn is_featureless_host_selector(&self) -> bool {
self.iter().is_featureless_host_selector()
pub fn is_featureless_host_selector_or_pseudo_element(&self) -> bool {
let mut iter = self.iter();
if !self.has_pseudo_element() {
return iter.is_featureless_host_selector();
}
// Skip the pseudo-element.
for _ in &mut iter { }
match iter.next_sequence() {
None => return false,
Some(combinator) => {
debug_assert_eq!(combinator, Combinator::PseudoElement);
}
}
iter.is_featureless_host_selector()
}
/// Returns an iterator over this selector in matching order (right-to-left),