LibWeb: Save time for animationcancel event before transitioning to idle

The if statement in the dispatch implies we are in the idle state, so of
course the active time will always be undefined. If this was cancelled
via a call to cancel(), we can save the time at that point. Otherwise,
just send 0.
This commit is contained in:
Matthew Olsson 2024-05-23 19:17:52 -07:00 committed by Andreas Kling
commit 15a8baee03
Notes: sideshowbarker 2024-07-17 10:16:43 +09:00
5 changed files with 38 additions and 2 deletions

View file

@ -2103,8 +2103,9 @@ void Document::dispatch_events_for_animation_if_necessary(JS::NonnullGCPtr<Anima
}
if (current_phase == Animations::AnimationEffect::Phase::Idle && previous_phase != Animations::AnimationEffect::Phase::Idle && previous_phase != Animations::AnimationEffect::Phase::After) {
// FIXME: Use the active time "at the moment it was cancelled"
dispatch_event(HTML::EventNames::animationcancel, effect->active_time_using_fill(Bindings::FillMode::Both).value());
// FIXME: Calculate a non-zero time when the animation is cancelled by means other than calling cancel()
auto cancel_time = animation->release_saved_cancel_time().value_or(0.0);
dispatch_event(HTML::EventNames::animationcancel, cancel_time);
}
}
effect->set_previous_phase(current_phase);