mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-16 06:22:17 +00:00
LibWeb: Remove animations from timeline in Element::removed_from()
`AnimationTimeline` visits pointers of all registered animations, so if element is removed from DOM tree but its animations remain registered in timeline, then `Animation` and owner `Element` will be kept alive until `AnimationTimeline` is destroyed.
This commit is contained in:
parent
85baf71d48
commit
c8b574e9b4
Notes:
github-actions[bot]
2025-07-23 21:51:20 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: c8b574e9b4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5515
Reviewed-by: https://github.com/shannonbooth
3 changed files with 12 additions and 0 deletions
|
@ -235,6 +235,15 @@ void Animatable::clear_transitions(Optional<CSS::PseudoElement> pseudo_element)
|
|||
transition.transition_attributes.clear();
|
||||
}
|
||||
|
||||
void Animatable::remove_animations_from_timeline()
|
||||
{
|
||||
// This is needed to avoid leaking Animation objects
|
||||
auto& impl = ensure_impl();
|
||||
for (auto animation : impl.associated_animations) {
|
||||
animation->set_timeline({});
|
||||
}
|
||||
}
|
||||
|
||||
void Animatable::visit_edges(JS::Cell::Visitor& visitor)
|
||||
{
|
||||
auto& impl = ensure_impl();
|
||||
|
|
|
@ -67,6 +67,8 @@ public:
|
|||
GC::Ptr<CSS::CSSTransition> property_transition(Optional<CSS::PseudoElement>, CSS::PropertyID) const;
|
||||
void clear_transitions(Optional<CSS::PseudoElement>);
|
||||
|
||||
void remove_animations_from_timeline();
|
||||
|
||||
protected:
|
||||
void visit_edges(JS::Cell::Visitor&);
|
||||
|
||||
|
|
|
@ -1356,6 +1356,7 @@ void Element::removed_from(Node* old_parent, Node& old_root)
|
|||
}
|
||||
|
||||
play_or_cancel_animations_after_display_property_change();
|
||||
remove_animations_from_timeline();
|
||||
}
|
||||
|
||||
void Element::moved_from(GC::Ptr<Node> old_parent)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue