From 191c39f28cf9ad0244fad6c3214c0df9f4f13acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 21 Oct 2017 13:00:54 +0200 Subject: [PATCH] style: Make invalidations with offset zero "universal" invalidations. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We'll use this for querySelector / querySelectorAll. Signed-off-by: Emilio Cobos Álvarez --- components/selectors/matching.rs | 3 +-- components/style/invalidation/element/invalidator.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/components/selectors/matching.rs b/components/selectors/matching.rs index f648594db04..7b505779315 100644 --- a/components/selectors/matching.rs +++ b/components/selectors/matching.rs @@ -338,8 +338,7 @@ pub fn matches_compound_selector( 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. } diff --git a/components/style/invalidation/element/invalidator.rs b/components/style/invalidation/element/invalidator.rs index 99e42e6d860..359617466d9 100644 --- a/components/style/invalidation/element/invalidator.rs +++ b/components/style/invalidation/element/invalidator.rs @@ -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 . // @@ -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 {