Adds an event loop abstraction to platform. This abstraction will be
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 May 2008 22:28:32 +0000 (22:28 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 May 2008 22:28:32 +0000 (22:28 +0000)
used by the JavaScriptDebugServer to implement pausing.

Reviewed by Kevin McCullough.

* platform/EventLoop.h: Added.
(WebCore::EventLoop::EventLoop):
(WebCore::EventLoop::ended): Return m_ended.
* platform/mac/EventLoopMac.mm: Added.
(WebCore::EventLoop::cycle): Call nextEventMatchingMask and then sendEvent.
* platform/win/EventLoopWin.cpp: Added.
(WebCore::EventLoop::cycle): Call GetMessage, TranslateMessage and DispatchMessage.
* WebCore.xcodeproj/project.pbxproj: Add new files.
* WebCore.vcproj/WebCore.vcproj: Ditto.

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

WebCore/ChangeLog
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/platform/EventLoop.h [new file with mode: 0644]
WebCore/platform/mac/EventLoopMac.mm [new file with mode: 0644]
WebCore/platform/win/EventLoopWin.cpp [new file with mode: 0644]

index 04c658f..fac2ea3 100644 (file)
@@ -1,5 +1,22 @@
 2008-05-13  Timothy Hatcher  <timothy@apple.com>
 
+        Adds an event loop abstraction to platform. This abstraction will be
+        used by the JavaScriptDebugServer to implement pausing.
+
+        Reviewed by Kevin McCullough.
+
+        * platform/EventLoop.h: Added.
+        (WebCore::EventLoop::EventLoop):
+        (WebCore::EventLoop::ended): Return m_ended.
+        * platform/mac/EventLoopMac.mm: Added.
+        (WebCore::EventLoop::cycle): Call nextEventMatchingMask and then sendEvent.
+        * platform/win/EventLoopWin.cpp: Added.
+        (WebCore::EventLoop::cycle): Call GetMessage, TranslateMessage and DispatchMessage.
+        * WebCore.xcodeproj/project.pbxproj: Add new files.
+        * WebCore.vcproj/WebCore.vcproj: Ditto.
+
+2008-05-13  Timothy Hatcher  <timothy@apple.com>
+
         Breaks out ObjectPropertiesSection from PropertiesSidebarPane
         so it can be used by the Scripts panel's Scope Chain pane.
 
index 5a4876f..d593617 100644 (file)
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\platform\EventLoop.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\platform\FileChooser.cpp"\r
                                >\r
                        </File>\r
                                        >\r
                                </File>\r
                                <File\r
+                                       RelativePath="..\platform\win\EventLoopWin.cpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
                                        RelativePath="..\platform\win\FileChooserWin.cpp"\r
                                        >\r
                                </File>\r
index d6bc031..ab6df3e 100644 (file)
                1C5FAEE70DCFDA6800D58F78 /* JSJavaScriptCallFrameCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C5FAEE60DCFDA6800D58F78 /* JSJavaScriptCallFrameCustom.cpp */; };
                1CA19CAE0DC1145F0065A994 /* JavaScriptCallFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CA19CAC0DC1145F0065A994 /* JavaScriptCallFrame.h */; };
                1CA19CAF0DC1145F0065A994 /* JavaScriptCallFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CA19CAD0DC1145F0065A994 /* JavaScriptCallFrame.cpp */; };
+               1CA19E050DC255950065A994 /* EventLoopMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CA19E030DC255950065A994 /* EventLoopMac.mm */; };
+               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, ); }; };
                1C904DF90BA9D2C80081E9D0 /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
                1CA19CAC0DC1145F0065A994 /* JavaScriptCallFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JavaScriptCallFrame.h; sourceTree = "<group>"; };
                1CA19CAD0DC1145F0065A994 /* JavaScriptCallFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JavaScriptCallFrame.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>"; };
                1CAF347E0A6C405200ABE06E /* WebScriptObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptObject.h; sourceTree = "<group>"; };
                1CAF347F0A6C405200ABE06E /* WebScriptObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebScriptObject.mm; sourceTree = "<group>"; };
                1CAF34800A6C405200ABE06E /* WebScriptObjectPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptObjectPrivate.h; sourceTree = "<group>"; };
                                F58784F002DE375901EA4122 /* CursorMac.mm */,
                                A795463D0B5C4C80007B438F /* DragDataMac.mm */,
                                A7CFB3D40B7ED1180070C32D /* DragImageMac.mm */,
+                               1CA19E030DC255950065A994 /* EventLoopMac.mm */,
                                066C772C0AB603D200238CC4 /* FileChooserMac.mm */,
                                514B3F750C722055000530DF /* FileSystemMac.mm */,
                                935C476C09AC4D6300A6AAB4 /* FoundationExtras.h */,
                                A79546420B5C4CB4007B438F /* DragData.cpp */,
                                A7CFB3D00B7ED10A0070C32D /* DragImage.h */,
                                A7CFB3CF0B7ED10A0070C32D /* DragImage.cpp */,
+                               1CA19E150DC255CA0065A994 /* EventLoop.h */,
                                BC073BA90C399B1F000F5979 /* FloatConversion.h */,
                                934FE9E40B5CA539003E4A73 /* FileChooser.cpp */,
                                066C772A0AB603B700238CC4 /* FileChooser.h */,
                                BCD0FC4F0DBD720B00B2F630 /* DOMRGBColorInternal.h in Headers */,
                                BC99812E0DBE807A008CE9EF /* DOMAbstractViewFrame.h in Headers */,
                                1CA19CAE0DC1145F0065A994 /* JavaScriptCallFrame.h in Headers */,
+                               1CA19E160DC255CA0065A994 /* EventLoop.h in Headers */,
                                511F23180DC160DA004F0032 /* LocalStorageTask.h in Headers */,
                                511F231A0DC160DA004F0032 /* LocalStorageThread.h in Headers */,
                                BC5A12E00DC0414800C9AFAD /* CSSReflectValue.h in Headers */,
                                F916C48D0DB510F80076CD83 /* JSXMLHttpRequestProgressEvent.cpp in Sources */,
                                BCD0FBD00DBD625E00B2F630 /* DOMAbstractView.mm in Sources */,
                                1CA19CAF0DC1145F0065A994 /* JavaScriptCallFrame.cpp in Sources */,
+                               1CA19E050DC255950065A994 /* EventLoopMac.mm in Sources */,
                                511F23170DC160DA004F0032 /* LocalStorageTask.cpp in Sources */,
                                511F23190DC160DA004F0032 /* LocalStorageThread.cpp in Sources */,
                                BC5A12DF0DC0414800C9AFAD /* CSSReflectValue.cpp in Sources */,
diff --git a/WebCore/platform/EventLoop.h b/WebCore/platform/EventLoop.h
new file mode 100644 (file)
index 0000000..6687c23
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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 : Noncopyable {
+    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/WebCore/platform/mac/EventLoopMac.mm b/WebCore/platform/mac/EventLoopMac.mm
new file mode 100644 (file)
index 0000000..05ef33a
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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"
+
+namespace WebCore {
+
+void EventLoop::cycle()
+{
+    // FIXME: Should this use NSRunLoopCommonModes? Switching to NSRunLoopCommonModes causes Safari to hang in a tight loop.
+    [NSApp setWindowsNeedUpdate:YES];
+    NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES];
+    [NSApp sendEvent:event];
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/win/EventLoopWin.cpp b/WebCore/platform/win/EventLoopWin.cpp
new file mode 100644 (file)
index 0000000..aae107d
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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"
+
+namespace WebCore {
+
+void EventLoop::cycle()
+{
+    MSG msg;
+    if (!GetMessage(&msg, 0, 0, 0)) {
+        m_ended = true;
+        return;
+    }
+
+    TranslateMessage(&msg);
+    DispatchMessage(&msg);
+}
+
+} // namespace WebCore