style: Make invalidations with offset zero "universal" invalidations.

We'll use this for querySelector / querySelectorAll.

Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
Emilio Cobos Álvarez 2017-10-21 13:00:54 +02:00
parent a296e386af
commit 191c39f28c
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 9 additions and 2 deletions

View file

@ -338,8 +338,7 @@ pub fn matches_compound_selector<E>(
where
E: Element
{
debug_assert_ne!(from_offset, 0);
if cfg!(debug_assertions) {
if cfg!(debug_assertions) && from_offset != 0 {
selector.combinator_at_parse_order(from_offset - 1); // This asserts.
}

View file

@ -112,6 +112,10 @@ impl Invalidation {
/// Whether this invalidation is effective for the next sibling or
/// descendant after us.
fn effective_for_next(&self) -> bool {
if self.offset == 0 {
return true;
}
// TODO(emilio): For pseudo-elements this should be mostly false, except
// for the weird pseudos in <input type="number">.
//
@ -124,6 +128,10 @@ impl Invalidation {
}
fn kind(&self) -> InvalidationKind {
if self.offset == 0 {
return InvalidationKind::Descendant;
}
if self.selector.combinator_at_parse_order(self.offset - 1).is_ancestor() {
InvalidationKind::Descendant
} else {