style: Cleanup selector-matching for nested pseudo-elements, match ::slotted correctly when there's no selector before it, and add tests.

D29542 fixed the bogus checks that was making nested pseudo-elements match
author rules. This adds tests and ends up being just a cleanup, though as it
turns out we it also fixes an issue with ::slotted() matched from
Element.matches.

Differential Revision: https://phabricator.services.mozilla.com/D27529
This commit is contained in:
Emilio Cobos Álvarez 2019-05-24 01:09:15 +00:00
parent 272d9758d7
commit 43444db8a8
9 changed files with 35 additions and 38 deletions

View file

@ -1098,7 +1098,7 @@ impl<'le> TElement for GeckoElement<'le> {
type TraversalChildrenIterator = GeckoChildrenIterator<'le>;
fn inheritance_parent(&self) -> Option<Self> {
if self.implemented_pseudo_element().is_some() {
if self.is_pseudo_element() {
return self.pseudo_element_originating_element();
}
@ -1471,7 +1471,7 @@ impl<'le> TElement for GeckoElement<'le> {
#[inline]
fn skip_item_display_fixup(&self) -> bool {
debug_assert!(
self.implemented_pseudo_element().is_none(),
!self.is_pseudo_element(),
"Just don't call me if I'm a pseudo, you should know the answer already"
);
self.is_root_of_native_anonymous_subtree()
@ -1918,9 +1918,14 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
Some(shadow.host())
}
#[inline]
fn is_pseudo_element(&self) -> bool {
self.implemented_pseudo_element().is_some()
}
#[inline]
fn pseudo_element_originating_element(&self) -> Option<Self> {
debug_assert!(self.implemented_pseudo_element().is_some());
debug_assert!(self.is_pseudo_element());
let parent = self.closest_anon_subtree_root_parent()?;
// FIXME(emilio): Special-case for <input type="number">s