aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/animations.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2020-06-09 11:39:43 +0200
committerMartin Robinson <mrobinson@igalia.com>2020-06-17 16:35:06 +0200
commite901fa2c39bc930201f5e251bb65e276a846634c (patch)
tree541e31dd3616ba4cc65c8a903fb1f2aade4550d0 /components/script/animations.rs
parent6d9b2eef296fe3281fc098a5ea238c8053c3f893 (diff)
downloadservo-e901fa2c39bc930201f5e251bb65e276a846634c.tar.gz
servo-e901fa2c39bc930201f5e251bb65e276a846634c.zip
Cancel animations for nodes which are removed from the DOM
This includes nodes which are being reparented.
Diffstat (limited to 'components/script/animations.rs')
-rw-r--r--components/script/animations.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/components/script/animations.rs b/components/script/animations.rs
index bddbac14966..c383048b3a8 100644
--- a/components/script/animations.rs
+++ b/components/script/animations.rs
@@ -99,6 +99,27 @@ impl Animations {
self.unroot_unused_nodes(&sets);
}
+ /// Cancel animations for the given node, if any exist.
+ pub(crate) fn cancel_animations_for_node(&self, node: &Node) {
+ let mut animations = self.sets.sets.write();
+ let mut cancel_animations_for = |key| {
+ animations.get_mut(&key).map(|set| {
+ set.cancel_all_animations();
+ });
+ };
+
+ let opaque_node = node.to_opaque();
+ cancel_animations_for(AnimationSetKey::new_for_non_pseudo(opaque_node));
+ cancel_animations_for(AnimationSetKey::new_for_pseudo(
+ opaque_node,
+ PseudoElement::Before,
+ ));
+ cancel_animations_for(AnimationSetKey::new_for_pseudo(
+ opaque_node,
+ PseudoElement::After,
+ ));
+ }
+
/// Processes any new animations that were discovered after reflow. Collect messages
/// that trigger events for any animations that changed state.
pub(crate) fn do_post_reflow_update(&self, window: &Window, now: f64) {