Move match and cascade temporaries to CurrentElementInfo

Before this change, the `ComputedStyle` struct that is part of permanent style
data per element holds 2 `StrongRuleNode`s (unvisited and visited) and 2
`Arc<ComputedValues>` (unvisited and visited).

Both rule nodes and the visited values don't actually need to be here.  This
patch moves these 3 to new temporary storage in `CascadeInputs` on
`CurrentElementInfo` during the match and cascade process.  Rule nodes are
pushed down inside the `ComputedValues` for later access after the cascade.
(Visited values were already available there.)

The permanent style data per element now has just the `Arc<ComputedValues>` for
itself and eager pseudo-elements (plus the `RestyleHint`).

MozReview-Commit-ID: 3wq52ERMpdi
This commit is contained in:
J. Ryan Stinnett 2017-06-13 12:51:37 -05:00
parent c3b2a2f4de
commit 2b5c56e6a8
19 changed files with 738 additions and 746 deletions

View file

@ -362,7 +362,7 @@ impl<E: TElement> StyleSharingTarget<E> {
fn accumulate_damage_when_sharing(&self,
shared_context: &SharedStyleContext,
shared_style: &ElementStyles,
shared_styles: &ElementStyles,
data: &mut ElementData) -> ChildCascadeRequirement {
// Accumulate restyle damage for the case when our sharing
// target managed to share style. This can come from several
@ -379,7 +379,7 @@ impl<E: TElement> StyleSharingTarget<E> {
// pseudos being restyled.
let (styles, mut restyle_data) = data.styles_and_restyle_mut();
let old_pseudos = &styles.pseudos;
let new_pseudos = &shared_style.pseudos;
let new_pseudos = &shared_styles.pseudos;
if !old_pseudos.has_same_pseudos_as(new_pseudos) {
restyle_data.damage |= RestyleDamage::reconstruct();
@ -389,9 +389,9 @@ impl<E: TElement> StyleSharingTarget<E> {
// here....
for pseudo in old_pseudos.keys() {
let old_values =
old_pseudos.get(&pseudo).unwrap().values.as_ref().map(|v| &**v);
old_pseudos.get(&pseudo).map(|v| &**v);
let new_values =
new_pseudos.get(&pseudo).unwrap().values();
new_pseudos.get(&pseudo).unwrap();
self.element.accumulate_damage(
&shared_context,
restyle_data,
@ -403,14 +403,12 @@ impl<E: TElement> StyleSharingTarget<E> {
}
}
let old_values =
data.get_styles_mut().and_then(|s| s.primary.values.take());
let old_values = data.styles.primary.take();
self.element.accumulate_damage(
&shared_context,
&mut data.restyle,
old_values.as_ref().map(|v| &**v),
shared_style.primary.values(),
shared_styles.primary(),
None
)
}
@ -595,13 +593,13 @@ impl<E: TElement> StyleSharingCandidateCache<E> {
);
match sharing_result {
Ok(shared_style) => {
Ok(shared_styles) => {
// Yay, cache hit. Share the style.
let child_cascade_requirement =
target.accumulate_damage_when_sharing(shared_context,
&shared_style,
&shared_styles,
data);
data.set_styles(shared_style);
data.styles = shared_styles;
return StyleSharingResult::StyleWasShared(i, child_cascade_requirement)
}
@ -708,6 +706,6 @@ impl<E: TElement> StyleSharingCandidateCache<E> {
debug!("Sharing style between {:?} and {:?}",
target.element, candidate.element);
Ok(data.styles().clone())
Ok(data.styles.clone())
}
}