From e11b9658ed5d8449ca5ba099b2e67e288ede6676 Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Thu, 7 Mar 2024 11:15:16 -0700 Subject: [PATCH] LibWeb: Disassociate animations from Animatables when setting effects --- Userland/Libraries/LibWeb/Animations/Animation.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Userland/Libraries/LibWeb/Animations/Animation.cpp b/Userland/Libraries/LibWeb/Animations/Animation.cpp index 2ebec92058..f6eb198ef5 100644 --- a/Userland/Libraries/LibWeb/Animations/Animation.cpp +++ b/Userland/Libraries/LibWeb/Animations/Animation.cpp @@ -74,6 +74,14 @@ void Animation::set_effect(JS::GCPtr new_effect) } // 6. Let the associated effect of animation be new effect. + auto old_target = m_effect ? m_effect->target() : nullptr; + auto new_target = new_effect ? new_effect->target() : nullptr; + if (old_target != new_target) { + if (old_target) + old_target->disassociate_with_animation(*this); + if (new_target) + new_target->associate_with_animation(*this); + } if (new_effect) new_effect->set_associated_animation(this); if (m_effect)