mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
style: Don't use the current element info for cached validation data.
We can take it straight from the validation target.
This commit is contained in:
parent
36310e3b66
commit
62310d9bd5
3 changed files with 15 additions and 34 deletions
|
@ -21,7 +21,7 @@ use rule_tree::StrongRuleNode;
|
||||||
use selector_parser::{EAGER_PSEUDO_COUNT, SnapshotMap};
|
use selector_parser::{EAGER_PSEUDO_COUNT, SnapshotMap};
|
||||||
use selectors::matching::ElementSelectorFlags;
|
use selectors::matching::ElementSelectorFlags;
|
||||||
use shared_lock::StylesheetGuards;
|
use shared_lock::StylesheetGuards;
|
||||||
use sharing::{ValidationData, StyleSharingCandidateCache};
|
use sharing::StyleSharingCandidateCache;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
#[cfg(feature = "servo")] use std::sync::Mutex;
|
#[cfg(feature = "servo")] use std::sync::Mutex;
|
||||||
|
@ -269,8 +269,6 @@ pub struct CurrentElementInfo {
|
||||||
element: OpaqueNode,
|
element: OpaqueNode,
|
||||||
/// Whether the element is being styled for the first time.
|
/// Whether the element is being styled for the first time.
|
||||||
is_initial_style: bool,
|
is_initial_style: bool,
|
||||||
/// Lazy cache of the different data used for style sharing.
|
|
||||||
pub validation_data: ValidationData,
|
|
||||||
/// A Vec of possibly expired animations. Used only by Servo.
|
/// A Vec of possibly expired animations. Used only by Servo.
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub possibly_expired_animations: Vec<PropertyAnimation>,
|
pub possibly_expired_animations: Vec<PropertyAnimation>,
|
||||||
|
@ -575,7 +573,6 @@ impl<E: TElement> ThreadLocalStyleContext<E> {
|
||||||
self.current_element_info = Some(CurrentElementInfo {
|
self.current_element_info = Some(CurrentElementInfo {
|
||||||
element: element.as_node().opaque(),
|
element: element.as_node().opaque(),
|
||||||
is_initial_style: !data.has_styles(),
|
is_initial_style: !data.has_styles(),
|
||||||
validation_data: ValidationData::default(),
|
|
||||||
possibly_expired_animations: Vec::new(),
|
possibly_expired_animations: Vec::new(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,7 +328,7 @@ impl<E: TElement> StyleSharingTarget<E> {
|
||||||
|
|
||||||
/// Attempts to share a style with another node.
|
/// Attempts to share a style with another node.
|
||||||
pub fn share_style_if_possible(
|
pub fn share_style_if_possible(
|
||||||
mut self,
|
&mut self,
|
||||||
context: &mut StyleContext<E>,
|
context: &mut StyleContext<E>,
|
||||||
) -> StyleSharingResult {
|
) -> StyleSharingResult {
|
||||||
let cache = &mut context.thread_local.style_sharing_candidate_cache;
|
let cache = &mut context.thread_local.style_sharing_candidate_cache;
|
||||||
|
@ -344,17 +344,17 @@ impl<E: TElement> StyleSharingTarget<E> {
|
||||||
debug_assert_eq!(bloom_filter.current_parent(),
|
debug_assert_eq!(bloom_filter.current_parent(),
|
||||||
self.element.traversal_parent());
|
self.element.traversal_parent());
|
||||||
|
|
||||||
let result =
|
cache.share_style_if_possible(
|
||||||
cache.share_style_if_possible(
|
shared_context,
|
||||||
shared_context,
|
selector_flags_map,
|
||||||
selector_flags_map,
|
bloom_filter,
|
||||||
bloom_filter,
|
self
|
||||||
&mut self
|
)
|
||||||
);
|
}
|
||||||
|
|
||||||
context.thread_local.current_element_info.as_mut().unwrap().validation_data =
|
/// Gets the validation data used to match against this target, if any.
|
||||||
self.validation_data.take();
|
pub fn take_validation_data(&mut self) -> ValidationData {
|
||||||
result
|
self.validation_data.take()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -777,7 +777,7 @@ where
|
||||||
// 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;
|
||||||
|
|
||||||
let target = StyleSharingTarget::new(element);
|
let mut target = StyleSharingTarget::new(element);
|
||||||
match target.share_style_if_possible(context) {
|
match target.share_style_if_possible(context) {
|
||||||
StyleWasShared(index, styles) => {
|
StyleWasShared(index, styles) => {
|
||||||
context.thread_local.statistics.styles_shared += 1;
|
context.thread_local.statistics.styles_shared += 1;
|
||||||
|
@ -791,29 +791,13 @@ where
|
||||||
StyleResolverForElement::new(element, context, RuleInclusion::All)
|
StyleResolverForElement::new(element, context, RuleInclusion::All)
|
||||||
.resolve_style_with_default_parents();
|
.resolve_style_with_default_parents();
|
||||||
|
|
||||||
// If we previously tried to match this element against the
|
|
||||||
// cache, the revalidation match results will already be
|
|
||||||
// cached. Otherwise we'll have None, and compute them later
|
|
||||||
// on-demand.
|
|
||||||
//
|
|
||||||
// If we do have the results, grab them here to satisfy the
|
|
||||||
// borrow checker.
|
|
||||||
let validation_data =
|
|
||||||
context.thread_local
|
|
||||||
.current_element_info
|
|
||||||
.as_mut().unwrap()
|
|
||||||
.validation_data
|
|
||||||
.take();
|
|
||||||
|
|
||||||
let dom_depth =
|
|
||||||
context.thread_local.bloom_filter.matching_depth();
|
|
||||||
context.thread_local
|
context.thread_local
|
||||||
.style_sharing_candidate_cache
|
.style_sharing_candidate_cache
|
||||||
.insert_if_possible(
|
.insert_if_possible(
|
||||||
&element,
|
&element,
|
||||||
new_styles.primary(),
|
new_styles.primary(),
|
||||||
validation_data,
|
target.take_validation_data(),
|
||||||
dom_depth
|
context.thread_local.bloom_filter.matching_depth(),
|
||||||
);
|
);
|
||||||
|
|
||||||
new_styles
|
new_styles
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue