diff --git a/dom/animation/Animation.cpp b/dom/animation/Animation.cpp index 9c49470cb4e..cf9bc7a797d 100644 --- a/dom/animation/Animation.cpp +++ b/dom/animation/Animation.cpp @@ -478,6 +478,8 @@ Animation::DoCancel() } ResetFinishedPromise(); + DispatchPlaybackEvent(NS_LITERAL_STRING("cancel")); + mHoldTime.SetNull(); mStartTime.SetNull(); @@ -1118,7 +1120,9 @@ Animation::DispatchPlaybackEvent(const nsAString& aName) { AnimationPlaybackEventInit init; - init.mCurrentTime = GetCurrentTimeAsDouble(); + if (aName.EqualsLiteral("finish")) { + init.mCurrentTime = GetCurrentTimeAsDouble(); + } if (mTimeline) { init.mTimelineTime = mTimeline->GetCurrentTimeAsDouble(); } diff --git a/dom/animation/Animation.h b/dom/animation/Animation.h index 34303f2489a..b079f134028 100644 --- a/dom/animation/Animation.h +++ b/dom/animation/Animation.h @@ -112,6 +112,7 @@ public: virtual void Reverse(ErrorResult& aRv); bool IsRunningOnCompositor() const { return mIsRunningOnCompositor; } IMPL_EVENT_HANDLER(finish); + IMPL_EVENT_HANDLER(cancel); // Wrapper functions for Animation DOM methods when called // from script. diff --git a/dom/animation/test/css-animations/file_animation-oncancel.html b/dom/animation/test/css-animations/file_animation-oncancel.html new file mode 100644 index 00000000000..563ef00613e --- /dev/null +++ b/dom/animation/test/css-animations/file_animation-oncancel.html @@ -0,0 +1,35 @@ + + + + +
+ + diff --git a/dom/animation/test/css-animations/test_animation-oncancel.html b/dom/animation/test/css-animations/test_animation-oncancel.html new file mode 100644 index 00000000000..94b5f92fb06 --- /dev/null +++ b/dom/animation/test/css-animations/test_animation-oncancel.html @@ -0,0 +1,15 @@ + + + + + + +