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

@ -331,11 +331,9 @@ where
return false;
}
// Advance to the non-pseudo-element part of the selector, but let the
// context note that .
if iter.next_sequence().is_none() {
return true;
}
// Advance to the non-pseudo-element part of the selector.
let next_sequence = iter.next_sequence().unwrap();
debug_assert_eq!(next_sequence, Combinator::PseudoElement);
}
let result =
@ -452,10 +450,6 @@ where
},
Combinator::Part => element.containing_shadow_host(),
Combinator::SlotAssignment => {
debug_assert!(
context.current_host.is_some(),
"Should not be trying to match slotted rules in a non-shadow-tree context"
);
debug_assert!(element
.assigned_slot()
.map_or(true, |s| s.is_html_slot_element()));
@ -677,7 +671,6 @@ where
Component::Slotted(ref selector) => {
// <slots> are never flattened tree slottables.
!element.is_html_slot_element() &&
element.assigned_slot().is_some() &&
context.shared.nest(|context| {
matches_complex_selector(selector.iter(), element, context, flags_setter)
})