style: Move the check into insert_if_possible.

This commit is contained in:
Emilio Cobos Álvarez 2017-09-14 11:56:45 +02:00
parent 2908c6a266
commit 158aa0ffdf
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 20 additions and 18 deletions

View file

@ -82,6 +82,7 @@ use smallvec::SmallVec;
use std::marker::PhantomData;
use std::mem;
use std::ops::Deref;
use style_resolver::PrimaryStyle;
use stylist::Stylist;
mod checks;
@ -549,10 +550,15 @@ impl<E: TElement> StyleSharingCache<E> {
pub fn insert_if_possible(
&mut self,
element: &E,
style: &ComputedValues,
style: &PrimaryStyle,
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() {
Some(element) => element,
None => {
@ -585,7 +591,7 @@ impl<E: TElement> StyleSharingCache<E> {
//
// These are things we don't check in the candidate match because they
// are either uncommon or expensive.
let box_style = style.get_box();
let box_style = style.style().get_box();
if box_style.specifies_transitions() {
debug!("Failing to insert to the cache: transitions");
return;

View file

@ -678,14 +678,12 @@ where
resolver.resolve_style_with_default_parents()
};
if !new_styles.primary.0.reused_via_rule_node {
context.thread_local.sharing_cache.insert_if_possible(
&element,
new_styles.primary.style(),
Some(&mut target),
traversal_data.current_dom_depth,
);
}
context.thread_local.sharing_cache.insert_if_possible(
&element,
&new_styles.primary,
Some(&mut target),
traversal_data.current_dom_depth,
);
new_styles
}
@ -725,14 +723,12 @@ where
resolver.cascade_styles_with_default_parents(cascade_inputs)
};
if !new_styles.primary.0.reused_via_rule_node {
context.thread_local.sharing_cache.insert_if_possible(
&element,
new_styles.primary.style(),
None,
traversal_data.current_dom_depth,
);
}
context.thread_local.sharing_cache.insert_if_possible(
&element,
&new_styles.primary,
None,
traversal_data.current_dom_depth,
);
new_styles
}