servo: Merge #18158 - style: Skip state pseudo-classes when finding a pseudo-element (from emilio:pseudo-crash); r=heycam

Bug: 1391577
Reviewed-by: heycam
MozReview-Commit-ID: 1ICBijtcf2b
Source-Repo: https://github.com/servo/servo
Source-Revision: 4f3fb904ae6863aa86bb3c8b7abee5533478af13

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 7158d74b7fcc082a2086e639df09b0bf83175977
This commit is contained in:
Emilio Cobos Álvarez 2017-08-20 02:14:08 -05:00
Родитель 019a8f16fa
Коммит caf5d52435
1 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -595,14 +595,27 @@ impl<'a, 'b: 'a, E> TreeStyleInvalidator<'a, 'b, E>
matched = true; matched = true;
if matches!(next_combinator, Combinator::PseudoElement) { 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 = let pseudo_selector =
invalidation.selector invalidation.selector
.iter_raw_parse_order_from(next_combinator_offset - 1) .iter_raw_parse_order_from(next_combinator_offset - 1)
.skip_while(|c| matches!(**c, Component::NonTSPseudoClass(..)))
.next() .next()
.unwrap(); .unwrap();
let pseudo = match *pseudo_selector { let pseudo = match *pseudo_selector {
Component::PseudoElement(ref pseudo) => pseudo, 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 // FIXME(emilio): This is not ideal, and could not be