Cache animation computed values when animations change

Instead of recalculating the animation style every tick of an animation,
cache the computed values when animations change. In addition to being
more efficient, this will allow us to return animation rules as property
declarations because we don't need to consult the final style to produce
them.
This commit is contained in:
Martin Robinson 2020-05-18 16:32:41 +02:00
parent 7df4655b60
commit 83fa1b9eaa
9 changed files with 246 additions and 169 deletions

View file

@ -574,7 +574,13 @@ impl LayoutThread {
origin: ImmutableOrigin,
animation_timeline_value: f64,
animation_states: ServoArc<RwLock<FxHashMap<OpaqueNode, ElementAnimationSet>>>,
stylesheets_changed: bool,
) -> LayoutContext<'a> {
let traversal_flags = match stylesheets_changed {
true => TraversalFlags::ForCSSRuleChanges,
false => TraversalFlags::empty(),
};
LayoutContext {
id: self.id,
origin,
@ -586,7 +592,7 @@ impl LayoutThread {
animation_states,
registered_speculative_painters: &self.registered_painters,
current_time_for_animations: animation_timeline_value,
traversal_flags: TraversalFlags::empty(),
traversal_flags,
snapshot_map: snapshot_map,
},
image_cache: self.image_cache.clone(),
@ -1064,6 +1070,7 @@ impl LayoutThread {
origin,
data.animation_timeline_value,
data.animations.clone(),
data.stylesheets_changed,
);
let dirty_root = unsafe {