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

@ -7,6 +7,7 @@
use Atom;
use bezier::Bezier;
use context::SharedStyleContext;
use declarations_iterators::RawDeclarationsIterator;
use dom::{OpaqueNode, UnsafeNode};
use euclid::point::Point2D;
use keyframes::{KeyframesStep, KeyframesStepValue};
@ -17,7 +18,6 @@ use properties::longhands::animation_iteration_count::computed_value::AnimationI
use properties::longhands::animation_play_state::computed_value::AnimationPlayState;
use properties::longhands::transition_timing_function::computed_value::StartEnd;
use properties::longhands::transition_timing_function::computed_value::TransitionTimingFunction;
use selector_matching::ApplicableDeclarationBlock;
use std::sync::Arc;
use std::sync::mpsc::Sender;
use timer::Timer;
@ -385,23 +385,24 @@ fn compute_style_for_animation_step(context: &SharedStyleContext,
style_from_cascade: &ComputedValues)
-> ComputedValues {
match step.value {
// TODO: avoiding this spurious clone might involve having to create
// an Arc in the below (more common case).
KeyframesStepValue::ComputedValues => style_from_cascade.clone(),
KeyframesStepValue::Declarations { block: ref declarations } => {
let declaration_block = ApplicableDeclarationBlock {
mixed_declarations: declarations.clone(),
importance: Importance::Normal,
source_order: 0,
specificity: ::std::u32::MAX,
};
let (computed, _) = properties::cascade(context.viewport_size,
&[declaration_block],
Some(previous_style),
None,
None,
context.error_reporter.clone(),
CascadeFlags::empty());
let guard = declarations.read();
// No !important in keyframes.
debug_assert!(guard.declarations.iter()
.all(|&(_, importance)| importance == Importance::Normal));
let iter = RawDeclarationsIterator::new(&guard.declarations);
let computed =
properties::apply_declarations(context.viewport_size,
/* is_root = */ false,
iter,
previous_style,
/* cascade_info = */ None,
context.error_reporter.clone(),
CascadeFlags::empty());
computed
}
}