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
--- 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);