Split animation cancellation from update_style_for_animation

`update_style_for_animation` previously handled both canceling defunct
animations and also updating style to reflect current animation state.
This change splits those two concerns because we want to start handling
replaced or canceled animations and finished animations in two different
places.

This is a refactor, so ideally it shouldn't change any behavior.
This commit is contained in:
Martin Robinson 2020-04-30 10:59:56 +02:00
parent 3bedd44026
commit 0ab4260d6b
3 changed files with 128 additions and 121 deletions

View file

@ -7,8 +7,6 @@
#![allow(unsafe_code)]
#![deny(missing_docs)]
#[cfg(feature = "servo")]
use crate::animation;
use crate::computed_value_flags::ComputedValueFlags;
use crate::context::{ElementCascadeInputs, QuirksMode, SelectorFlagsMap};
use crate::context::{SharedStyleContext, StyleContext};
@ -455,29 +453,14 @@ trait PrivateMatchMethods: TElement {
);
}
// Trigger any present animations if necessary.
animation::maybe_start_animations(
*self,
animation_state.update_animations_for_new_style(*self, &shared_context, &new_values);
animation_state.update_transitions_for_new_style(
&shared_context,
this_opaque,
&new_values,
&mut animation_state,
old_values.as_ref(),
new_values,
);
// Trigger transitions if necessary. This will set `new_values` to
// the starting value of the transition if it did trigger a transition.
if let Some(ref old_values) = old_values {
let transitioning_properties = animation::start_transitions_if_applicable(
shared_context,
this_opaque,
old_values,
new_values,
&mut animation_state,
);
animation_state
.cancel_transitions_with_nontransitioning_properties(&transitioning_properties);
}
animation_state.apply_running_animations::<Self>(
shared_context,
new_values,