style: Expire keyframes animations when no longer referenced by the style.

It's a long way to make this sound in general...

Fixes #20731
This commit is contained in:
Emilio Cobos Álvarez 2018-05-05 19:15:59 +02:00
parent 1ba57cbaad
commit a949e9e1e8
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 46 additions and 25 deletions

View file

@ -583,7 +583,7 @@ trait PrivateMatchMethods: TElement {
possibly_expired_animations: &mut Vec<::animation::PropertyAnimation>,
font_metrics: &::font_metrics::FontMetricsProvider,
) {
use animation::{self, Animation};
use animation::{self, Animation, AnimationUpdate};
use dom::TNode;
// Finish any expired transitions.
@ -601,7 +601,7 @@ trait PrivateMatchMethods: TElement {
}
let mut all_running_animations = context.running_animations.write();
for running_animation in all_running_animations.get_mut(&this_opaque).unwrap() {
for mut running_animation in all_running_animations.get_mut(&this_opaque).unwrap() {
// This shouldn't happen frequently, but under some circumstances
// mainly huge load or debug builds, the constellation might be
// delayed in sending the `TickAllAnimations` message to layout.
@ -616,15 +616,25 @@ trait PrivateMatchMethods: TElement {
continue;
}
animation::update_style_for_animation::<Self>(
let update = animation::update_style_for_animation::<Self>(
context,
running_animation,
&mut running_animation,
style,
font_metrics,
);
if let Animation::Transition(_, _, ref frame) = *running_animation {
possibly_expired_animations.push(frame.property_animation.clone())
match *running_animation {
Animation::Transition(_, _, ref frame) => {
possibly_expired_animations.push(frame.property_animation.clone())
}
Animation::Keyframes(_, _, _, ref mut state) => {
match update {
AnimationUpdate::Regular => {},
AnimationUpdate::AnimationCanceled => {
state.expired = true;
}
}
}
}
}
}