mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Use a rule hash for revalidation selectors.
MozReview-Commit-ID: 1mTZcfMxaw8
This commit is contained in:
parent
a6fe7bea5e
commit
1fb9108daf
1 changed files with 18 additions and 15 deletions
|
@ -117,7 +117,7 @@ pub struct Stylist {
|
||||||
/// on state that is not otherwise visible to the cache, like attributes or
|
/// on state that is not otherwise visible to the cache, like attributes or
|
||||||
/// tree-structural state like child index and pseudos).
|
/// tree-structural state like child index and pseudos).
|
||||||
#[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")]
|
#[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")]
|
||||||
selectors_for_cache_revalidation: Vec<SelectorInner<SelectorImpl>>,
|
selectors_for_cache_revalidation: SelectorMap<SelectorInner<SelectorImpl>>,
|
||||||
|
|
||||||
/// The total number of selectors.
|
/// The total number of selectors.
|
||||||
num_selectors: usize,
|
num_selectors: usize,
|
||||||
|
@ -177,7 +177,7 @@ impl Stylist {
|
||||||
rules_source_order: 0,
|
rules_source_order: 0,
|
||||||
rule_tree: RuleTree::new(),
|
rule_tree: RuleTree::new(),
|
||||||
dependencies: DependencySet::new(),
|
dependencies: DependencySet::new(),
|
||||||
selectors_for_cache_revalidation: vec![],
|
selectors_for_cache_revalidation: SelectorMap::new(),
|
||||||
num_selectors: 0,
|
num_selectors: 0,
|
||||||
num_declarations: 0,
|
num_declarations: 0,
|
||||||
num_rebuilds: 0,
|
num_rebuilds: 0,
|
||||||
|
@ -260,7 +260,7 @@ impl Stylist {
|
||||||
self.rules_source_order = 0;
|
self.rules_source_order = 0;
|
||||||
self.dependencies.clear();
|
self.dependencies.clear();
|
||||||
self.animations.clear();
|
self.animations.clear();
|
||||||
self.selectors_for_cache_revalidation.clear();
|
self.selectors_for_cache_revalidation = SelectorMap::new();
|
||||||
self.num_selectors = 0;
|
self.num_selectors = 0;
|
||||||
self.num_declarations = 0;
|
self.num_declarations = 0;
|
||||||
|
|
||||||
|
@ -376,7 +376,7 @@ impl Stylist {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn note_for_revalidation(&mut self, selector: &Selector<SelectorImpl>) {
|
fn note_for_revalidation(&mut self, selector: &Selector<SelectorImpl>) {
|
||||||
if needs_revalidation(selector) {
|
if needs_revalidation(selector) {
|
||||||
self.selectors_for_cache_revalidation.push(selector.inner.clone());
|
self.selectors_for_cache_revalidation.insert(selector.inner.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -847,17 +847,20 @@ impl Stylist {
|
||||||
use selectors::matching::StyleRelations;
|
use selectors::matching::StyleRelations;
|
||||||
use selectors::matching::matches_selector;
|
use selectors::matching::matches_selector;
|
||||||
|
|
||||||
let len = self.selectors_for_cache_revalidation.len();
|
// Note that, by the time we're revalidating, we're guaranteed that the
|
||||||
let mut results = BitVec::from_elem(len, false);
|
// candidate and the entry have the same id, classes, and local name.
|
||||||
|
// This means we're guaranteed to get the same rulehash buckets for all
|
||||||
for (i, ref selector) in self.selectors_for_cache_revalidation
|
// the lookups, which means that the bitvecs are comparable. We verify
|
||||||
.iter().enumerate() {
|
// this in the caller by asserting that the bitvecs are same-length.
|
||||||
results.set(i, matches_selector(selector,
|
let mut results = BitVec::new();
|
||||||
element,
|
self.selectors_for_cache_revalidation.lookup(*element, &mut |selector| {
|
||||||
Some(bloom),
|
results.push(matches_selector(selector,
|
||||||
&mut StyleRelations::empty(),
|
element,
|
||||||
flags_setter));
|
Some(bloom),
|
||||||
}
|
&mut StyleRelations::empty(),
|
||||||
|
flags_setter));
|
||||||
|
true
|
||||||
|
});
|
||||||
|
|
||||||
results
|
results
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue