Port WebAnimation to the HTML5 event loop
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Nov 2019 20:36:17 +0000 (20:36 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Nov 2019 20:36:17 +0000 (20:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=203797

Reviewed by Ryosuke Niwa.

* animation/WebAnimation.cpp:
(WebCore::WebAnimation::WebAnimation):
(WebCore::WebAnimation::enqueueAnimationPlaybackEvent):
(WebCore::WebAnimation::stop):
(WebCore::WebAnimation::hasPendingActivity const):
* animation/WebAnimation.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252007 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/animation/WebAnimation.cpp
Source/WebCore/animation/WebAnimation.h

index 7247bdf..392bd64 100644 (file)
@@ -1,5 +1,19 @@
 2019-11-04  Chris Dumez  <cdumez@apple.com>
 
+        Port WebAnimation to the HTML5 event loop
+        https://bugs.webkit.org/show_bug.cgi?id=203797
+
+        Reviewed by Ryosuke Niwa.
+
+        * animation/WebAnimation.cpp:
+        (WebCore::WebAnimation::WebAnimation):
+        (WebCore::WebAnimation::enqueueAnimationPlaybackEvent):
+        (WebCore::WebAnimation::stop):
+        (WebCore::WebAnimation::hasPendingActivity const):
+        * animation/WebAnimation.h:
+
+2019-11-04  Chris Dumez  <cdumez@apple.com>
+
         MediaRecorder should not prevent entering the back/forward cache
         https://bugs.webkit.org/show_bug.cgi?id=203093
         <rdar://problem/56748870>
index 19834d0..c23f9c0 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "WebAnimation.h"
 
+#include "AbstractEventLoop.h"
 #include "AnimationEffect.h"
 #include "AnimationPlaybackEvent.h"
 #include "AnimationTimeline.h"
@@ -68,7 +69,6 @@ WebAnimation::WebAnimation(Document& document)
     : ActiveDOMObject(document)
     , m_readyPromise(makeUniqueRef<ReadyPromise>(*this, &WebAnimation::readyPromiseResolve))
     , m_finishedPromise(makeUniqueRef<FinishedPromise>(*this, &WebAnimation::finishedPromiseResolve))
-    , m_taskQueue(SuspendableTaskQueue::create(document))
 {
     m_readyPromise->resolve(*this);
     suspendIfNeeded();
@@ -626,9 +626,7 @@ void WebAnimation::enqueueAnimationPlaybackEvent(const AtomString& type, Optiona
         downcast<DocumentTimeline>(*m_timeline).enqueueAnimationPlaybackEvent(WTFMove(event));
     } else {
         // Otherwise, queue a task to dispatch event at animation. The task source for this task is the DOM manipulation task source.
-        m_taskQueue->enqueueTask([this, event = WTFMove(event)] {
-            dispatchEvent(event);
-        });
+        queueTaskToDispatchEvent(*this, TaskSource::DOMManipulation, WTFMove(event));
     }
 }
 
@@ -1181,7 +1179,6 @@ void WebAnimation::resume()
 
 void WebAnimation::stop()
 {
-    m_taskQueue->cancelAllTasks();
     ActiveDOMObject::stop();
     removeAllEventListeners();
 }
@@ -1189,7 +1186,7 @@ void WebAnimation::stop()
 bool WebAnimation::hasPendingActivity() const
 {
     // Keep the JS wrapper alive if the animation is considered relevant or could become relevant again by virtue of having a timeline.
-    return m_timeline || m_isRelevant || m_taskQueue->hasPendingTasks() || ActiveDOMObject::hasPendingActivity();
+    return m_timeline || m_isRelevant || ActiveDOMObject::hasPendingActivity();
 }
 
 void WebAnimation::updateRelevance()
index 8b86ae3..ce0c7e9 100644 (file)
@@ -29,7 +29,6 @@
 #include "EventTarget.h"
 #include "ExceptionOr.h"
 #include "IDLTypes.h"
-#include "SuspendableTaskQueue.h"
 #include "WebAnimationUtilities.h"
 #include <wtf/Markable.h>
 #include <wtf/RefCounted.h>
@@ -179,7 +178,6 @@ private:
     RefPtr<AnimationTimeline> m_timeline;
     UniqueRef<ReadyPromise> m_readyPromise;
     UniqueRef<FinishedPromise> m_finishedPromise;
-    UniqueRef<SuspendableTaskQueue> m_taskQueue;
     Markable<Seconds, Seconds::MarkableTraits> m_previousCurrentTime;
     Markable<Seconds, Seconds::MarkableTraits> m_startTime;
     Markable<Seconds, Seconds::MarkableTraits> m_holdTime;