Bug 1544242 - Check iterator length in SelectorIter::is_featureless_host_selector. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 29 Apr 2019 05:58:56 +0000
changeset 534017 961d9f01940bcf4b435f5ac62ec56b2b99862522
parent 534016 7abb70ddfaf322e125cd5dd53fd3d242928d5a52
child 534018 0e33c9c98d2c75fa62d4606feec22c5db6302779
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1544242
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1544242 - Check iterator length in SelectorIter::is_featureless_host_selector. r=heycam I'm going to unconditionally generate the PseudoElement combinator, and this causes issues since we'll put the raw `::pseudo` selectors in the host bucket, which is obviously wrong. Differential Revision: https://phabricator.services.mozilla.com/D27528
servo/components/selectors/parser.rs
--- a/servo/components/selectors/parser.rs
+++ b/servo/components/selectors/parser.rs
@@ -731,17 +731,18 @@ impl<'a, Impl: 'a + SelectorImpl> Select
     pub fn next_sequence(&mut self) -> Option<Combinator> {
         self.next_combinator.take()
     }
 
     /// Whether this selector is a featureless host selector, with no
     /// combinators to the left.
     #[inline]
     pub(crate) fn is_featureless_host_selector(&mut self) -> bool {
-        self.all(|component| matches!(*component, Component::Host(..))) &&
+        self.selector_length() > 0 &&
+            self.all(|component| matches!(*component, Component::Host(..))) &&
             self.next_sequence().is_none()
     }
 
     /// Returns remaining count of the simple selectors and combinators in the Selector.
     #[inline]
     pub fn selector_length(&self) -> usize {
         self.iter.len()
     }