mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Share styles during recascades.
MozReview-Commit-ID: AFTwtzi4P93
This commit is contained in:
parent
1c9b39a8e8
commit
8e5c1c771e
2 changed files with 35 additions and 16 deletions
|
@ -430,11 +430,16 @@ impl<Candidate> SharingCacheBase<Candidate> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: TElement> SharingCache<E> {
|
impl<E: TElement> SharingCache<E> {
|
||||||
fn insert(&mut self, el: E, validation_data_holder: &mut StyleSharingTarget<E>) {
|
fn insert(
|
||||||
self.entries.insert(StyleSharingCandidate {
|
&mut self,
|
||||||
element: el,
|
element: E,
|
||||||
validation_data: validation_data_holder.take_validation_data(),
|
validation_data_holder: Option<&mut StyleSharingTarget<E>>,
|
||||||
});
|
) {
|
||||||
|
let validation_data = match validation_data_holder {
|
||||||
|
Some(v) => v.take_validation_data(),
|
||||||
|
None => ValidationData::default(),
|
||||||
|
};
|
||||||
|
self.entries.insert(StyleSharingCandidate { element, validation_data });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lookup<F>(&mut self, mut is_match: F) -> Option<E>
|
fn lookup<F>(&mut self, mut is_match: F) -> Option<E>
|
||||||
|
@ -544,7 +549,7 @@ impl<E: TElement> StyleSharingCache<E> {
|
||||||
pub fn insert_if_possible(&mut self,
|
pub fn insert_if_possible(&mut self,
|
||||||
element: &E,
|
element: &E,
|
||||||
style: &ComputedValues,
|
style: &ComputedValues,
|
||||||
validation_data_holder: &mut StyleSharingTarget<E>,
|
validation_data_holder: Option<&mut StyleSharingTarget<E>>,
|
||||||
dom_depth: usize) {
|
dom_depth: usize) {
|
||||||
let parent = match element.traversal_parent() {
|
let parent = match element.traversal_parent() {
|
||||||
Some(element) => element,
|
Some(element) => element,
|
||||||
|
|
|
@ -646,6 +646,10 @@ where
|
||||||
traversal_data.current_dom_depth);
|
traversal_data.current_dom_depth);
|
||||||
|
|
||||||
context.thread_local.bloom_filter.assert_complete(element);
|
context.thread_local.bloom_filter.assert_complete(element);
|
||||||
|
debug_assert_eq!(
|
||||||
|
context.thread_local.bloom_filter.matching_depth(),
|
||||||
|
traversal_data.current_dom_depth
|
||||||
|
);
|
||||||
|
|
||||||
// This is only relevant for animations as of right now.
|
// This is only relevant for animations as of right now.
|
||||||
important_rules_changed = true;
|
important_rules_changed = true;
|
||||||
|
@ -679,8 +683,8 @@ where
|
||||||
.insert_if_possible(
|
.insert_if_possible(
|
||||||
&element,
|
&element,
|
||||||
new_styles.primary.style(),
|
new_styles.primary.style(),
|
||||||
&mut target,
|
Some(&mut target),
|
||||||
context.thread_local.bloom_filter.matching_depth(),
|
traversal_data.current_dom_depth,
|
||||||
);
|
);
|
||||||
|
|
||||||
new_styles
|
new_styles
|
||||||
|
@ -709,6 +713,7 @@ where
|
||||||
let cascade_inputs =
|
let cascade_inputs =
|
||||||
ElementCascadeInputs::new_from_element_data(data);
|
ElementCascadeInputs::new_from_element_data(data);
|
||||||
|
|
||||||
|
let new_styles = {
|
||||||
let mut resolver =
|
let mut resolver =
|
||||||
StyleResolverForElement::new(
|
StyleResolverForElement::new(
|
||||||
element,
|
element,
|
||||||
|
@ -718,6 +723,15 @@ 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(
|
||||||
|
&element,
|
||||||
|
new_styles.primary.style(),
|
||||||
|
None,
|
||||||
|
traversal_data.current_dom_depth,
|
||||||
|
);
|
||||||
|
|
||||||
|
new_styles
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue