Bug 1382812: Don't track ancestor hashes in quirks mode. r?bholley draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 20 Jul 2017 22:10:22 +0200
changeset 612557 821e438f56f71721219b1cabbe8fe738b9c5cb7a
parent 612553 1381fcf9afa191a70670cd673a03d05c6b4a5f5e
child 638441 d7d42b40cdde8b506a5275f37cdb10ea2f58d2e5
push id69532
push userbmo:emilio+bugs@crisal.io
push dateThu, 20 Jul 2017 20:16:20 +0000
reviewersbholley
bugs1382812
milestone56.0a1
Bug 1382812: Don't track ancestor hashes in quirks mode. r?bholley This is the simplest patch. We still maintain the bloom filter, but I think it's not worth caring about that. MozReview-Commit-ID: 4uvrfYsWb1v
servo/components/selectors/parser.rs
servo/components/style/stylist.rs
--- a/servo/components/selectors/parser.rs
+++ b/servo/components/selectors/parser.rs
@@ -213,16 +213,22 @@ impl<Impl: SelectorImpl> SelectorList<Im
 /// complicated to assemble, because we often bail out before checking all the
 /// hashes.
 #[derive(Eq, PartialEq, Clone, Debug)]
 pub struct AncestorHashes {
     pub packed_hashes: [u32; 3],
 }
 
 impl AncestorHashes {
+    pub fn empty() -> Self {
+        Self {
+            packed_hashes: [0; 3],
+        }
+    }
+
     pub fn new<Impl: SelectorImpl>(s: &Selector<Impl>) -> Self {
         Self::from_iter(s.iter())
     }
 
     pub fn from_iter<Impl: SelectorImpl>(iter: SelectorIter<Impl>) -> Self {
         // Compute ancestor hashes for the bloom filter.
         let mut hashes = [0u32; 4];
         let mut hash_iter = AncestorIter::new(iter)
--- a/servo/components/style/stylist.rs
+++ b/servo/components/style/stylist.rs
@@ -485,17 +485,25 @@ impl Stylist {
                             self.pseudos_map
                                 .entry(pseudo.canonical())
                                 .or_insert_with(PerPseudoElementSelectorMap::new)
                                 .borrow_for_origin(&origin)
                         } else {
                             self.element_map.borrow_for_origin(&origin)
                         };
 
-                        let hashes = AncestorHashes::new(&selector);
+                        // In quirks mode, we don't keep track of the selector
+                        // hashes, because they'd need to match in a
+                        // case-sensitive way.
+                        let hashes = if self.quirks_mode == QuirksMode::Quirks {
+                            AncestorHashes::empty()
+                        } else {
+                            AncestorHashes::new(&selector)
+                        };
+
                         map.insert(
                             Rule::new(selector.clone(),
                                       hashes.clone(),
                                       locked.clone(),
                                       self.rules_source_order),
                             self.quirks_mode);
 
                         self.invalidation_map.note_selector(selector, self.quirks_mode);