mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +01:00
Auto merge of #18497 - emilio:no-cache-if-cached, r=heycam
style: Don't cache styles that got a cache hit on the second pass. This avoids doing wasted work, at least in the recascade case, and pretty likely in the other as well. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18497) <!-- Reviewable:end -->
This commit is contained in:
commit
988728e9d5
2 changed files with 22 additions and 15 deletions
|
@ -82,6 +82,7 @@ use smallvec::SmallVec;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
use style_resolver::PrimaryStyle;
|
||||||
use stylist::Stylist;
|
use stylist::Stylist;
|
||||||
|
|
||||||
mod checks;
|
mod checks;
|
||||||
|
@ -546,11 +547,18 @@ impl<E: TElement> StyleSharingCache<E> {
|
||||||
///
|
///
|
||||||
/// NB: We pass a source for the validation data, rather than the data itself,
|
/// NB: We pass a source for the validation data, rather than the data itself,
|
||||||
/// to avoid memmoving at each function call. See rust issue #42763.
|
/// to avoid memmoving at each function call. See rust issue #42763.
|
||||||
pub fn insert_if_possible(&mut self,
|
pub fn insert_if_possible(
|
||||||
element: &E,
|
&mut self,
|
||||||
style: &ComputedValues,
|
element: &E,
|
||||||
validation_data_holder: Option<&mut StyleSharingTarget<E>>,
|
style: &PrimaryStyle,
|
||||||
dom_depth: usize) {
|
validation_data_holder: Option<&mut StyleSharingTarget<E>>,
|
||||||
|
dom_depth: usize,
|
||||||
|
) {
|
||||||
|
if style.0.reused_via_rule_node {
|
||||||
|
debug!("Failing to insert into the cached: this was a cached style");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let parent = match element.traversal_parent() {
|
let parent = match element.traversal_parent() {
|
||||||
Some(element) => element,
|
Some(element) => element,
|
||||||
None => {
|
None => {
|
||||||
|
@ -583,7 +591,7 @@ impl<E: TElement> StyleSharingCache<E> {
|
||||||
//
|
//
|
||||||
// These are things we don't check in the candidate match because they
|
// These are things we don't check in the candidate match because they
|
||||||
// are either uncommon or expensive.
|
// are either uncommon or expensive.
|
||||||
let box_style = style.get_box();
|
let box_style = style.style().get_box();
|
||||||
if box_style.specifies_transitions() {
|
if box_style.specifies_transitions() {
|
||||||
debug!("Failing to insert to the cache: transitions");
|
debug!("Failing to insert to the cache: transitions");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -678,14 +678,12 @@ where
|
||||||
resolver.resolve_style_with_default_parents()
|
resolver.resolve_style_with_default_parents()
|
||||||
};
|
};
|
||||||
|
|
||||||
context.thread_local
|
context.thread_local.sharing_cache.insert_if_possible(
|
||||||
.sharing_cache
|
&element,
|
||||||
.insert_if_possible(
|
&new_styles.primary,
|
||||||
&element,
|
Some(&mut target),
|
||||||
new_styles.primary.style(),
|
traversal_data.current_dom_depth,
|
||||||
Some(&mut target),
|
);
|
||||||
traversal_data.current_dom_depth,
|
|
||||||
);
|
|
||||||
|
|
||||||
new_styles
|
new_styles
|
||||||
}
|
}
|
||||||
|
@ -724,9 +722,10 @@ where
|
||||||
|
|
||||||
resolver.cascade_styles_with_default_parents(cascade_inputs)
|
resolver.cascade_styles_with_default_parents(cascade_inputs)
|
||||||
};
|
};
|
||||||
|
|
||||||
context.thread_local.sharing_cache.insert_if_possible(
|
context.thread_local.sharing_cache.insert_if_possible(
|
||||||
&element,
|
&element,
|
||||||
new_styles.primary.style(),
|
&new_styles.primary,
|
||||||
None,
|
None,
|
||||||
traversal_data.current_dom_depth,
|
traversal_data.current_dom_depth,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue