Fix the handling of the Bloom filter in the style sharing cache.

This commit is contained in:
Boris Zbarsky 2017-06-01 23:30:26 -04:00
parent a36edb9970
commit 98f95a32da
5 changed files with 61 additions and 27 deletions

View file

@ -799,19 +799,6 @@ fn compute_style<E, D>(_traversal: &D,
context.thread_local.statistics.elements_styled += 1;
let kind = data.restyle_kind();
// First, try the style sharing cache. If we get a match we can skip the rest
// of the work.
if let MatchAndCascade = kind {
let target = StyleSharingTarget::new(element);
let sharing_result = target.share_style_if_possible(context, data);
if let StyleWasShared(index, had_damage) = sharing_result {
context.thread_local.statistics.styles_shared += 1;
context.thread_local.style_sharing_candidate_cache.touch(index);
return had_damage;
}
}
match kind {
MatchAndCascade => {
// Ensure the bloom filter is up to date.
@ -820,6 +807,18 @@ fn compute_style<E, D>(_traversal: &D,
traversal_data.current_dom_depth);
context.thread_local.bloom_filter.assert_complete(element);
// Now that our bloom filter is set up, try the style sharing
// cache. If we get a match we can skip the rest of the work.
let target = StyleSharingTarget::new(element);
let sharing_result = target.share_style_if_possible(context, data);
if let StyleWasShared(index, had_damage) = sharing_result {
context.thread_local.statistics.styles_shared += 1;
context.thread_local.style_sharing_candidate_cache.touch(index);
return had_damage;
}
context.thread_local.statistics.elements_matched += 1;
// Perform the matching and cascading.