LibWeb/Animations: Don't try to associate animations to null timelines

The input to `set_timeline` is user controlled, it can be null.
This commit is contained in:
Lucas CHOLLET 2024-12-22 19:50:25 -05:00 committed by Andreas Kling
parent 55b4a983a7
commit c2165fb6b8
Notes: github-actions[bot] 2024-12-25 16:15:31 +00:00

View file

@ -99,8 +99,6 @@ void Animation::set_effect(GC::Ptr<AnimationEffect> new_effect)
// https://www.w3.org/TR/web-animations-1/#animation-set-the-timeline-of-an-animation
void Animation::set_timeline(GC::Ptr<AnimationTimeline> new_timeline)
{
// Setting this attribute updates the objects timeline using the procedure to set the timeline of an animation.
// 1. Let old timeline be the current timeline of animation, if any.
auto old_timeline = m_timeline;
@ -112,7 +110,8 @@ void Animation::set_timeline(GC::Ptr<AnimationTimeline> new_timeline)
if (m_timeline)
m_timeline->disassociate_with_animation(*this);
m_timeline = new_timeline;
m_timeline->associate_with_animation(*this);
if (m_timeline)
m_timeline->associate_with_animation(*this);
// 4. If the start time of animation is resolved, make animations hold time unresolved.
if (m_start_time.has_value())