Auto merge of #16985 - emilio:cache, r=bholley

layout: Stop mutating the style data from layout.

This is part of #16982.

Right now we have some code that tries to cache stuff in the style data during
layout.

This code is extremely rarely executed, only for `<details>` and `<summary>`.

I think if we really really want to cache these, we should find a place in the
layout data for it.

For now, let's move it away (and all the other layout code) from mutating the
style data from layout.

<!-- 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/16985)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-05-23 06:35:16 -05:00 committed by GitHub
commit 84c1f904cb
3 changed files with 32 additions and 60 deletions

View file

@ -12,9 +12,7 @@ use restyle_hints::{HintComputationContext, RestyleReplacements, RestyleHint};
use rule_tree::StrongRuleNode;
use selector_parser::{EAGER_PSEUDO_COUNT, PseudoElement, RestyleDamage};
use shared_lock::StylesheetGuards;
#[cfg(feature = "servo")] use std::collections::HashMap;
use std::fmt;
#[cfg(feature = "servo")] use std::hash::BuildHasherDefault;
use stylearc::Arc;
use traversal::TraversalFlags;
@ -145,14 +143,6 @@ impl EagerPseudoStyles {
}
}
/// A cache of precomputed and lazy pseudo-elements, used by servo. This isn't
/// a very efficient design, but is the result of servo having previously used
/// the eager pseudo map (when it was a map) for this cache.
#[cfg(feature = "servo")]
type PseudoElementCache = HashMap<PseudoElement, ComputedStyle, BuildHasherDefault<::fnv::FnvHasher>>;
#[cfg(feature = "gecko")]
type PseudoElementCache = ();
/// The styles associated with a node, including the styles for any
/// pseudo-elements.
#[derive(Clone, Debug)]
@ -161,8 +151,6 @@ pub struct ElementStyles {
pub primary: ComputedStyle,
/// A list of the styles for the element's eagerly-cascaded pseudo-elements.
pub pseudos: EagerPseudoStyles,
/// NB: This is an empty field for gecko.
pub cached_pseudos: PseudoElementCache,
}
impl ElementStyles {
@ -171,7 +159,6 @@ impl ElementStyles {
ElementStyles {
primary: primary,
pseudos: EagerPseudoStyles(None),
cached_pseudos: PseudoElementCache::default(),
}
}