Diff
Modified: trunk/Source/WebCore/ChangeLog (252645 => 252646)
--- trunk/Source/WebCore/ChangeLog 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/ChangeLog 2019-11-19 21:57:52 UTC (rev 252646)
@@ -1,3 +1,41 @@
+2019-11-18 Ryosuke Niwa <[email protected]>
+
+ Rename AbstractEventLoop to EventLoop and move to its own cpp file
+ https://bugs.webkit.org/show_bug.cgi?id=204335
+
+ Reviewed by Antti Koivisto.
+
+ This patch renames AbstractEventLoop to EventLoop and move to its own cpp file since
+ r252607 consolidated the event loop implementations in WindowEventLoop and WorkerEventLoop.
+
+ * Modules/cache/DOMCache.cpp:
+ * Modules/cache/DOMCacheStorage.cpp:
+ * Modules/encryptedmedia/MediaKeySession.cpp:
+ * Modules/encryptedmedia/MediaKeys.cpp:
+ * Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp:
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * animation/WebAnimation.cpp:
+ * bindings/js/JSDOMPromiseDeferred.h:
+ * css/FontFaceSet.cpp:
+ * dom/ActiveDOMObject.cpp:
+ * dom/Document.h:
+ * dom/ScriptExecutionContext.h:
+ * dom/WindowEventLoop.cpp:
+ (WebCore::AbstractEventLoop::queueTask): Deleted.
+ (WebCore::AbstractEventLoop::resumeGroup): Deleted.
+ (WebCore::AbstractEventLoop::stopGroup): Deleted.
+ (WebCore::AbstractEventLoop::scheduleToRunIfNeeded): Deleted.
+ (WebCore::AbstractEventLoop::run): Deleted.
+ (WebCore::AbstractEventLoop::clearAllTasks): Deleted.
+ (WebCore::EventLoopFunctionDispatchTask::EventLoopFunctionDispatchTask): Deleted.
+ (WebCore::EventLoopTaskGroup::queueTask): Deleted.
+ * dom/WindowEventLoop.h:
+ * fileapi/FileReader.cpp:
+ * testing/Internals.cpp:
+ * workers/WorkerEventLoop.h:
+ * workers/service/ServiceWorkerContainer.cpp:
+
2019-11-19 Yusuke Suzuki <[email protected]>
[IndexedDB] IndexedDB's threading assertion should respect Web thread
Modified: trunk/Source/WebCore/Modules/cache/DOMCache.cpp (252645 => 252646)
--- trunk/Source/WebCore/Modules/cache/DOMCache.cpp 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/Modules/cache/DOMCache.cpp 2019-11-19 21:57:52 UTC (rev 252646)
@@ -26,8 +26,8 @@
#include "config.h"
#include "DOMCache.h"
-#include "AbstractEventLoop.h"
#include "CacheQueryOptions.h"
+#include "EventLoop.h"
#include "FetchResponse.h"
#include "HTTPParsers.h"
#include "JSFetchRequest.h"
Modified: trunk/Source/WebCore/Modules/cache/DOMCacheStorage.cpp (252645 => 252646)
--- trunk/Source/WebCore/Modules/cache/DOMCacheStorage.cpp 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/Modules/cache/DOMCacheStorage.cpp 2019-11-19 21:57:52 UTC (rev 252646)
@@ -26,9 +26,9 @@
#include "config.h"
#include "DOMCacheStorage.h"
-#include "AbstractEventLoop.h"
#include "CacheQueryOptions.h"
#include "ClientOrigin.h"
+#include "EventLoop.h"
#include "JSDOMCache.h"
#include "JSFetchResponse.h"
#include "ScriptExecutionContext.h"
Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp (252645 => 252646)
--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp 2019-11-19 21:57:52 UTC (rev 252646)
@@ -31,11 +31,11 @@
#if ENABLE(ENCRYPTED_MEDIA)
-#include "AbstractEventLoop.h"
#include "CDM.h"
#include "CDMInstance.h"
#include "DOMPromiseProxy.h"
#include "Document.h"
+#include "EventLoop.h"
#include "EventNames.h"
#include "Logging.h"
#include "MediaKeyMessageEvent.h"
Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp (252645 => 252646)
--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp 2019-11-19 21:57:52 UTC (rev 252646)
@@ -31,10 +31,10 @@
#if ENABLE(ENCRYPTED_MEDIA)
-#include "AbstractEventLoop.h"
#include "CDM.h"
#include "CDMClient.h"
#include "CDMInstance.h"
+#include "EventLoop.h"
#include "JSDOMPromiseDeferred.h"
#include "Logging.h"
#include "MediaKeySession.h"
Modified: trunk/Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp (252645 => 252646)
--- trunk/Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp 2019-11-19 21:57:52 UTC (rev 252646)
@@ -28,8 +28,8 @@
#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
-#include "AbstractEventLoop.h"
#include "Document.h"
+#include "EventLoop.h"
#include "EventNames.h"
#include "Page.h"
#include "SecurityOriginData.h"
Modified: trunk/Source/WebCore/Sources.txt (252645 => 252646)
--- trunk/Source/WebCore/Sources.txt 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/Sources.txt 2019-11-19 21:57:52 UTC (rev 252646)
@@ -880,6 +880,7 @@
dom/EventContext.cpp
dom/EventDispatcher.cpp
dom/EventListenerMap.cpp
+dom/EventLoop.cpp
dom/EventNames.cpp
dom/EventPath.cpp
dom/EventTarget.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (252645 => 252646)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-11-19 21:57:52 UTC (rev 252646)
@@ -1250,7 +1250,7 @@
46EF142C1F97B7D800C2A524 /* ServiceWorkerClients.h in Headers */ = {isa = PBXBuildFile; fileRef = 46EF14221F97B7BA00C2A524 /* ServiceWorkerClients.h */; };
46EF142D1F97B7D800C2A524 /* ServiceWorkerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 46EF14241F97B7BA00C2A524 /* ServiceWorkerClient.h */; };
46EFAF121E5FB9F100E7F34B /* LowPowerModeNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 46EFAF101E5FB9E100E7F34B /* LowPowerModeNotifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 46F02A1A23737F8300106A64 /* AbstractEventLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B0ABCA123679AB300B45085 /* AbstractEventLoop.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 46F02A1A23737F8300106A64 /* EventLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B0ABCA123679AB300B45085 /* EventLoop.h */; settings = {ATTRIBUTES = (Private, ); }; };
46FCB6181A70820E00C5A21E /* DiagnosticLoggingKeys.h in Headers */ = {isa = PBXBuildFile; fileRef = CD37B37515C1A7E1006DC898 /* DiagnosticLoggingKeys.h */; settings = {ATTRIBUTES = (Private, ); }; };
490707E71219C04300D90E51 /* ANGLEWebKitBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };
49291E4B134172C800E753DE /* ImageRenderingMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 49291E4A134172C800E753DE /* ImageRenderingMode.h */; };
@@ -11132,7 +11132,7 @@
9B098BE01F3D673D002DD562 /* JSDataTransferItemList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDataTransferItemList.h; sourceTree = "<group>"; };
9B098BE61F3D6AF6002DD562 /* JSStringCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSStringCallback.cpp; sourceTree = "<group>"; };
9B098BE71F3D6AF6002DD562 /* JSStringCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStringCallback.h; sourceTree = "<group>"; };
- 9B0ABCA123679AB300B45085 /* AbstractEventLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractEventLoop.h; sourceTree = "<group>"; };
+ 9B0ABCA123679AB300B45085 /* EventLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventLoop.h; sourceTree = "<group>"; };
9B0ABCA323679ACF00B45085 /* WorkerEventLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerEventLoop.cpp; sourceTree = "<group>"; };
9B0ABCA423679ACF00B45085 /* WorkerEventLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerEventLoop.h; sourceTree = "<group>"; };
9B0ABCAC236BB40A00B45085 /* TaskSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TaskSource.h; sourceTree = "<group>"; };
@@ -11176,6 +11176,7 @@
9B864F01234C028A006D10EB /* IdleRequestOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = IdleRequestOptions.idl; sourceTree = "<group>"; };
9B864F05234C0893006D10EB /* IdleCallbackController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IdleCallbackController.h; sourceTree = "<group>"; };
9B864F07234C08A3006D10EB /* IdleCallbackController.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IdleCallbackController.cpp; sourceTree = "<group>"; };
+ 9B91DCCC2383792D000EEE0F /* EventLoop.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = EventLoop.cpp; sourceTree = "<group>"; };
9B9299B01F6796A4006723C2 /* WebContentReaderCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebContentReaderCocoa.mm; sourceTree = "<group>"; };
9B9CADA72165DC7600E8D858 /* JSMutationRecordCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSMutationRecordCustom.cpp; sourceTree = "<group>"; };
9BA273F3172206BB0097CE47 /* LogicalSelectionOffsetCaches.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LogicalSelectionOffsetCaches.h; sourceTree = "<group>"; };
@@ -27808,7 +27809,6 @@
7CD0E2BD1F80A56E0016A4CE /* AbortSignal.cpp */,
7CD0E2BC1F80A56E0016A4CE /* AbortSignal.h */,
7CD0E2BE1F80A56E0016A4CE /* AbortSignal.idl */,
- 9B0ABCA123679AB300B45085 /* AbstractEventLoop.h */,
7C5222971E1DAE16002CB8F7 /* ActiveDOMCallback.cpp */,
7C5222981E1DAE16002CB8F7 /* ActiveDOMCallback.h */,
7CD0BA021B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.cpp */,
@@ -28011,6 +28011,8 @@
85AFA7410AAF298400E84305 /* EventListener.idl */,
AD4495F1141FC08900541EDF /* EventListenerMap.cpp */,
AD4495F2141FC08900541EDF /* EventListenerMap.h */,
+ 9B91DCCC2383792D000EEE0F /* EventLoop.cpp */,
+ 9B0ABCA123679AB300B45085 /* EventLoop.h */,
83FE7CA31DA9F1650037237C /* EventModifierInit.h */,
83FE7CA61DA9F1660037237C /* EventModifierInit.idl */,
939885C108B7E3D100E707C4 /* EventNames.cpp */,
@@ -28782,7 +28784,6 @@
7CD0E2B81F80A4820016A4CE /* AbortController.h in Headers */,
7CD0E2BF1F80A56E0016A4CE /* AbortSignal.h in Headers */,
46B95195207D633400A7D2DD /* AbstractDOMWindow.h in Headers */,
- 46F02A1A23737F8300106A64 /* AbstractEventLoop.h in Headers */,
46B95196207D633A00A7D2DD /* AbstractFrame.h in Headers */,
F48223131E386E240066FC79 /* AbstractPasteboard.h in Headers */,
41E1B1D10FF5986900576B3B /* AbstractWorker.h in Headers */,
@@ -29539,7 +29540,6 @@
CE057FA61220731100A476D5 /* DocumentMarkerController.h in Headers */,
BCCFBAE80B5152ED0001F1D7 /* DocumentParser.h in Headers */,
1D2F8E03234474EF00993B68 /* DocumentPictureInPicture.h in Headers */,
- 4A4F48AA16B0DFC000EDBB29 /* StyleScopeRuleSets.h in Headers */,
AD6E71AD1668899D00320C13 /* DocumentSharedObjectPool.h in Headers */,
6BDB5DC2227BD3B800919770 /* DocumentStorageAccess.h in Headers */,
0B90561A0F2578BF0095FF6A /* DocumentThreadableLoader.h in Headers */,
@@ -29665,6 +29665,7 @@
970B728A144FFAC600F00A37 /* EventInterfaces.h in Headers */,
935FBC4509BA00B900E230B1 /* EventListener.h in Headers */,
AD4495F4141FC08900541EDF /* EventListenerMap.h in Headers */,
+ 46F02A1A23737F8300106A64 /* EventLoop.h in Headers */,
83FE7CA81DA9F1B60037237C /* EventModifierInit.h in Headers */,
939885C408B7E3D100E707C4 /* EventNames.h in Headers */,
9B714E211C91166900AC0E92 /* EventPath.h in Headers */,
@@ -32275,6 +32276,7 @@
E4946EAF156E64DD00D3297F /* StyleRuleImport.h in Headers */,
0F94F37E23661626003AA5C7 /* StyleRuleType.h in Headers */,
E461D65F1BB0C80D00CB5645 /* StyleScope.h in Headers */,
+ 4A4F48AA16B0DFC000EDBB29 /* StyleScopeRuleSets.h in Headers */,
F47A5E3E195B8C8A00483100 /* StyleScrollSnapPoints.h in Headers */,
9D6380101AF173220031A15C /* StyleSelfAlignmentData.h in Headers */,
E47A3AC61C5EAC9D00CCBFA7 /* StyleSharingResolver.h in Headers */,
Modified: trunk/Source/WebCore/animation/WebAnimation.cpp (252645 => 252646)
--- trunk/Source/WebCore/animation/WebAnimation.cpp 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/animation/WebAnimation.cpp 2019-11-19 21:57:52 UTC (rev 252646)
@@ -26,7 +26,6 @@
#include "config.h"
#include "WebAnimation.h"
-#include "AbstractEventLoop.h"
#include "AnimationEffect.h"
#include "AnimationPlaybackEvent.h"
#include "AnimationTimeline.h"
@@ -34,6 +33,7 @@
#include "DeclarativeAnimation.h"
#include "Document.h"
#include "DocumentTimeline.h"
+#include "EventLoop.h"
#include "EventNames.h"
#include "InspectorInstrumentation.h"
#include "JSWebAnimation.h"
Modified: trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.h (252645 => 252646)
--- trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.h 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.h 2019-11-19 21:57:52 UTC (rev 252646)
@@ -25,7 +25,7 @@
#pragma once
-#include "AbstractEventLoop.h"
+#include "EventLoop.h"
#include "ExceptionOr.h"
#include "JSDOMConvert.h"
#include "JSDOMGuardedObject.h"
Modified: trunk/Source/WebCore/css/FontFaceSet.cpp (252645 => 252646)
--- trunk/Source/WebCore/css/FontFaceSet.cpp 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/css/FontFaceSet.cpp 2019-11-19 21:57:52 UTC (rev 252646)
@@ -26,9 +26,9 @@
#include "config.h"
#include "FontFaceSet.h"
-#include "AbstractEventLoop.h"
#include "DOMPromiseProxy.h"
#include "Document.h"
+#include "EventLoop.h"
#include "FontFace.h"
#include "FrameLoader.h"
#include "JSDOMBinding.h"
Deleted: trunk/Source/WebCore/dom/AbstractEventLoop.h (252645 => 252646)
--- trunk/Source/WebCore/dom/AbstractEventLoop.h 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/dom/AbstractEventLoop.h 2019-11-19 21:57:52 UTC (rev 252646)
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include "TaskSource.h"
-#include <wtf/Function.h>
-#include <wtf/RefCounted.h>
-#include <wtf/StdLibExtras.h>
-#include <wtf/WeakHashSet.h>
-#include <wtf/WeakPtr.h>
-
-namespace WebCore {
-
-class EventLoopTaskGroup;
-class EventTarget;
-class ScriptExecutionContext;
-
-class EventLoopTask {
- WTF_MAKE_NONCOPYABLE(EventLoopTask);
- WTF_MAKE_FAST_ALLOCATED;
-
-public:
- virtual ~EventLoopTask() = default;
-
- TaskSource taskSource() { return m_taskSource; }
- virtual void execute() = 0;
-
- EventLoopTaskGroup* group() const { return m_group.get(); }
-
-protected:
- EventLoopTask(TaskSource, EventLoopTaskGroup&);
-
-private:
- const TaskSource m_taskSource;
- WeakPtr<EventLoopTaskGroup> m_group;
-};
-
-// https://html.spec.whatwg.org/multipage/webappapis.html#event-loop
-class AbstractEventLoop : public RefCounted<AbstractEventLoop>, public CanMakeWeakPtr<AbstractEventLoop> {
-public:
- virtual ~AbstractEventLoop() = default;
-
- typedef Function<void ()> TaskFunction;
- void queueTask(std::unique_ptr<EventLoopTask>&&);
-
- void resumeGroup(EventLoopTaskGroup&);
- void stopGroup(EventLoopTaskGroup&);
-
-protected:
- AbstractEventLoop() = default;
- void run();
- void clearAllTasks();
-
-private:
- void scheduleToRunIfNeeded();
- virtual void scheduleToRun() = 0;
- virtual bool isContextThread() const = 0;
-
- // Use a global queue instead of multiple task queues since HTML5 spec allows UA to pick arbitrary queue.
- Vector<std::unique_ptr<EventLoopTask>> m_tasks;
- WeakHashSet<EventLoopTaskGroup> m_groupsWithSuspenedTasks;
- bool m_isScheduledToRun { false };
-};
-
-class EventLoopTaskGroup : public CanMakeWeakPtr<EventLoopTaskGroup> {
- WTF_MAKE_NONCOPYABLE(EventLoopTaskGroup);
- WTF_MAKE_FAST_ALLOCATED;
-
-public:
- EventLoopTaskGroup(AbstractEventLoop& eventLoop)
- : m_eventLoop(makeWeakPtr(eventLoop))
- {
- }
-
- bool matchesTask(EventLoopTask& task) const
- {
- auto* group = task.group();
- return group == this;
- }
-
- void stopAndDiscardAllTasks()
- {
- m_state = State::Stopped;
- if (auto* eventLoop = m_eventLoop.get())
- eventLoop->stopGroup(*this);
- }
-
- void suspend()
- {
- ASSERT(m_state != State::Stopped);
- m_state = State::Suspended;
- // We don't remove suspended tasks to preserve the ordering.
- // AbstractEventLoop::run checks whether each task's group is suspended or not.
- }
-
- void resume()
- {
- ASSERT(m_state != State::Stopped);
- m_state = State::Running;
- if (auto* eventLoop = m_eventLoop.get())
- eventLoop->resumeGroup(*this);
- }
-
- bool isStoppedPermanently() { return m_state == State::Stopped; }
- bool isSuspended() { return m_state == State::Suspended; }
-
- void queueTask(std::unique_ptr<EventLoopTask>&& task)
- {
- if (m_state == State::Stopped || !m_eventLoop)
- return;
- ASSERT(task->group() == this);
- m_eventLoop->queueTask(WTFMove(task));
- }
-
- WEBCORE_EXPORT void queueTask(TaskSource, AbstractEventLoop::TaskFunction&&);
-
-private:
- enum class State : uint8_t { Running, Suspended, Stopped };
-
- WeakPtr<AbstractEventLoop> m_eventLoop;
- State m_state { State::Running };
-};
-
-inline EventLoopTask::EventLoopTask(TaskSource source, EventLoopTaskGroup& group)
- : m_taskSource(source)
- , m_group(makeWeakPtr(group))
-{ }
-
-} // namespace WebCore
Modified: trunk/Source/WebCore/dom/ActiveDOMObject.cpp (252645 => 252646)
--- trunk/Source/WebCore/dom/ActiveDOMObject.cpp 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/dom/ActiveDOMObject.cpp 2019-11-19 21:57:52 UTC (rev 252646)
@@ -27,8 +27,8 @@
#include "config.h"
#include "ActiveDOMObject.h"
-#include "AbstractEventLoop.h"
#include "Document.h"
+#include "EventLoop.h"
#include "ScriptExecutionContext.h"
namespace WebCore {
Modified: trunk/Source/WebCore/dom/Document.h (252645 => 252646)
--- trunk/Source/WebCore/dom/Document.h 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/dom/Document.h 2019-11-19 21:57:52 UTC (rev 252646)
@@ -88,7 +88,7 @@
namespace WebCore {
-class AbstractEventLoop;
+class EventLoop;
class ApplicationStateChangeListener;
class AXObjectCache;
class Attr;
Added: trunk/Source/WebCore/dom/EventLoop.cpp (0 => 252646)
--- trunk/Source/WebCore/dom/EventLoop.cpp (rev 0)
+++ trunk/Source/WebCore/dom/EventLoop.cpp 2019-11-19 21:57:52 UTC (rev 252646)
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "EventLoop.h"
+
+namespace WebCore {
+
+void EventLoop::queueTask(std::unique_ptr<EventLoopTask>&& task)
+{
+ ASSERT(task->group());
+ ASSERT(isContextThread());
+ scheduleToRunIfNeeded();
+ m_tasks.append(WTFMove(task));
+}
+
+void EventLoop::resumeGroup(EventLoopTaskGroup& group)
+{
+ ASSERT(isContextThread());
+ if (!m_groupsWithSuspenedTasks.contains(group))
+ return;
+ scheduleToRunIfNeeded();
+}
+
+void EventLoop::stopGroup(EventLoopTaskGroup& group)
+{
+ ASSERT(isContextThread());
+ m_tasks.removeAllMatching([&group] (auto& task) {
+ return group.matchesTask(*task);
+ });
+}
+
+void EventLoop::scheduleToRunIfNeeded()
+{
+ if (m_isScheduledToRun)
+ return;
+ m_isScheduledToRun = true;
+ scheduleToRun();
+}
+
+void EventLoop::run()
+{
+ m_isScheduledToRun = false;
+ if (m_tasks.isEmpty())
+ return;
+
+ auto tasks = std::exchange(m_tasks, { });
+ m_groupsWithSuspenedTasks.clear();
+ Vector<std::unique_ptr<EventLoopTask>> remainingTasks;
+ for (auto& task : tasks) {
+ auto* group = task->group();
+ if (!group || group->isStoppedPermanently())
+ continue;
+
+ if (group->isSuspended()) {
+ m_groupsWithSuspenedTasks.add(group);
+ remainingTasks.append(WTFMove(task));
+ continue;
+ }
+
+ task->execute();
+ }
+ for (auto& task : m_tasks)
+ remainingTasks.append(WTFMove(task));
+ m_tasks = WTFMove(remainingTasks);
+}
+
+void EventLoop::clearAllTasks()
+{
+ m_tasks.clear();
+ m_groupsWithSuspenedTasks.clear();
+}
+
+void EventLoopTaskGroup::queueTask(std::unique_ptr<EventLoopTask>&& task)
+{
+ if (m_state == State::Stopped || !m_eventLoop)
+ return;
+ ASSERT(task->group() == this);
+ m_eventLoop->queueTask(WTFMove(task));
+}
+
+class EventLoopFunctionDispatchTask : public EventLoopTask {
+public:
+ EventLoopFunctionDispatchTask(TaskSource source, EventLoopTaskGroup& group, EventLoop::TaskFunction&& function)
+ : EventLoopTask(source, group)
+ , m_function(WTFMove(function))
+ {
+ }
+
+ void execute() final { m_function(); }
+
+private:
+ EventLoop::TaskFunction m_function;
+};
+
+void EventLoopTaskGroup::queueTask(TaskSource source, EventLoop::TaskFunction&& function)
+{
+ return queueTask(makeUnique<EventLoopFunctionDispatchTask>(source, *this, WTFMove(function)));
+}
+
+} // namespace WebCore
Copied: trunk/Source/WebCore/dom/EventLoop.h (from rev 252645, trunk/Source/WebCore/dom/AbstractEventLoop.h) (0 => 252646)
--- trunk/Source/WebCore/dom/EventLoop.h (rev 0)
+++ trunk/Source/WebCore/dom/EventLoop.h 2019-11-19 21:57:52 UTC (rev 252646)
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "TaskSource.h"
+#include <wtf/Function.h>
+#include <wtf/RefCounted.h>
+#include <wtf/StdLibExtras.h>
+#include <wtf/WeakHashSet.h>
+#include <wtf/WeakPtr.h>
+
+namespace WebCore {
+
+class EventLoopTaskGroup;
+class EventTarget;
+class ScriptExecutionContext;
+
+class EventLoopTask {
+ WTF_MAKE_NONCOPYABLE(EventLoopTask);
+ WTF_MAKE_FAST_ALLOCATED;
+
+public:
+ virtual ~EventLoopTask() = default;
+
+ TaskSource taskSource() { return m_taskSource; }
+ virtual void execute() = 0;
+
+ EventLoopTaskGroup* group() const { return m_group.get(); }
+
+protected:
+ EventLoopTask(TaskSource, EventLoopTaskGroup&);
+
+private:
+ const TaskSource m_taskSource;
+ WeakPtr<EventLoopTaskGroup> m_group;
+};
+
+// https://html.spec.whatwg.org/multipage/webappapis.html#event-loop
+class EventLoop : public RefCounted<EventLoop>, public CanMakeWeakPtr<EventLoop> {
+public:
+ virtual ~EventLoop() = default;
+
+ typedef Function<void ()> TaskFunction;
+ void queueTask(std::unique_ptr<EventLoopTask>&&);
+
+ void resumeGroup(EventLoopTaskGroup&);
+ void stopGroup(EventLoopTaskGroup&);
+
+protected:
+ EventLoop() = default;
+ void run();
+ void clearAllTasks();
+
+private:
+ void scheduleToRunIfNeeded();
+ virtual void scheduleToRun() = 0;
+ virtual bool isContextThread() const = 0;
+
+ // Use a global queue instead of multiple task queues since HTML5 spec allows UA to pick arbitrary queue.
+ Vector<std::unique_ptr<EventLoopTask>> m_tasks;
+ WeakHashSet<EventLoopTaskGroup> m_groupsWithSuspenedTasks;
+ bool m_isScheduledToRun { false };
+};
+
+class EventLoopTaskGroup : public CanMakeWeakPtr<EventLoopTaskGroup> {
+ WTF_MAKE_NONCOPYABLE(EventLoopTaskGroup);
+ WTF_MAKE_FAST_ALLOCATED;
+
+public:
+ EventLoopTaskGroup(EventLoop& eventLoop)
+ : m_eventLoop(makeWeakPtr(eventLoop))
+ {
+ }
+
+ bool matchesTask(EventLoopTask& task) const
+ {
+ auto* group = task.group();
+ return group == this;
+ }
+
+ void stopAndDiscardAllTasks()
+ {
+ m_state = State::Stopped;
+ if (auto* eventLoop = m_eventLoop.get())
+ eventLoop->stopGroup(*this);
+ }
+
+ void suspend()
+ {
+ ASSERT(m_state != State::Stopped);
+ m_state = State::Suspended;
+ // We don't remove suspended tasks to preserve the ordering.
+ // EventLoop::run checks whether each task's group is suspended or not.
+ }
+
+ void resume()
+ {
+ ASSERT(m_state != State::Stopped);
+ m_state = State::Running;
+ if (auto* eventLoop = m_eventLoop.get())
+ eventLoop->resumeGroup(*this);
+ }
+
+ bool isStoppedPermanently() { return m_state == State::Stopped; }
+ bool isSuspended() { return m_state == State::Suspended; }
+
+ void queueTask(std::unique_ptr<EventLoopTask>&&);
+ WEBCORE_EXPORT void queueTask(TaskSource, EventLoop::TaskFunction&&);
+
+private:
+ enum class State : uint8_t { Running, Suspended, Stopped };
+
+ WeakPtr<EventLoop> m_eventLoop;
+ State m_state { State::Running };
+};
+
+inline EventLoopTask::EventLoopTask(TaskSource source, EventLoopTaskGroup& group)
+ : m_taskSource(source)
+ , m_group(makeWeakPtr(group))
+{ }
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.h (252645 => 252646)
--- trunk/Source/WebCore/dom/ScriptExecutionContext.h 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.h 2019-11-19 21:57:52 UTC (rev 252646)
@@ -53,7 +53,7 @@
namespace WebCore {
-class AbstractEventLoop;
+class EventLoop;
class CachedScript;
class DatabaseContext;
class EventQueue;
Modified: trunk/Source/WebCore/dom/WindowEventLoop.cpp (252645 => 252646)
--- trunk/Source/WebCore/dom/WindowEventLoop.cpp 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/dom/WindowEventLoop.cpp 2019-11-19 21:57:52 UTC (rev 252646)
@@ -59,38 +59,6 @@
RELEASE_ASSERT(didRemove);
}
-void AbstractEventLoop::queueTask(std::unique_ptr<EventLoopTask>&& task)
-{
- ASSERT(task->group());
- ASSERT(isContextThread());
- scheduleToRunIfNeeded();
- m_tasks.append(WTFMove(task));
-}
-
-void AbstractEventLoop::resumeGroup(EventLoopTaskGroup& group)
-{
- ASSERT(isContextThread());
- if (!m_groupsWithSuspenedTasks.contains(group))
- return;
- scheduleToRunIfNeeded();
-}
-
-void AbstractEventLoop::stopGroup(EventLoopTaskGroup& group)
-{
- ASSERT(isContextThread());
- m_tasks.removeAllMatching([&group] (auto& task) {
- return group.matchesTask(*task);
- });
-}
-
-void AbstractEventLoop::scheduleToRunIfNeeded()
-{
- if (m_isScheduledToRun)
- return;
- m_isScheduledToRun = true;
- scheduleToRun();
-}
-
void WindowEventLoop::scheduleToRun()
{
callOnMainThread([eventLoop = makeRef(*this)] () {
@@ -103,56 +71,4 @@
return isMainThread();
}
-void AbstractEventLoop::run()
-{
- m_isScheduledToRun = false;
- if (m_tasks.isEmpty())
- return;
-
- auto tasks = std::exchange(m_tasks, { });
- m_groupsWithSuspenedTasks.clear();
- Vector<std::unique_ptr<EventLoopTask>> remainingTasks;
- for (auto& task : tasks) {
- auto* group = task->group();
- if (!group || group->isStoppedPermanently())
- continue;
-
- if (group->isSuspended()) {
- m_groupsWithSuspenedTasks.add(group);
- remainingTasks.append(WTFMove(task));
- continue;
- }
-
- task->execute();
- }
- for (auto& task : m_tasks)
- remainingTasks.append(WTFMove(task));
- m_tasks = WTFMove(remainingTasks);
-}
-
-void AbstractEventLoop::clearAllTasks()
-{
- m_tasks.clear();
- m_groupsWithSuspenedTasks.clear();
-}
-
-class EventLoopFunctionDispatchTask : public EventLoopTask {
-public:
- EventLoopFunctionDispatchTask(TaskSource source, EventLoopTaskGroup& group, AbstractEventLoop::TaskFunction&& function)
- : EventLoopTask(source, group)
- , m_function(WTFMove(function))
- {
- }
-
- void execute() final { m_function(); }
-
-private:
- AbstractEventLoop::TaskFunction m_function;
-};
-
-void EventLoopTaskGroup::queueTask(TaskSource source, AbstractEventLoop::TaskFunction&& function)
-{
- return queueTask(makeUnique<EventLoopFunctionDispatchTask>(source, *this, WTFMove(function)));
-}
-
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/WindowEventLoop.h (252645 => 252646)
--- trunk/Source/WebCore/dom/WindowEventLoop.h 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/dom/WindowEventLoop.h 2019-11-19 21:57:52 UTC (rev 252646)
@@ -25,8 +25,8 @@
#pragma once
-#include "AbstractEventLoop.h"
#include "DocumentIdentifier.h"
+#include "EventLoop.h"
#include "RegistrableDomain.h"
#include <wtf/HashSet.h>
@@ -35,7 +35,7 @@
class Document;
// https://html.spec.whatwg.org/multipage/webappapis.html#window-event-loop
-class WindowEventLoop final : public AbstractEventLoop {
+class WindowEventLoop final : public EventLoop {
public:
static Ref<WindowEventLoop> ensureForRegistrableDomain(const RegistrableDomain&);
Modified: trunk/Source/WebCore/fileapi/FileReader.cpp (252645 => 252646)
--- trunk/Source/WebCore/fileapi/FileReader.cpp 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/fileapi/FileReader.cpp 2019-11-19 21:57:52 UTC (rev 252646)
@@ -31,7 +31,7 @@
#include "config.h"
#include "FileReader.h"
-#include "AbstractEventLoop.h"
+#include "EventLoop.h"
#include "EventNames.h"
#include "File.h"
#include "Logging.h"
Modified: trunk/Source/WebCore/testing/Internals.cpp (252645 => 252646)
--- trunk/Source/WebCore/testing/Internals.cpp 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/testing/Internals.cpp 2019-11-19 21:57:52 UTC (rev 252646)
@@ -28,7 +28,6 @@
#include "Internals.h"
#include "AXObjectCache.h"
-#include "AbstractEventLoop.h"
#include "ActiveDOMCallbackMicrotask.h"
#include "ActivityState.h"
#include "AnimationTimeline.h"
@@ -71,6 +70,7 @@
#include "Element.h"
#include "EventHandler.h"
#include "EventListener.h"
+#include "EventLoop.h"
#include "EventNames.h"
#include "ExtendableEvent.h"
#include "ExtensionStyleSheets.h"
Modified: trunk/Source/WebCore/workers/WorkerEventLoop.h (252645 => 252646)
--- trunk/Source/WebCore/workers/WorkerEventLoop.h 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/workers/WorkerEventLoop.h 2019-11-19 21:57:52 UTC (rev 252646)
@@ -25,8 +25,8 @@
#pragma once
-#include "AbstractEventLoop.h"
#include "ActiveDOMObject.h"
+#include "EventLoop.h"
namespace WebCore {
@@ -33,7 +33,7 @@
class WorkerGlobalScope;
class WorkletGlobalScope;
-class WorkerEventLoop final : public AbstractEventLoop, private ContextDestructionObserver {
+class WorkerEventLoop final : public EventLoop, private ContextDestructionObserver {
public:
// Explicitly take WorkerGlobalScope and WorkletGlobalScope for documentation purposes.
static Ref<WorkerEventLoop> create(WorkerGlobalScope&);
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp (252645 => 252646)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp 2019-11-19 21:36:54 UTC (rev 252645)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp 2019-11-19 21:57:52 UTC (rev 252646)
@@ -28,10 +28,10 @@
#if ENABLE(SERVICE_WORKER)
-#include "AbstractEventLoop.h"
#include "DOMPromiseProxy.h"
#include "Document.h"
#include "Event.h"
+#include "EventLoop.h"
#include "EventNames.h"
#include "Exception.h"
#include "IDLTypes.h"