Concurrent rule tree, v1

This patch introduces infrastructure for the rule tree, and constructs it.

We don't use it yet, nor have good heuristics for GC'ing it, but this should not
happen anymore once we store the rule node reference in the node.

I haven't messed up with memory orders because I want to do a try run with it,
then mess with them.

Take down the ApplicableDeclarationsCache, use the rule tree for doing the cascade.
This commit is contained in:
Emilio Cobos Álvarez 2016-09-06 11:13:50 +08:00 committed by Simon Sapin
parent f7875dad1a
commit de4fe6e2b6
22 changed files with 1067 additions and 552 deletions

View file

@ -5,6 +5,7 @@
//! Per-node data used in style calculation.
use properties::ComputedValues;
use rule_tree::StrongRuleNode;
use selector_impl::PseudoElement;
use std::collections::HashMap;
use std::hash::BuildHasherDefault;
@ -12,7 +13,7 @@ use std::mem;
use std::ops::{Deref, DerefMut};
use std::sync::Arc;
type PseudoStylesInner = HashMap<PseudoElement, Arc<ComputedValues>,
type PseudoStylesInner = HashMap<PseudoElement, (Arc<ComputedValues>, StrongRuleNode),
BuildHasherDefault<::fnv::FnvHasher>>;
#[derive(Clone, Debug)]
pub struct PseudoStyles(PseudoStylesInner);
@ -39,14 +40,18 @@ pub struct ElementStyles {
/// The results of CSS styling for this node.
pub primary: Arc<ComputedValues>,
/// The rule node representing the last rule matched for this node.
pub rule_node: StrongRuleNode,
/// The results of CSS styling for each pseudo-element (if any).
pub pseudos: PseudoStyles,
}
impl ElementStyles {
pub fn new(primary: Arc<ComputedValues>) -> Self {
pub fn new(primary: Arc<ComputedValues>, rule_node: StrongRuleNode) -> Self {
ElementStyles {
primary: primary,
rule_node: rule_node,
pseudos: PseudoStyles::empty(),
}
}
@ -185,11 +190,6 @@ impl ElementData {
}
}
pub fn style_text_node(&mut self, style: Arc<ComputedValues>) {
self.styles = ElementDataStyles::Current(ElementStyles::new(style));
self.restyle_data = None;
}
pub fn finish_styling(&mut self, styles: ElementStyles) {
debug_assert!(self.styles.is_previous());
self.styles = ElementDataStyles::Current(styles);