Make WebInspector's remote debug EventLoop code into RunLoop
https://bugs.webkit.org/show_bug.cgi?id=202716

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

Updated the code to use RunLoop::cycle instead of now deleted EventLoop class.

The runloop mode used in Apple's port is moved to RemoteInspectionTarget::runLoopMode
with a special case for watchOS.

* JavaScriptCore.xcodeproj/project.pbxproj:
* Sources.txt:
* inspector/JSGlobalObjectScriptDebugServer.cpp:
(Inspector::JSGlobalObjectScriptDebugServer::runEventLoopWhilePaused):
(Inspector::JSGlobalObjectScriptDebugServer::runLoopMode): Added.
* inspector/remote/RemoteInspectionTarget.cpp:
(Inspector::RemoteInspectionTarget::pauseWaitingForAutomaticInspection):
Invoke CFRunLoopAddSource with the runloop mode only expcet on watchOS where
we use the default runloop anyway.
* inspector/remote/RemoteInspectionTarget.h:
* inspector/remote/cocoa/RemoteConnectionToTargetCocoa.mm:
(Inspector::RemoteTargetInitializeGlobalQueue):
(Inspector::RemoteConnectionToTarget::setupRunLoop):
(Inspector::RemoteConnectionToTarget::teardownRunLoop):

Source/WebCore:

Use RunLoop::cycle.

* PlatformFTW.cmake:
* PlatformPlayStation.cmake:
* PlatformWin.cmake:
* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:
* inspector/PageScriptDebugServer.cpp:
(WebCore::PageScriptDebugServer::runEventLoopWhilePausedInternal):
* platform/SourcesGLib.txt:
* platform/glib/EventLoopGlib.cpp: Removed.
* platform/playstation/EventLoopPlayStation.cpp: Removed.
* platform/win/EventLoopWin.cpp: Removed.

Source/WTF:

This patch merges WebInspector's EventLoop code into RunLoop as a static function.

* wtf/RunLoop.h:
(WTF::RunLoop::cycle):
* wtf/cf/RunLoopCF.cpp:
(WTF::RunLoop::cycle): Added.
* wtf/generic/RunLoopGeneric.cpp:
(WTF::RunLoop::cycle): Added.
* wtf/glib/RunLoopGLib.cpp:
(WTF::RunLoop::cycle): Added.
* wtf/win/RunLoopWin.cpp:
(WTF::RunLoop::cycle): Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index b6fcc65..edc205b 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,30 @@
+2019-10-08  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Make WebInspector's remote debug EventLoop code into RunLoop
+        https://bugs.webkit.org/show_bug.cgi?id=202716
+
+        Reviewed by Joseph Pecoraro.
+
+        Updated the code to use RunLoop::cycle instead of now deleted EventLoop class.
+
+        The runloop mode used in Apple's port is moved to RemoteInspectionTarget::runLoopMode
+        with a special case for watchOS.
+
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * Sources.txt:
+        * inspector/JSGlobalObjectScriptDebugServer.cpp:
+        (Inspector::JSGlobalObjectScriptDebugServer::runEventLoopWhilePaused):
+        (Inspector::JSGlobalObjectScriptDebugServer::runLoopMode): Added.
+        * inspector/remote/RemoteInspectionTarget.cpp:
+        (Inspector::RemoteInspectionTarget::pauseWaitingForAutomaticInspection):
+        Invoke CFRunLoopAddSource with the runloop mode only expcet on watchOS where
+        we use the default runloop anyway.
+        * inspector/remote/RemoteInspectionTarget.h:
+        * inspector/remote/cocoa/RemoteConnectionToTargetCocoa.mm:
+        (Inspector::RemoteTargetInitializeGlobalQueue):
+        (Inspector::RemoteConnectionToTarget::setupRunLoop):
+        (Inspector::RemoteConnectionToTarget::teardownRunLoop):
+
 2019-10-10  Ryosuke Niwa  <rniwa@webkit.org>
 
         Make it safe to store a ThreadSafeRefCounted object in Ref & RefPtr safe inside its destructor
diff --git a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
index 5678547..8c99e17 100644
--- a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
+++ b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
@@ -1404,7 +1404,6 @@
 		A5398FAB1C750DA40060A963 /* HeapProfiler.h in Headers */ = {isa = PBXBuildFile; fileRef = A5398FAA1C750D950060A963 /* HeapProfiler.h */; };
 		A53CE08A18BC21C300BEDF76 /* ConsoleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A53CE08918BC21C300BEDF76 /* ConsoleClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A53F1AC018C90F8F0072EB6D /* framework.sb in Resources */ = {isa = PBXBuildFile; fileRef = A53F1ABE18C90EC70072EB6D /* framework.sb */; };
-		A54982041891D0B00081E5B8 /* EventLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = A54982021891D0B00081E5B8 /* EventLoop.h */; };
 		A54C2AB11C6544F200A18D78 /* HeapSnapshot.h in Headers */ = {isa = PBXBuildFile; fileRef = A54C2AAF1C6544D100A18D78 /* HeapSnapshot.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A54CF2F6184EAB2400237F19 /* ScriptValue.h in Headers */ = {isa = PBXBuildFile; fileRef = A54CF2F3184EAB2400237F19 /* ScriptValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A54CF2FA184EAEDA00237F19 /* ScriptObject.h in Headers */ = {isa = PBXBuildFile; fileRef = A54CF2F8184EAEDA00237F19 /* ScriptObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -4336,8 +4335,6 @@
 		A5398FAA1C750D950060A963 /* HeapProfiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeapProfiler.h; sourceTree = "<group>"; };
 		A53CE08918BC21C300BEDF76 /* ConsoleClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConsoleClient.h; sourceTree = "<group>"; };
 		A53F1ABE18C90EC70072EB6D /* framework.sb */ = {isa = PBXFileReference; lastKnownFileType = text; path = framework.sb; sourceTree = "<group>"; };
-		A54982011891D0B00081E5B8 /* EventLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventLoop.cpp; sourceTree = "<group>"; };
-		A54982021891D0B00081E5B8 /* EventLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventLoop.h; sourceTree = "<group>"; };
 		A54C2AAE1C6544D100A18D78 /* HeapSnapshot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HeapSnapshot.cpp; sourceTree = "<group>"; };
 		A54C2AAF1C6544D100A18D78 /* HeapSnapshot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeapSnapshot.h; sourceTree = "<group>"; };
 		A54CF2F2184EAB2400237F19 /* ScriptValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptValue.cpp; sourceTree = "<group>"; };
@@ -8413,8 +8410,6 @@
 				A5FD0078189B051000633231 /* ConsoleMessage.h */,
 				A57D23EF1891B5B40031C7FA /* ContentSearchUtilities.cpp */,
 				A57D23F01891B5B40031C7FA /* ContentSearchUtilities.h */,
-				A54982011891D0B00081E5B8 /* EventLoop.cpp */,
-				A54982021891D0B00081E5B8 /* EventLoop.h */,
 				A5FD0072189B038C00633231 /* IdentifiersFactory.cpp */,
 				A5FD0073189B038C00633231 /* IdentifiersFactory.h */,
 				A513E5B5185B8BD3007E95AD /* InjectedScript.cpp */,
@@ -9320,7 +9315,6 @@
 				E3EE137621FBD43500D83C4B /* ErrorType.h in Headers */,
 				14AD910C1DCA92940014F9FE /* EvalCodeBlock.h in Headers */,
 				147341D21DC02E2E00AA29BA /* EvalExecutable.h in Headers */,
-				A54982041891D0B00081E5B8 /* EventLoop.h in Headers */,
 				FE1C0FFD1B193E9800B53FCA /* Exception.h in Headers */,
 				FE6029D91D6E1E4F0030204D /* ExceptionEventLocation.h in Headers */,
 				0F12DE101979D5FD0006FF4E /* ExceptionFuzz.h in Headers */,
diff --git a/Source/JavaScriptCore/Sources.txt b/Source/JavaScriptCore/Sources.txt
index 82db982..7ced68b 100644
--- a/Source/JavaScriptCore/Sources.txt
+++ b/Source/JavaScriptCore/Sources.txt
@@ -553,7 +553,6 @@
 inspector/AsyncStackTrace.cpp
 inspector/ConsoleMessage.cpp
 inspector/ContentSearchUtilities.cpp
-inspector/EventLoop.cpp
 inspector/IdentifiersFactory.cpp
 inspector/InjectedScript.cpp
 inspector/InjectedScriptBase.cpp
diff --git a/Source/JavaScriptCore/inspector/EventLoop.cpp b/Source/JavaScriptCore/inspector/EventLoop.cpp
deleted file mode 100644
index 7af75c1..0000000
--- a/Source/JavaScriptCore/inspector/EventLoop.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2011 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. ``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
- * 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"
-
-#if OS(WINDOWS)
-#include <windows.h>
-#elif USE(GLIB)
-#include <glib.h>
-#endif
-
-namespace Inspector {
-
-#if USE(CF) && !OS(WINDOWS)
-CFStringRef EventLoop::remoteInspectorRunLoopMode()
-{
-    return CFSTR("com.apple.JavaScriptCore.remote-inspector-runloop-mode");
-}
-#endif
-
-void EventLoop::cycle()
-{
-#if OS(WINDOWS)
-    MSG msg;
-    if (!GetMessage(&msg, 0, 0, 0)) {
-        m_ended = true;
-        return;
-    }
-    TranslateMessage(&msg);
-    DispatchMessage(&msg);
-#elif PLATFORM(WATCHOS)
-    // FIXME: <rdar://problem/25972777>. In order for auto-attach to work, we need to
-    // run in the default run loop mode otherwise we do not receive the XPC messages
-    // necessary to setup the relay connection and negotiate an auto-attach debugger.
-    CFTimeInterval timeInterval = 0.05;
-    CFRunLoopRunInMode(kCFRunLoopDefaultMode, timeInterval, true);
-#elif USE(CF)
-    // Run the RunLoop in a custom run loop mode to prevent default observers
-    // to run and potentially evaluate JavaScript in this context while we are
-    // nested. Only the debugger should control things until we continue.
-    // FIXME: This is not a perfect solution, as background threads are not
-    // paused and can still access and evalute script in the JSContext.
-    CFTimeInterval timeInterval = 0.05;
-    CFRunLoopRunInMode(remoteInspectorRunLoopMode(), timeInterval, true);
-#elif USE(GLIB)
-    g_main_context_iteration(NULL, FALSE);
-#endif
-}
-
-} // namespace Inspector
diff --git a/Source/JavaScriptCore/inspector/EventLoop.h b/Source/JavaScriptCore/inspector/EventLoop.h
deleted file mode 100644
index 1625a6b..0000000
--- a/Source/JavaScriptCore/inspector/EventLoop.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2008 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. ``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
- * 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 <wtf/Noncopyable.h>
-
-#if USE(CF) && !OS(WINDOWS)
-#include <CoreFoundation/CFRunLoop.h>
-#endif
-
-namespace Inspector {
-
-class EventLoop {
-    WTF_MAKE_NONCOPYABLE(EventLoop);
-public:
-    EventLoop()
-        : m_ended(false)
-    {
-    }
-
-    void cycle();
-    bool ended() const { return m_ended; }
-
-#if USE(CF) && !OS(WINDOWS)
-    static CFStringRef remoteInspectorRunLoopMode();
-#endif
-
-private:
-    bool m_ended;
-};
-
-} // namespace Inspector
diff --git a/Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.cpp b/Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.cpp
index 667438b..6e279a3 100644
--- a/Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.cpp
+++ b/Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.cpp
@@ -26,9 +26,10 @@
 #include "config.h"
 #include "JSGlobalObjectScriptDebugServer.h"
 
-#include "EventLoop.h"
+#include <wtf/RunLoop.h>
 #include "JSCInlines.h"
 #include "JSLock.h"
+#include "RemoteInspectionTarget.h"
 
 using namespace JSC;
 
@@ -57,9 +58,28 @@
     // Drop all locks so another thread can work in the VM while we are nested.
     JSC::JSLock::DropAllLocks dropAllLocks(&m_globalObject.vm());
 
-    EventLoop loop;
-    while (!m_doneProcessingDebuggerEvents && !loop.ended())
-        loop.cycle();
+    while (!m_doneProcessingDebuggerEvents) {
+        if (RunLoop::cycle(JSGlobalObjectScriptDebugServer::runLoopMode()) == RunLoop::CycleResult::Stop)
+            break;
+    }
+}
+
+String JSGlobalObjectScriptDebugServer::runLoopMode()
+{
+#if USE(CF) && !PLATFORM(WATCHOS)
+    // Run the RunLoop in a custom run loop mode to prevent default observers
+    // to run and potentially evaluate JavaScript in this context while we are
+    // nested. Only the debugger should control things until we continue.
+    // FIXME: This is not a perfect solution, as background threads are not
+    // paused and can still access and evalute script in the JSContext.
+
+    // FIXME: <rdar://problem/25972777>. On watchOS, in order for auto-attach to work,
+    // we need to run in the default run loop mode otherwise we do not receive the XPC messages
+    // necessary to setup the relay connection and negotiate an auto-attach debugger.
+    return "com.apple.JavaScriptCore.remote-inspector-runloop-mode"_s;
+#else
+    return { };
+#endif
 }
 
 } // namespace Inspector
diff --git a/Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.h b/Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.h
index 431ddcd9..92d75c9 100644
--- a/Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.h
+++ b/Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.h
@@ -38,6 +38,8 @@
 
     JSC::JSGlobalObject& globalObject() const { return m_globalObject; }
 
+    static String runLoopMode();
+
 private:
     void attachDebugger() override;
     void detachDebugger(bool isBeingDestroyed) override;
diff --git a/Source/JavaScriptCore/inspector/remote/RemoteInspectionTarget.cpp b/Source/JavaScriptCore/inspector/remote/RemoteInspectionTarget.cpp
index 5d5f3eb..1febaef 100644
--- a/Source/JavaScriptCore/inspector/remote/RemoteInspectionTarget.cpp
+++ b/Source/JavaScriptCore/inspector/remote/RemoteInspectionTarget.cpp
@@ -28,8 +28,9 @@
 
 #if ENABLE(REMOTE_INSPECTOR)
 
-#include "EventLoop.h"
+#include "JSGlobalObjectScriptDebugServer.h"
 #include "RemoteInspector.h"
+#include <wtf/RunLoop.h>
 
 namespace Inspector {
 
@@ -57,9 +58,10 @@
     ASSERT(m_allowed);
     ASSERT(automaticInspectionAllowed());
 
-    EventLoop loop;
-    while (RemoteInspector::singleton().waitingForAutomaticInspection(targetIdentifier()) && !loop.ended())
-        loop.cycle();
+    while (RemoteInspector::singleton().waitingForAutomaticInspection(targetIdentifier())) {
+        if (RunLoop::cycle(JSGlobalObjectScriptDebugServer::runLoopMode()) == RunLoop::CycleResult::Stop)
+            break;
+    }
 }
 
 void RemoteInspectionTarget::unpauseForInitializedInspector()
diff --git a/Source/JavaScriptCore/inspector/remote/cocoa/RemoteConnectionToTargetCocoa.mm b/Source/JavaScriptCore/inspector/remote/cocoa/RemoteConnectionToTargetCocoa.mm
index 9730db8..3c62825 100644
--- a/Source/JavaScriptCore/inspector/remote/cocoa/RemoteConnectionToTargetCocoa.mm
+++ b/Source/JavaScriptCore/inspector/remote/cocoa/RemoteConnectionToTargetCocoa.mm
@@ -28,12 +28,13 @@
 
 #if ENABLE(REMOTE_INSPECTOR)
 
-#import "EventLoop.h"
+#import "JSGlobalObjectScriptDebugServer.h"
 #import "RemoteAutomationTarget.h"
 #import "RemoteInspectionTarget.h"
 #import "RemoteInspector.h"
 #import <dispatch/dispatch.h>
 #import <wtf/Optional.h>
+#import <wtf/RunLoop.h>
 
 #if PLATFORM(IOS_FAMILY)
 #import <wtf/ios/WebCoreThread.h>
@@ -87,7 +88,9 @@
 
         // Add to the default run loop mode for default handling, and the JSContext remote inspector run loop mode when paused.
         CFRunLoopAddSource(CFRunLoopGetMain(), rwiRunLoopSource, kCFRunLoopDefaultMode);
-        CFRunLoopAddSource(CFRunLoopGetMain(), rwiRunLoopSource, EventLoop::remoteInspectorRunLoopMode());
+        auto mode = JSGlobalObjectScriptDebugServer::runLoopMode();
+        if (!mode.isNull())
+            CFRunLoopAddSource(CFRunLoopGetMain(), rwiRunLoopSource, mode.createCFString().get());
     });
 }
 
@@ -258,7 +261,9 @@
     m_runLoopSource = adoptCF(CFRunLoopSourceCreate(kCFAllocatorDefault, 1, &runLoopSourceContext));
 
     CFRunLoopAddSource(m_runLoop.get(), m_runLoopSource.get(), kCFRunLoopDefaultMode);
-    CFRunLoopAddSource(m_runLoop.get(), m_runLoopSource.get(), EventLoop::remoteInspectorRunLoopMode());
+    auto mode = JSGlobalObjectScriptDebugServer::runLoopMode();
+    if (!mode.isNull())
+        CFRunLoopAddSource(m_runLoop.get(), m_runLoopSource.get(), mode.createCFString().get());
 }
 
 void RemoteConnectionToTarget::teardownRunLoop()
@@ -267,7 +272,9 @@
         return;
 
     CFRunLoopRemoveSource(m_runLoop.get(), m_runLoopSource.get(), kCFRunLoopDefaultMode);
-    CFRunLoopRemoveSource(m_runLoop.get(), m_runLoopSource.get(), EventLoop::remoteInspectorRunLoopMode());
+    auto mode = JSGlobalObjectScriptDebugServer::runLoopMode();
+    if (!mode.isNull())
+        CFRunLoopRemoveSource(m_runLoop.get(), m_runLoopSource.get(), mode.createCFString().get());
 
     m_runLoop = nullptr;
     m_runLoopSource = nullptr;
diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog
index ef97fb1..a5a7555 100644
--- a/Source/WTF/ChangeLog
+++ b/Source/WTF/ChangeLog
@@ -1,3 +1,23 @@
+2019-10-08  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Make WebInspector's remote debug EventLoop code into RunLoop
+        https://bugs.webkit.org/show_bug.cgi?id=202716
+
+        Reviewed by Joseph Pecoraro.
+
+        This patch merges WebInspector's EventLoop code into RunLoop as a static function.
+
+        * wtf/RunLoop.h:
+        (WTF::RunLoop::cycle):
+        * wtf/cf/RunLoopCF.cpp:
+        (WTF::RunLoop::cycle): Added.
+        * wtf/generic/RunLoopGeneric.cpp:
+        (WTF::RunLoop::cycle): Added.
+        * wtf/glib/RunLoopGLib.cpp:
+        (WTF::RunLoop::cycle): Added.
+        * wtf/win/RunLoopWin.cpp:
+        (WTF::RunLoop::cycle): Added.
+
 2019-10-10  Ryosuke Niwa  <rniwa@webkit.org>
 
         Make it safe to store a ThreadSafeRefCounted object in Ref & RefPtr safe inside its destructor
diff --git a/Source/WTF/wtf/PlatformMac.cmake b/Source/WTF/wtf/PlatformMac.cmake
index c674ba3..39d2fea 100644
--- a/Source/WTF/wtf/PlatformMac.cmake
+++ b/Source/WTF/wtf/PlatformMac.cmake
@@ -64,6 +64,7 @@
 
     mac/DeprecatedSymbolsUsedBySafari.mm
     mac/FileSystemMac.mm
+    mac/RunLoopMac.mm
     mac/SchedulePairMac.mm
 
     posix/FileSystemPOSIX.cpp
diff --git a/Source/WTF/wtf/RunLoop.h b/Source/WTF/wtf/RunLoop.h
index d615e07..9de8859 100644
--- a/Source/WTF/wtf/RunLoop.h
+++ b/Source/WTF/wtf/RunLoop.h
@@ -35,6 +35,7 @@
 #include <wtf/RetainPtr.h>
 #include <wtf/Seconds.h>
 #include <wtf/ThreadingPrimitives.h>
+#include <wtf/text/WTFString.h>
 
 #if USE(GLIB_EVENT_LOOP)
 #include <wtf/glib/GRefPtr.h>
@@ -60,6 +61,9 @@
     WTF_EXPORT_PRIVATE void stop();
     WTF_EXPORT_PRIVATE void wakeUp();
 
+    enum class CycleResult { Continue, Stop };
+    WTF_EXPORT_PRIVATE CycleResult static cycle(const String& = { });
+
 #if USE(COCOA_EVENT_LOOP)
     WTF_EXPORT_PRIVATE void runForDuration(Seconds duration);
 #endif
diff --git a/Source/WTF/wtf/cf/RunLoopCF.cpp b/Source/WTF/wtf/cf/RunLoopCF.cpp
index bd5d8d0..27d3fe2 100644
--- a/Source/WTF/wtf/cf/RunLoopCF.cpp
+++ b/Source/WTF/wtf/cf/RunLoopCF.cpp
@@ -62,6 +62,13 @@
     CFRunLoopWakeUp(m_runLoop.get());
 }
 
+RunLoop::CycleResult RunLoop::cycle(const String& mode)
+{
+    CFTimeInterval timeInterval = 0.05;
+    CFRunLoopRunInMode(mode.isNull() ? kCFRunLoopDefaultMode : mode.createCFString().get(), timeInterval, true);
+    return CycleResult::Continue;
+}
+
 void RunLoop::run()
 {
     AutodrainedPool pool;
diff --git a/Source/WTF/wtf/generic/RunLoopGeneric.cpp b/Source/WTF/wtf/generic/RunLoopGeneric.cpp
index 3c8ebc7..eaf3292 100644
--- a/Source/WTF/wtf/generic/RunLoopGeneric.cpp
+++ b/Source/WTF/wtf/generic/RunLoopGeneric.cpp
@@ -218,6 +218,11 @@
     wakeUp(locker);
 }
 
+RunLoop::CycleResult RunLoop::cycle(const String&)
+{
+    iterate();
+}
+
 void RunLoop::schedule(const AbstractLocker&, Ref<TimerBase::ScheduledTask>&& task)
 {
     m_schedules.append(task.ptr());
diff --git a/Source/WTF/wtf/glib/RunLoopGLib.cpp b/Source/WTF/wtf/glib/RunLoopGLib.cpp
index fb211d0..01ef422 100644
--- a/Source/WTF/wtf/glib/RunLoopGLib.cpp
+++ b/Source/WTF/wtf/glib/RunLoopGLib.cpp
@@ -123,6 +123,12 @@
     g_source_set_ready_time(m_source.get(), 0);
 }
 
+RunLoop::CycleResult RunLoop::cycle(const String&)
+{
+    g_main_context_iteration(NULL, FALSE);
+    return CycleResult::Continue;
+}
+
 class DispatchAfterContext {
     WTF_MAKE_FAST_ALLOCATED;
 public:
diff --git a/Source/WTF/wtf/win/RunLoopWin.cpp b/Source/WTF/wtf/win/RunLoopWin.cpp
index 670914b..ad0f447 100644
--- a/Source/WTF/wtf/win/RunLoopWin.cpp
+++ b/Source/WTF/wtf/win/RunLoopWin.cpp
@@ -120,6 +120,18 @@
     ::PostMessage(m_runLoopMessageWindow, PerformWorkMessage, reinterpret_cast<WPARAM>(this), 0);
 }
 
+RunLoop::CycleResult RunLoop::cycle(const String&)
+{
+    MSG message;
+    if (!::GetMessage(&message, 0, 0, 0))
+        return CycleResult::Stop;
+
+    ::TranslateMessage(&message);
+    ::DispatchMessage(&message);
+
+    return CycleResult::Continue;
+}
+
 // RunLoop::Timer
 
 void RunLoop::TimerBase::timerFired()
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 315710a..c99645e 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,24 @@
+2019-10-08  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Make WebInspector's remote debug EventLoop code into RunLoop
+        https://bugs.webkit.org/show_bug.cgi?id=202716
+
+        Reviewed by Joseph Pecoraro.
+
+        Use RunLoop::cycle.
+
+        * PlatformFTW.cmake:
+        * PlatformPlayStation.cmake:
+        * PlatformWin.cmake:
+        * SourcesCocoa.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * inspector/PageScriptDebugServer.cpp:
+        (WebCore::PageScriptDebugServer::runEventLoopWhilePausedInternal):
+        * platform/SourcesGLib.txt:
+        * platform/glib/EventLoopGlib.cpp: Removed.
+        * platform/playstation/EventLoopPlayStation.cpp: Removed.
+        * platform/win/EventLoopWin.cpp: Removed.
+
 2019-10-11  Dean Jackson  <dino@apple.com>
 
         REGRESSION (r244239) Layout Test fast/canvas/canvas-too-large-to-draw.html is failing
diff --git a/Source/WebCore/PlatformFTW.cmake b/Source/WebCore/PlatformFTW.cmake
index 6c3f8c1..e674a19 100644
--- a/Source/WebCore/PlatformFTW.cmake
+++ b/Source/WebCore/PlatformFTW.cmake
@@ -117,7 +117,6 @@
     platform/win/DragDataWin.cpp
     platform/win/DragImageDirect2D.cpp
     platform/win/DragImageWin.cpp
-    platform/win/EventLoopWin.cpp
     platform/win/GDIObjectCounter.cpp
     platform/win/GDIUtilities.cpp
     platform/win/ImportedFunctionsEnumerator.cpp
diff --git a/Source/WebCore/PlatformPlayStation.cmake b/Source/WebCore/PlatformPlayStation.cmake
index ad57e78..2678c31 100644
--- a/Source/WebCore/PlatformPlayStation.cmake
+++ b/Source/WebCore/PlatformPlayStation.cmake
@@ -58,7 +58,6 @@
     platform/network/playstation/CurlSSLHandlePlayStation.cpp
     platform/network/playstation/NetworkStateNotifierPlayStation.cpp
 
-    platform/playstation/EventLoopPlayStation.cpp
     platform/playstation/MIMETypeRegistryPlayStation.cpp
     platform/playstation/PlatformScreenPlayStation.cpp
     platform/playstation/ScrollbarThemePlayStation.cpp
diff --git a/Source/WebCore/PlatformWin.cmake b/Source/WebCore/PlatformWin.cmake
index a2d1fa6..8d060c8 100644
--- a/Source/WebCore/PlatformWin.cmake
+++ b/Source/WebCore/PlatformWin.cmake
@@ -82,7 +82,6 @@
     platform/win/DefWndProcWindowClass.cpp
     platform/win/DragDataWin.cpp
     platform/win/DragImageWin.cpp
-    platform/win/EventLoopWin.cpp
     platform/win/GDIObjectCounter.cpp
     platform/win/GDIUtilities.cpp
     platform/win/KeyEventWin.cpp
diff --git a/Source/WebCore/SourcesCocoa.txt b/Source/WebCore/SourcesCocoa.txt
index 0957943..d84847c 100644
--- a/Source/WebCore/SourcesCocoa.txt
+++ b/Source/WebCore/SourcesCocoa.txt
@@ -386,7 +386,6 @@
 platform/ios/DeviceMotionClientIOS.mm
 platform/ios/DeviceOrientationClientIOS.mm
 platform/ios/DragImageIOS.mm
-platform/ios/EventLoopIOS.mm
 platform/ios/KeyEventIOS.mm
 platform/ios/LegacyTileCache.mm
 platform/ios/LegacyTileGrid.mm
@@ -436,7 +435,6 @@
 platform/mac/CursorMac.mm
 platform/mac/DragDataMac.mm
 platform/mac/DragImageMac.mm
-platform/mac/EventLoopMac.mm
 platform/mac/KeyEventMac.mm @no-unify
 platform/mac/PlaybackSessionInterfaceMac.mm @no-unify
 platform/mac/LocalCurrentGraphicsContext.mm
diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
index 4955404..aea3df3 100644
--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -619,7 +619,6 @@
 		1C73A71521857587004CCEA5 /* TextDecorationThickness.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CB6B4F8217B83930093B9CD /* TextDecorationThickness.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1C81B95A0E97330800266E07 /* InspectorController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C81B9560E97330800266E07 /* InspectorController.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1C81B95C0E97330800266E07 /* InspectorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C81B9580E97330800266E07 /* InspectorClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		1CA19E160DC255CA0065A994 /* EventLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CA19E150DC255CA0065A994 /* EventLoop.h */; };
 		1CAF34810A6C405200ABE06E /* WebScriptObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CAF347E0A6C405200ABE06E /* WebScriptObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1CAF34820A6C405200ABE06E /* WebScriptObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CAF347F0A6C405200ABE06E /* WebScriptObject.mm */; };
 		1CAF34830A6C405200ABE06E /* WebScriptObjectPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CAF34800A6C405200ABE06E /* WebScriptObjectPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -6399,8 +6398,6 @@
 		1CA0C2E521EED12A00A11860 /* WHLSLFunctionStageChecker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLFunctionStageChecker.h; sourceTree = "<group>"; };
 		1CA0C2EA21EED6F500A11860 /* WHLSLLiteralTypeChecker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLLiteralTypeChecker.h; sourceTree = "<group>"; };
 		1CA0C2EC21EED6F600A11860 /* WHLSLLiteralTypeChecker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLLiteralTypeChecker.cpp; sourceTree = "<group>"; };
-		1CA19E030DC255950065A994 /* EventLoopMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EventLoopMac.mm; sourceTree = "<group>"; };
-		1CA19E150DC255CA0065A994 /* EventLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventLoop.h; sourceTree = "<group>"; };
 		1CAA82F62242AE0500E84BBB /* WHLSLPropertyResolver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLPropertyResolver.cpp; sourceTree = "<group>"; };
 		1CAA82F72242AE0500E84BBB /* WHLSLPropertyResolver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLPropertyResolver.h; sourceTree = "<group>"; };
 		1CAF347E0A6C405200ABE06E /* WebScriptObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptObject.h; sourceTree = "<group>"; };
@@ -6530,7 +6527,6 @@
 		26F0C89A1A2EC110002794F8 /* ContentExtensionRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentExtensionRule.h; sourceTree = "<group>"; };
 		26F0C89D1A2EC3BE002794F8 /* ContentExtensionsBackend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentExtensionsBackend.cpp; sourceTree = "<group>"; };
 		26F0C89E1A2EC3BE002794F8 /* ContentExtensionsBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentExtensionsBackend.h; sourceTree = "<group>"; };
-		26F40D4914904A6300CA67C4 /* EventLoopIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EventLoopIOS.mm; sourceTree = "<group>"; };
 		26F756AE1B3B65AC0005DD79 /* MutableRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MutableRange.h; sourceTree = "<group>"; };
 		26F756AF1B3B65AC0005DD79 /* MutableRangeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MutableRangeList.h; sourceTree = "<group>"; };
 		26F756B21B3B66F70005DD79 /* ImmutableNFA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImmutableNFA.h; sourceTree = "<group>"; };
@@ -20188,7 +20184,6 @@
 				A795463D0B5C4C80007B438F /* DragDataMac.mm */,
 				A7CFB3D40B7ED1180070C32D /* DragImageMac.mm */,
 				E1BA66F01742BD8600C20251 /* DynamicLinkerInterposing.h */,
-				1CA19E030DC255950065A994 /* EventLoopMac.mm */,
 				935C476E09AC4D7300A6AAB4 /* KeyEventMac.mm */,
 				F44A5F571FED3830007F5944 /* LegacyNSPasteboardTypes.h */,
 				06E81ED60AB5D5E900C87837 /* LocalCurrentGraphicsContext.h */,
@@ -22559,7 +22554,6 @@
 				31403799124BEA7F00AF40E4 /* DeviceOrientationClientIOS.h */,
 				3140379A124BEA7F00AF40E4 /* DeviceOrientationClientIOS.mm */,
 				0FDA7C22188330A900C954B5 /* DragImageIOS.mm */,
-				26F40D4914904A6300CA67C4 /* EventLoopIOS.mm */,
 				265541371489811C000DFC5D /* KeyEventCodesIOS.h */,
 				265541381489811C000DFC5D /* KeyEventIOS.mm */,
 				E4C3B1F90F0E4161009693F6 /* LegacyTileCache.h */,
@@ -25543,7 +25537,6 @@
 				A7CFB3CF0B7ED10A0070C32D /* DragImage.cpp */,
 				A7CFB3D00B7ED10A0070C32D /* DragImage.h */,
 				1AF5E4D71E5677A9004A1F01 /* DragItem.h */,
-				1CA19E150DC255CA0065A994 /* EventLoop.h */,
 				262EC41C1D110B1F00BA78FC /* EventTrackingRegions.cpp */,
 				262EC4191D078F3D00BA78FC /* EventTrackingRegions.h */,
 				934FE9E40B5CA539003E4A73 /* FileChooser.cpp */,
@@ -29354,7 +29347,6 @@
 				970B728A144FFAC600F00A37 /* EventInterfaces.h in Headers */,
 				935FBC4509BA00B900E230B1 /* EventListener.h in Headers */,
 				AD4495F4141FC08900541EDF /* EventListenerMap.h in Headers */,
-				1CA19E160DC255CA0065A994 /* EventLoop.h in Headers */,
 				83FE7CA81DA9F1B60037237C /* EventModifierInit.h in Headers */,
 				939885C408B7E3D100E707C4 /* EventNames.h in Headers */,
 				9B714E211C91166900AC0E92 /* EventPath.h in Headers */,
diff --git a/Source/WebCore/inspector/PageScriptDebugServer.cpp b/Source/WebCore/inspector/PageScriptDebugServer.cpp
index 55d6619..6b7b0ca 100644
--- a/Source/WebCore/inspector/PageScriptDebugServer.cpp
+++ b/Source/WebCore/inspector/PageScriptDebugServer.cpp
@@ -29,7 +29,6 @@
 
 #include "CommonVM.h"
 #include "Document.h"
-#include "EventLoop.h"
 #include "Frame.h"
 #include "FrameView.h"
 #include "InspectorController.h"
@@ -116,9 +115,10 @@
 
     m_page.incrementNestedRunLoopCount();
 
-    EventLoop loop;
-    while (!m_doneProcessingDebuggerEvents && !loop.ended())
-        loop.cycle();
+    while (!m_doneProcessingDebuggerEvents) {
+        if (RunLoop::cycle() == RunLoop::CycleResult::Stop)
+            break;
+    }
 
     m_page.decrementNestedRunLoopCount();
 }
diff --git a/Source/WebCore/platform/EventLoop.h b/Source/WebCore/platform/EventLoop.h
deleted file mode 100644
index 128e92b..0000000
--- a/Source/WebCore/platform/EventLoop.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2008 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. ``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
- * 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.
- */
-
-#ifndef EventLoop_h
-#define EventLoop_h
-
-#include <wtf/Noncopyable.h>
-
-namespace WebCore {
-
-    class EventLoop {
-        WTF_MAKE_NONCOPYABLE(EventLoop);
-    public:
-        EventLoop()
-            : m_ended(false)
-        {
-        }
-
-        void cycle();
-        bool ended() const { return m_ended; }
-
-    private:
-        bool m_ended;
-    };
-
-} // namespace WebCore
-
-#endif // EventLoop_h
diff --git a/Source/WebCore/platform/SourcesGLib.txt b/Source/WebCore/platform/SourcesGLib.txt
index 756d070..b62259e 100644
--- a/Source/WebCore/platform/SourcesGLib.txt
+++ b/Source/WebCore/platform/SourcesGLib.txt
@@ -24,7 +24,6 @@
 platform/audio/glib/AudioBusGLib.cpp
 
 platform/glib/EventHandlerGLib.cpp
-platform/glib/EventLoopGlib.cpp
 platform/glib/FileMonitorGLib.cpp
 platform/glib/KeyedDecoderGlib.cpp
 platform/glib/KeyedEncoderGlib.cpp
diff --git a/Source/WebCore/platform/glib/EventLoopGlib.cpp b/Source/WebCore/platform/glib/EventLoopGlib.cpp
deleted file mode 100644
index 4ef7b5c..0000000
--- a/Source/WebCore/platform/glib/EventLoopGlib.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2008 Nuanti Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "EventLoop.h"
-
-#include <glib.h>
-
-namespace WebCore {
-
-void EventLoop::cycle()
-{
-    g_main_context_iteration(NULL, FALSE);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/ios/EventLoopIOS.mm b/Source/WebCore/platform/ios/EventLoopIOS.mm
deleted file mode 100644
index ba35c9d..0000000
--- a/Source/WebCore/platform/ios/EventLoopIOS.mm
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2011 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. ``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
- * 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"
-
-#if PLATFORM(IOS_FAMILY)
-
-#include <CoreFoundation/CFRunLoop.h>
-
-namespace WebCore {
-
-void EventLoop::cycle()
-{
-    CFTimeInterval timeInterval = 0.05;
-    CFRunLoopRunInMode(kCFRunLoopDefaultMode, timeInterval, true);
-}
-
-} // namespace WebCore
-
-#endif // PLATFORM(IOS_FAMILY)
diff --git a/Source/WebCore/platform/mac/EventLoopMac.mm b/Source/WebCore/platform/mac/EventLoopMac.mm
deleted file mode 100644
index 81079f1..0000000
--- a/Source/WebCore/platform/mac/EventLoopMac.mm
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2008-2018 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. ``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
- * 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"
-
-#include <wtf/ProcessPrivilege.h>
-
-#if PLATFORM(MAC)
-
-namespace WebCore {
-
-void EventLoop::cycle()
-{
-#if ENABLE(WEBPROCESS_NSRUNLOOP)
-    if (![NSApp isRunning]) {
-        [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.05]];
-        return;
-    }
-    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
-#endif
-    [NSApp setWindowsNeedUpdate:YES];
-    if (NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate dateWithTimeIntervalSinceNow:0.05] inMode:NSDefaultRunLoopMode dequeue:YES])
-        [NSApp sendEvent:event];
-}
-
-} // namespace WebCore
-
-#endif // PLATFORM(MAC)
diff --git a/Source/WebCore/platform/playstation/EventLoopPlayStation.cpp b/Source/WebCore/platform/playstation/EventLoopPlayStation.cpp
deleted file mode 100644
index d433fb1..0000000
--- a/Source/WebCore/platform/playstation/EventLoopPlayStation.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2018 Sony Interactive Entertainment Inc.
- *
- * 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"
-
-#include <wtf/RunLoop.h>
-
-namespace WebCore {
-
-void EventLoop::cycle()
-{
-    RunLoop::iterate();
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/EventLoopWin.cpp b/Source/WebCore/platform/win/EventLoopWin.cpp
deleted file mode 100644
index ece320f..0000000
--- a/Source/WebCore/platform/win/EventLoopWin.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2008 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. ``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
- * 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"
-
-#include <windows.h>
-
-namespace WebCore {
-
-void EventLoop::cycle()
-{
-    MSG msg;
-    if (!GetMessage(&msg, 0, 0, 0)) {
-        m_ended = true;
-        return;
-    }
-
-    TranslateMessage(&msg);
-    DispatchMessage(&msg);
-}
-
-} // namespace WebCore