From 9e0dd19e7e5436dfdc765cc3bd89fcfafc768783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 20 Aug 2017 09:01:12 +0200 Subject: [PATCH] style: Skip state pseudo-classes when finding a pseudo-element. Bug: 1391577 Reviewed-by: heycam MozReview-Commit-ID: 1ICBijtcf2b --- .../style/invalidation/element/invalidator.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/components/style/invalidation/element/invalidator.rs b/components/style/invalidation/element/invalidator.rs index 44f6b8da3eb..234a627dd41 100644 --- a/components/style/invalidation/element/invalidator.rs +++ b/components/style/invalidation/element/invalidator.rs @@ -595,14 +595,27 @@ impl<'a, 'b: 'a, E> TreeStyleInvalidator<'a, 'b, E> matched = true; if matches!(next_combinator, Combinator::PseudoElement) { + // This will usually be the very next component, except for + // the fact that we store compound selectors the other way + // around, so there could also be state pseudo-classes. let pseudo_selector = invalidation.selector .iter_raw_parse_order_from(next_combinator_offset - 1) + .skip_while(|c| matches!(**c, Component::NonTSPseudoClass(..))) .next() .unwrap(); + let pseudo = match *pseudo_selector { Component::PseudoElement(ref pseudo) => pseudo, - _ => unreachable!("Someone seriously messed up selector parsing"), + _ => { + unreachable!( + "Someone seriously messed up selector parsing: \ + {:?} at offset {:?}: {:?}", + invalidation.selector, + next_combinator_offset, + pseudo_selector, + ) + } }; // FIXME(emilio): This is not ideal, and could not be