Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancel animations for nodes which are removed from the DOM #26953

Merged
merged 1 commit into from Jun 22, 2020
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Cancel animations for nodes which are removed from the DOM

This includes nodes which are being reparented.
  • Loading branch information
mrobinson committed Jun 17, 2020
commit e901fa2c39bc930201f5e251bb65e276a846634c
@@ -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) {
@@ -3855,6 +3855,10 @@ impl Document {
.borrow()
.do_post_reflow_update(&self.window, self.current_animation_timeline_value());
}

pub(crate) fn cancel_animations_for_node(&self, node: &Node) {
self.animations.borrow().cancel_animations_for_node(node);
}
}

impl Element {
@@ -281,6 +281,11 @@ impl Node {
}
}

pub fn clean_up_layout_data(&self) {
self.owner_doc().cancel_animations_for_node(self);
self.style_and_layout_data.borrow_mut().take();
}

/// Clean up flags and unbind from tree.
pub fn complete_remove_subtree(root: &Node, context: &UnbindContext) {
for node in root.traverse_preorder(ShadowIncluding::Yes) {
@@ -295,6 +300,8 @@ impl Node {
);
}
for node in root.traverse_preorder(ShadowIncluding::Yes) {
node.clean_up_layout_data();

// This needs to be in its own loop, because unbind_from_tree may
// rely on the state of IS_IN_DOC of the context node's descendants,
// e.g. when removing a <form>.

This file was deleted.

@@ -212,9 +212,6 @@
[text-indent length(in) / events]
expected: FAIL

[visibility visibility(keyword) / events]
expected: FAIL

[text-indent length(pc) / events]
expected: FAIL

@@ -227,9 +224,6 @@
[text-indent length(cm) / events]
expected: FAIL

[visibility visibility(keyword) / values]
expected: FAIL

[outline-width length(cm) / events]
expected: FAIL

@@ -104,9 +104,6 @@
[vertical-align length(cm) / values]
expected: FAIL

[visibility visibility(keyword) / events]
expected: FAIL

[vertical-align length(ex) / values]
expected: FAIL

@@ -212,9 +212,6 @@
[text-indent length(in) / events]
expected: FAIL

[visibility visibility(keyword) / events]
expected: FAIL

[text-indent length(pc) / events]
expected: FAIL

@@ -227,9 +224,6 @@
[text-indent length(cm) / events]
expected: FAIL

[visibility visibility(keyword) / values]
expected: FAIL

[outline-width length(cm) / events]
expected: FAIL

This file was deleted.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.