Add events to represent the start/end of a gesture scroll
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jan 2011 01:55:07 +0000 (01:55 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jan 2011 01:55:07 +0000 (01:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=53215

Reviewed by Maciej Stachowiak.

Source/JavaScriptCore:

* wtf/Platform.h: Add ENABLE for gesture events.

Source/WebCore:

* WebCore.exp.in:
Add new file.

* WebCore.xcodeproj/project.pbxproj:
Add new file.

* page/EventHandler.cpp:
(WebCore::EventHandler::handleGestureEvent):
* page/EventHandler.h:
Add entry point for handling gesture events.

* platform/PlatformGestureEvent.h: Added.
(WebCore::PlatformGestureEvent::PlatformGestureEvent):
(WebCore::PlatformGestureEvent::type):
(WebCore::PlatformGestureEvent::position):
(WebCore::PlatformGestureEvent::globalPosition):
(WebCore::PlatformGestureEvent::timestamp):
Add platform agnostic representation of a gesture event.

Source/WebKit2:

* Scripts/webkit2/messages.py:
* Shared/WebEvent.h:
(WebKit::WebGestureEvent::WebGestureEvent):
(WebKit::WebGestureEvent::position):
(WebKit::WebGestureEvent::globalPosition):
* Shared/WebEventConversion.cpp:
(WebKit::WebKit2PlatformGestureEvent::WebKit2PlatformGestureEvent):
(WebKit::platform):
* Shared/WebEventConversion.h:
* Shared/WebGestureEvent.cpp: Added.
(WebKit::WebGestureEvent::WebGestureEvent):
(WebKit::WebGestureEvent::encode):
(WebKit::WebGestureEvent::decode):
(WebKit::WebGestureEvent::isGestureEventType):
* Shared/mac/WebEventFactory.h:
* Shared/mac/WebEventFactory.mm:
(WebKit::gestureEventTypeForEvent):
(WebKit::WebEventFactory::createWebGestureEvent):
* UIProcess/API/mac/WKView.mm:
(-[WKView shortCircuitedEndGestureWithEvent:]):
(-[WKView beginGestureWithEvent:]):
(-[WKView viewDidMoveToWindow]):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::handleGestureEvent):
(WebKit::WebPageProxy::didReceiveEvent):
* UIProcess/WebPageProxy.h:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::handleGestureEvent):
(WebKit::WebPage::gestureEvent):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
Pipe gesture events down to WebCore.

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

23 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/wtf/Platform.h
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h
Source/WebCore/platform/PlatformGestureEvent.h [new file with mode: 0644]
Source/WebKit2/ChangeLog
Source/WebKit2/Scripts/webkit2/messages.py
Source/WebKit2/Shared/WebEvent.h
Source/WebKit2/Shared/WebEventConversion.cpp
Source/WebKit2/Shared/WebEventConversion.h
Source/WebKit2/Shared/WebGestureEvent.cpp [new file with mode: 0644]
Source/WebKit2/Shared/mac/WebEventFactory.h
Source/WebKit2/Shared/mac/WebEventFactory.mm
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

index 2075202..dee07e6 100644 (file)
@@ -1,3 +1,12 @@
+2011-01-26  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Maciej Stachowiak.
+
+        Add events to represent the start/end of a gesture scroll
+        https://bugs.webkit.org/show_bug.cgi?id=53215
+
+        * wtf/Platform.h: Add ENABLE for gesture events. 
+
 2011-01-26  Yael Aharon  <yael.aharon@nokia.com>
 
         Reviewed by Laszlo Gombos.
index e4428c5..b638a56 100644 (file)
 #endif
 
 #if PLATFORM(MAC) && !PLATFORM(IOS)
-#define WTF_PLATFORM_CF 1
-#define WTF_USE_PTHREADS 1
-#define HAVE_PTHREAD_RWLOCK 1
 #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_TIGER) && CPU(X86_64)
 #define WTF_USE_PLUGIN_HOST_PROCESS 1
 #endif
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+#define ENABLE_GESTURE_EVENTS 1
+#endif
 #if !defined(ENABLE_JAVA_BRIDGE)
 #define ENABLE_JAVA_BRIDGE 1
 #endif
 #if !defined(ENABLE_DASHBOARD_SUPPORT)
 #define ENABLE_DASHBOARD_SUPPORT 1
 #endif
+#define WTF_PLATFORM_CF 1
+#define WTF_USE_PTHREADS 1
+#define HAVE_PTHREAD_RWLOCK 1
 #define HAVE_READLINE 1
 #define HAVE_RUNLOOP_TIMER 1
 #define ENABLE_FULLSCREEN_API 1
index 545ea65..49b4af4 100644 (file)
@@ -1,3 +1,29 @@
+2011-01-26  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Maciej Stachowiak.
+
+        Add events to represent the start/end of a gesture scroll
+        https://bugs.webkit.org/show_bug.cgi?id=53215
+
+        * WebCore.exp.in: 
+        Add new file.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        Add new file.
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleGestureEvent):
+        * page/EventHandler.h:
+        Add entry point for handling gesture events.
+
+        * platform/PlatformGestureEvent.h: Added.
+        (WebCore::PlatformGestureEvent::PlatformGestureEvent):
+        (WebCore::PlatformGestureEvent::type):
+        (WebCore::PlatformGestureEvent::position):
+        (WebCore::PlatformGestureEvent::globalPosition):
+        (WebCore::PlatformGestureEvent::timestamp):
+        Add platform agnostic representation of a gesture event.
+
 2011-01-26  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Dave Hyatt.
index acc6cb9..db5feb2 100644 (file)
@@ -781,7 +781,6 @@ __ZN7WebCore8GradientC1ERKNS_10FloatPointES3_
 __ZN7WebCore8IntPointC1ERK8_NSPoint
 __ZN7WebCore8PositionC1EN3WTF10PassRefPtrINS_4NodeEEEi
 __ZN7WebCore8Settings14setJavaEnabledEb
-__ZN7WebCore8Settings18setWebAudioEnabledEb
 __ZN7WebCore8Settings15setWebGLEnabledEb
 __ZN7WebCore8Settings16setUsesPageCacheEb
 __ZN7WebCore8Settings17setPluginsEnabledEb
@@ -790,6 +789,7 @@ __ZN7WebCore8Settings18setDefaultFontSizeEi
 __ZN7WebCore8Settings18setFixedFontFamilyERKN3WTF12AtomicStringE
 __ZN7WebCore8Settings18setMinimumFontSizeEi
 __ZN7WebCore8Settings18setSerifFontFamilyERKN3WTF12AtomicStringE
+__ZN7WebCore8Settings18setWebAudioEnabledEb
 __ZN7WebCore8Settings19setShowDebugBordersEb
 __ZN7WebCore8Settings20setCursiveFontFamilyERKN3WTF12AtomicStringE
 __ZN7WebCore8Settings20setFantasyFontFamilyERKN3WTF12AtomicStringE
@@ -875,9 +875,9 @@ __ZN7WebCore9FrameView23updateCanHaveScrollbarsEv
 __ZN7WebCore9FrameView24forceLayoutForPaginationERKNS_9FloatSizeEfNS_5Frame19AdjustViewSizeOrNotE
 __ZN7WebCore9FrameView26adjustPageHeightDeprecatedEPffff
 __ZN7WebCore9FrameView29setShouldUpdateWhileOffscreenEb
-__ZN7WebCore9FrameView38syncCompositingStateIncludingSubframesEv
 __ZN7WebCore9FrameView37updateLayoutAndStyleIfNeededRecursiveEv
 __ZN7WebCore9FrameView38scrollPositionChangedViaPlatformWidgetEv
+__ZN7WebCore9FrameView38syncCompositingStateIncludingSubframesEv
 __ZN7WebCore9FrameView6createEPNS_5FrameE
 __ZN7WebCore9FrameView6createEPNS_5FrameERKNS_7IntSizeE
 __ZN7WebCore9HTMLNames10listingTagE
@@ -1683,3 +1683,6 @@ __ZN7WebCore6Editor13uppercaseWordEv
 __ZN7WebCore6Editor14capitalizeWordEv
 #endif
 
+#if ENABLE(GESTURE_EVENTS)
+__ZN7WebCore12EventHandler18handleGestureEventERKNS_20PlatformGestureEventE
+#endif
index cc28227..2f221fb 100644 (file)
                BC94D14F0C275C68006BC617 /* JSHistory.h in Headers */ = {isa = PBXBuildFile; fileRef = BC94D14D0C275C68006BC617 /* JSHistory.h */; };
                BC94D1530C275C8B006BC617 /* History.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC94D1500C275C8B006BC617 /* History.cpp */; };
                BC94D1540C275C8B006BC617 /* History.h in Headers */ = {isa = PBXBuildFile; fileRef = BC94D1510C275C8B006BC617 /* History.h */; };
+               BC9585E112F0989500755821 /* PlatformGestureEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = BC9585DF12F0989500755821 /* PlatformGestureEvent.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BC96DB430F3A880E00573CB3 /* RenderBoxModelObject.h in Headers */ = {isa = PBXBuildFile; fileRef = BC96DB420F3A880E00573CB3 /* RenderBoxModelObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BC96DB460F3A882200573CB3 /* RenderBoxModelObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC96DB450F3A882200573CB3 /* RenderBoxModelObject.cpp */; };
                BC97E23A109144950010D361 /* HTMLAllCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = BC97E238109144950010D361 /* HTMLAllCollection.h */; };
                BC94D1500C275C8B006BC617 /* History.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = History.cpp; sourceTree = "<group>"; };
                BC94D1510C275C8B006BC617 /* History.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = History.h; sourceTree = "<group>"; };
                BC94D1520C275C8B006BC617 /* History.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = History.idl; sourceTree = "<group>"; };
+               BC9585DF12F0989500755821 /* PlatformGestureEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformGestureEvent.h; sourceTree = "<group>"; };
                BC96DB420F3A880E00573CB3 /* RenderBoxModelObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderBoxModelObject.h; sourceTree = "<group>"; };
                BC96DB450F3A882200573CB3 /* RenderBoxModelObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderBoxModelObject.cpp; sourceTree = "<group>"; };
                BC97E238109144950010D361 /* HTMLAllCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLAllCollection.h; sourceTree = "<group>"; };
                                BC772C4D0C4EB3040083285F /* MIMETypeRegistry.h */,
                                4B2708C50AF19EE40065127F /* Pasteboard.h */,
                                935C476609AC4D4300A6AAB4 /* PlatformKeyboardEvent.h */,
+                               BC9585DF12F0989500755821 /* PlatformGestureEvent.h */,
                                932871BF0B20DEB70049035A /* PlatformMenuDescription.h */,
                                935C476709AC4D4300A6AAB4 /* PlatformMouseEvent.h */,
                                BCEC01D60C274EB4009F4EC9 /* PlatformScreen.h */,
                                97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
                                BC8AE34F12EA096A00EB3AE6 /* ScrollableArea.h in Headers */,
                                4F2D205412EAE7B3005C2874 /* InspectorAgent.h in Headers */,
+                               BC9585E112F0989500755821 /* PlatformGestureEvent.h in Headers */,
                                E134F5AB12EE343F004EC58D /* IntRectHash.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
index 8cc8626..b2988cb 100644 (file)
 #include <wtf/CurrentTime.h>
 #include <wtf/StdLibExtras.h>
 
+#if ENABLE(GESTURE_EVENTS)
+#include "PlatformGestureEvent.h"
+#endif
+
 #if ENABLE(SVG)
 #include "SVGDocument.h"
 #include "SVGElementInstance.h"
@@ -2035,6 +2039,14 @@ void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv
         m_previousWheelScrolledNode = stopNode;
 }
 
+#if ENABLE(GESTURE_EVENTS)
+bool EventHandler::handleGestureEvent(const PlatformGestureEvent&)
+{
+    // FIXME: Handle gesture events.
+    return true;
+}
+#endif
+
 #if ENABLE(CONTEXT_MENUS)
 bool EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event)
 {
index d12a56e..6a7aac9 100644 (file)
@@ -53,9 +53,9 @@ class EventTarget;
 class FloatPoint;
 class FloatQuad;
 class Frame;
+class HTMLFrameSetElement;
 class HitTestRequest;
 class HitTestResult;
-class HTMLFrameSetElement;
 class KeyboardEvent;
 class MouseEventWithHitTestResults;
 class Node;
@@ -65,13 +65,17 @@ class PlatformWheelEvent;
 class RenderLayer;
 class RenderObject;
 class RenderWidget;
-class Scrollbar;
 class SVGElementInstance;
+class Scrollbar;
 class TextEvent;
 class TouchEvent;
 class WheelEvent;
 class Widget;
-    
+
+#if ENABLE(GESTURE_EVENTS)
+class PlatformGestureEvent;
+#endif
+
 #if ENABLE(DRAG_SUPPORT)
 extern const int LinkDragHysteresis;
 extern const int ImageDragHysteresis;
@@ -161,6 +165,10 @@ public:
     bool handleWheelEvent(PlatformWheelEvent&);
     void defaultWheelEventHandler(Node*, WheelEvent*);
 
+#if ENABLE(GESTURE_EVENTS)
+    bool handleGestureEvent(const PlatformGestureEvent&);
+#endif
+
 #if ENABLE(CONTEXT_MENUS)
     bool sendContextMenuEvent(const PlatformMouseEvent&);
     bool sendContextMenuEventForKey();
diff --git a/Source/WebCore/platform/PlatformGestureEvent.h b/Source/WebCore/platform/PlatformGestureEvent.h
new file mode 100644 (file)
index 0000000..99157e1
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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 COMPUTER, 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 COMPUTER, 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 PlatformGestureEvent_h
+#define PlatformGestureEvent_h
+
+#if ENABLE(GESTURE_EVENTS)
+
+#include "IntPoint.h"
+
+namespace WebCore {
+
+class PlatformGestureEvent {
+public:
+    enum Type {
+        ScrollBeginType,
+        ScrollEndType,
+    };
+
+    PlatformGestureEvent()
+        : m_type(ScrollBeginType)
+        , m_timestamp(0)
+    {
+    }
+
+    Type type() const { return m_type; }
+
+    const IntPoint& position() const { return m_position; } // PlatformWindow coordinates.
+    const IntPoint& globalPosition() const { return m_globalPosition; } // Screen coordinates.
+
+    double timestamp() const { return m_timestamp; }
+
+protected:
+    Type m_type;
+    IntPoint m_position;
+    IntPoint m_globalPosition;
+    double m_timestamp;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(GESTURE_EVENTS)
+
+#endif // PlatformGestureEvent_h
index 0db7350..5473a23 100644 (file)
@@ -1,3 +1,44 @@
+2011-01-26  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Maciej Stachowiak.
+
+        Add events to represent the start/end of a gesture scroll
+        https://bugs.webkit.org/show_bug.cgi?id=53215
+
+        * Scripts/webkit2/messages.py:
+        * Shared/WebEvent.h:
+        (WebKit::WebGestureEvent::WebGestureEvent):
+        (WebKit::WebGestureEvent::position):
+        (WebKit::WebGestureEvent::globalPosition):
+        * Shared/WebEventConversion.cpp:
+        (WebKit::WebKit2PlatformGestureEvent::WebKit2PlatformGestureEvent):
+        (WebKit::platform):
+        * Shared/WebEventConversion.h:
+        * Shared/WebGestureEvent.cpp: Added.
+        (WebKit::WebGestureEvent::WebGestureEvent):
+        (WebKit::WebGestureEvent::encode):
+        (WebKit::WebGestureEvent::decode):
+        (WebKit::WebGestureEvent::isGestureEventType):
+        * Shared/mac/WebEventFactory.h:
+        * Shared/mac/WebEventFactory.mm:
+        (WebKit::gestureEventTypeForEvent):
+        (WebKit::WebEventFactory::createWebGestureEvent):
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView shortCircuitedEndGestureWithEvent:]):
+        (-[WKView beginGestureWithEvent:]):
+        (-[WKView viewDidMoveToWindow]):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::handleGestureEvent):
+        (WebKit::WebPageProxy::didReceiveEvent):
+        * UIProcess/WebPageProxy.h:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::handleGestureEvent):
+        (WebKit::WebPage::gestureEvent):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        Pipe gesture events down to WebCore.
+
 2011-01-26  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Dave Hyatt.
index 60f1277..573ea0f 100644 (file)
@@ -421,6 +421,7 @@ def headers_for_type(type):
         'WebCore::KeypressCommand': '<WebCore/KeyboardEvent.h>',
         'WebCore::PluginInfo': '<WebCore/PluginData.h>',
         'WebCore::TextCheckingResult': '<WebCore/EditorClient.h>',
+        'WebKit::WebGestureEvent': '"WebEvent.h"',
         'WebKit::WebKeyboardEvent': '"WebEvent.h"',
         'WebKit::WebMouseEvent': '"WebEvent.h"',
         'WebKit::WebTouchEvent': '"WebEvent.h"',
index 2193b6c..361aa46 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 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
@@ -55,13 +55,20 @@ public:
         KeyDown,
         KeyUp,
         RawKeyDown,
-        Char
+        Char,
+
+#if ENABLE(GESTURE_EVENTS)
+        // WebGestureEvent
+        GestureScrollBegin,
+        GestureScrollEnd,
+#endif
+
 #if ENABLE(TOUCH_EVENTS)
-        ,
+        // WebTouchEvent
         TouchStart,
         TouchMove,
         TouchEnd,
-        TouchCancel
+        TouchCancel,
 #endif
     };
 
@@ -230,8 +237,30 @@ private:
     bool m_isSystemKey;
 };
 
-#if ENABLE(TOUCH_EVENTS)
 
+#if ENABLE(GESTURE_EVENTS)
+// FIXME: Move this class to its own header file.
+class WebGestureEvent : public WebEvent {
+public:
+    WebGestureEvent() { }
+    WebGestureEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, Modifiers, double timestamp);
+
+    const WebCore::IntPoint position() const { return m_position; }
+    const WebCore::IntPoint globalPosition() const { return m_globalPosition; }
+
+    void encode(CoreIPC::ArgumentEncoder*) const;
+    static bool decode(CoreIPC::ArgumentDecoder*, WebGestureEvent&);
+
+private:
+    static bool isGestureEventType(Type);
+
+    WebCore::IntPoint m_position;
+    WebCore::IntPoint m_globalPosition;
+};
+#endif // ENABLE(GESTURE_EVENTS)
+
+
+#if ENABLE(TOUCH_EVENTS)
 // FIXME: Move this class to its own header file.
 // FIXME: Having "Platform" in the name makes it sound like this event is platform-specific or low-
 // level in some way. That doesn't seem to be the case.
index d82a051..7ae2e85 100644 (file)
@@ -26,7 +26,6 @@
 #include "WebEventConversion.h"
 
 #include "WebEvent.h"
-#include <WebCore/IntPoint.h>
 
 namespace WebKit {
 
@@ -168,6 +167,34 @@ WebCore::PlatformKeyboardEvent platform(const WebKeyboardEvent& webEvent)
     return WebKit2PlatformKeyboardEvent(webEvent);
 }
 
+#if ENABLE(GESTURE_EVENTS)
+class WebKit2PlatformGestureEvent : public WebCore::PlatformGestureEvent {
+public:
+    WebKit2PlatformGestureEvent(const WebGestureEvent& webEvent)
+    {
+        switch (webEvent.type()) {
+        case WebEvent::GestureScrollBegin:
+            m_type = PlatformGestureEvent::ScrollBeginType;
+            break;
+        case WebEvent::GestureScrollEnd:
+            m_type = PlatformGestureEvent::ScrollEndType;
+            break;
+        default:
+            ASSERT_NOT_REACHED();
+        }
+
+        m_position = webEvent.position();
+        m_globalPosition = webEvent.globalPosition();
+        m_timestamp = webEvent.timestamp();
+    }
+};
+
+WebCore::PlatformGestureEvent platform(const WebGestureEvent& webEvent)
+{
+    return WebKit2PlatformGestureEvent(webEvent);
+}
+#endif
+
 #if ENABLE(TOUCH_EVENTS)
 class WebKit2PlatformTouchPoint : public WebCore::PlatformTouchPoint {
 public:
index 8fa0813..1fe87bc 100644 (file)
 #include <WebCore/PlatformKeyboardEvent.h>
 #include <WebCore/PlatformMouseEvent.h>
 #include <WebCore/PlatformWheelEvent.h>
+
+#if ENABLE(GESTURE_EVENTS)
+#include <WebCore/PlatformGestureEvent.h>
+#endif
+
 #if ENABLE(TOUCH_EVENTS)
 #include <WebCore/PlatformTouchEvent.h>
 #include <WebCore/PlatformTouchPoint.h>
@@ -39,17 +44,29 @@ namespace WebKit {
 class WebMouseEvent;
 class WebWheelEvent;
 class WebKeyboardEvent;
+
+#if ENABLE(GESTURE_EVENTS)
+class WebGestureEvent;
+#endif
+
 #if ENABLE(TOUCH_EVENTS)
 class WebTouchEvent;
 class WebTouchPoint;
 #endif
+
 WebCore::PlatformMouseEvent platform(const WebMouseEvent&);
 WebCore::PlatformWheelEvent platform(const WebWheelEvent&);
 WebCore::PlatformKeyboardEvent platform(const WebKeyboardEvent&);
+
+#if ENABLE(GESTURE_EVENTS)
+WebCore::PlatformGestureEvent platform(const WebGestureEvent&);
+#endif
+
 #if ENABLE(TOUCH_EVENTS)
 WebCore::PlatformTouchEvent platform(const WebTouchEvent&);
 WebCore::PlatformTouchPoint platform(const WebTouchPoint&);
 #endif
+
 } // namespace WebKit
 
 #endif // WebEventConversion_h
diff --git a/Source/WebKit2/Shared/WebGestureEvent.cpp b/Source/WebKit2/Shared/WebGestureEvent.cpp
new file mode 100644 (file)
index 0000000..5b6faf6
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * 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. 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 "WebEvent.h"
+
+#if ENABLE(GESTURE_EVENTS)
+
+#include "Arguments.h"
+#include "WebCoreArgumentCoders.h"
+
+using namespace WebCore;
+
+namespace WebKit {    
+
+WebGestureEvent::WebGestureEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, Modifiers modifiers, double timestamp)
+    : WebEvent(type, modifiers, timestamp)
+    , m_position(position)
+    , m_globalPosition(globalPosition)
+{
+    ASSERT(isGestureEventType(type));
+}
+
+void WebGestureEvent::encode(CoreIPC::ArgumentEncoder* encoder) const
+{
+    WebEvent::encode(encoder);
+
+    encoder->encode(m_position);
+    encoder->encode(m_globalPosition);
+}
+
+bool WebGestureEvent::decode(CoreIPC::ArgumentDecoder* decoder, WebGestureEvent& t)
+{
+    if (!WebEvent::decode(decoder, t))
+        return false;
+    if (!decoder->decode(t.m_position))
+        return false;
+    if (!decoder->decode(t.m_globalPosition))
+        return false;
+    return true;
+}
+
+bool WebGestureEvent::isGestureEventType(Type type)
+{
+    return type == GestureScrollBegin || type == GestureScrollEnd;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(GESTURE_EVENTS)
index 7bc8d97..73fbed0 100644 (file)
@@ -38,6 +38,10 @@ public:
     static WebMouseEvent createWebMouseEvent(NSEvent *event, NSView *windowView);
     static WebWheelEvent createWebWheelEvent(NSEvent *event, NSView *windowView);
     static WebKeyboardEvent createWebKeyboardEvent(NSEvent *event, NSView *windowView);
+
+#if ENABLE(GESTURE_EVENTS)
+    static WebGestureEvent createWebGestureEvent(NSEvent *event, NSView *windowView);
+#endif
 };
 
 } // namespace WebKit
index 19c2a70..e53e5fa 100644 (file)
@@ -188,7 +188,22 @@ static WebWheelEvent::Phase phaseForEvent(NSEvent *event)
     return WebWheelEvent::PhaseNone;
 #endif
 }
-    
+
+#if ENABLE(GESTURE_EVENTS)
+static WebEvent::Type gestureEventTypeForEvent(NSEvent *event)
+{
+    switch ([event type]) {
+    case NSEventTypeBeginGesture:
+        return WebEvent::GestureScrollBegin;
+    case NSEventTypeEndGesture:
+        return WebEvent::GestureScrollEnd;
+    default:
+        ASSERT_NOT_REACHED();
+        return WebEvent::GestureScrollEnd;
+    }
+}
+#endif
+
 static inline String textFromEvent(NSEvent* event)
 {
     if ([event type] == NSFlagsChanged)
@@ -1045,4 +1060,17 @@ WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(NSEvent *event, NSView
     return WebKeyboardEvent(type, text, unmodifiedText, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
 }
 
+#if ENABLE(GESTURE_EVENTS)
+WebGestureEvent WebEventFactory::createWebGestureEvent(NSEvent *event, NSView *windowView)
+{
+    WebEvent::Type type             = gestureEventTypeForEvent(event);
+    NSPoint position                = pointForEvent(event, windowView);
+    NSPoint globalPosition          = globalPointForEvent(event);
+    WebEvent::Modifiers modifiers   = modifiersForEvent(event);
+    double timestamp                = [event timestamp];
+
+    return WebGestureEvent(type, IntPoint(position), IntPoint(globalPosition), modifiers, timestamp);
+}
+#endif
+
 } // namespace WebKit
index c7a8d9a..9432e33 100644 (file)
@@ -135,6 +135,10 @@ typedef HashMap<String, ValidationVector> ValidationMap;
     NSEvent *_mouseDownEvent;
     BOOL _ignoringMouseDraggedEvents;
     BOOL _dragHasStarted;
+
+#if ENABLE(GESTURE_EVENTS)
+    id _endGestureMonitor;
+#endif
 }
 @end
 
@@ -758,6 +762,41 @@ EVENT_HANDLER(scrollWheel, Wheel)
     [self _mouseHandler:event];
 }
 
+#if ENABLE(GESTURE_EVENTS)
+
+static const short kIOHIDEventTypeScroll = 6;
+
+- (void)shortCircuitedEndGestureWithEvent:(NSEvent *)event
+{
+    if ([event subtype] != kIOHIDEventTypeScroll)
+        return;
+
+    WebGestureEvent webEvent = WebEventFactory::createWebGestureEvent(event, self);
+    _data->_page->handleGestureEvent(webEvent);
+
+    if (_data->_endGestureMonitor) {
+        [NSEvent removeMonitor:_data->_endGestureMonitor];
+        _data->_endGestureMonitor = nil;
+    }
+}
+
+- (void)beginGestureWithEvent:(NSEvent *)event
+{
+    if ([event subtype] != kIOHIDEventTypeScroll)
+        return;
+
+    WebGestureEvent webEvent = WebEventFactory::createWebGestureEvent(event, self);
+    _data->_page->handleGestureEvent(webEvent);
+
+    if (!_data->_endGestureMonitor) {
+        _data->_endGestureMonitor = [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskEndGesture handler:^(NSEvent *blockEvent) {
+            [self shortCircuitedEndGestureWithEvent:blockEvent];
+            return blockEvent;
+        }];
+    }
+}
+#endif
+
 - (void)doCommandBySelector:(SEL)selector
 {
     if (selector != @selector(noop:))
@@ -1177,8 +1216,14 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
     } else {
         _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
         _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive | WebPageProxy::ViewIsInWindow);
-    }
 
+#if ENABLE(GESTURE_EVENTS)
+        if (_data->_endGestureMonitor) {
+            [NSEvent removeMonitor:_data->_endGestureMonitor];
+            _data->_endGestureMonitor = nil;
+        }
+#endif
+    }
     [self _setRemoteAccessibilityWindow:[self window]];
 }
 
index 2fd8f1a..02e598a 100644 (file)
@@ -702,6 +702,17 @@ void WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)
     process()->send(Messages::WebPage::KeyEvent(event), m_pageID);
 }
 
+#if ENABLE(GESTURE_EVENTS)
+void WebPageProxy::handleGestureEvent(const WebGestureEvent& event)
+{
+    if (!isValid())
+        return;
+
+    process()->responsivenessTimer()->start();
+    process()->send(Messages::WebPage::GestureEvent(event), m_pageID);
+}
+#endif
+
 #if ENABLE(TOUCH_EVENTS)
 void WebPageProxy::handleTouchEvent(const WebTouchEvent& event)
 {
@@ -2112,6 +2123,10 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
     case WebEvent::KeyUp:
     case WebEvent::RawKeyDown:
     case WebEvent::Char:
+#if ENABLE(GESTURE_EVENTS)
+    case WebEvent::GestureScrollBegin:
+    case WebEvent::GestureScrollEnd:
+#endif
         process()->responsivenessTimer()->stop();
         break;
     }
@@ -2126,6 +2141,10 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
         break;
     case WebEvent::MouseDown:
     case WebEvent::MouseUp:
+#if ENABLE(GESTURE_EVENTS)
+    case WebEvent::GestureScrollBegin:
+    case WebEvent::GestureScrollEnd:
+#endif
         break;
 
     case WebEvent::Wheel: {
index 184f85b..4228024 100644 (file)
@@ -105,6 +105,10 @@ struct PrintInfo;
 struct WebPageCreationParameters;
 struct WebPopupItem;
 
+#if ENABLE(GESTURE_EVENTS)
+class WebGestureEvent;
+#endif
+
 typedef GenericCallback<WKStringRef, StringImpl*> StringCallback;
 
 class WebPageProxy : public APIObject, public WebPopupMenuProxy::Client {
@@ -215,6 +219,9 @@ public:
     void handleMouseEvent(const WebMouseEvent&);
     void handleWheelEvent(const WebWheelEvent&);
     void handleKeyboardEvent(const NativeWebKeyboardEvent&);
+#if ENABLE(GESTURE_EVENTS)
+    void handleGestureEvent(const WebGestureEvent&);
+#endif
 #if ENABLE(TOUCH_EVENTS)
     void handleTouchEvent(const WebTouchEvent&);
 #endif
index 37d5355..152a3b0 100644 (file)
                BC90A1D2122DD55E00CC8C50 /* WebURLResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = BC90A1D0122DD55E00CC8C50 /* WebURLResponse.h */; };
                BC90A1D3122DD55E00CC8C50 /* WebURLResponse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC90A1D1122DD55E00CC8C50 /* WebURLResponse.cpp */; };
                BC90A1D7122DD66A00CC8C50 /* WebURLResponseMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC90A1D5122DD66A00CC8C50 /* WebURLResponseMac.mm */; };
+               BC9585C812F095B800755821 /* WebGestureEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC9585C712F095B800755821 /* WebGestureEvent.cpp */; };
                BC963D6B113DD19200574BE2 /* WebPage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC963D6A113DD19200574BE2 /* WebPage.cpp */; };
                BC963D6E113DD1A500574BE2 /* WebPageMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC963D6D113DD1A500574BE2 /* WebPageMac.mm */; };
                BC9B38A110F538BE00443A15 /* WebFrameProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = BC9B389F10F538BE00443A15 /* WebFrameProxy.h */; };
                BC90A1D0122DD55E00CC8C50 /* WebURLResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebURLResponse.h; sourceTree = "<group>"; };
                BC90A1D1122DD55E00CC8C50 /* WebURLResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebURLResponse.cpp; sourceTree = "<group>"; };
                BC90A1D5122DD66A00CC8C50 /* WebURLResponseMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebURLResponseMac.mm; sourceTree = "<group>"; };
+               BC9585C712F095B800755821 /* WebGestureEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGestureEvent.cpp; sourceTree = "<group>"; };
                BC963D6A113DD19200574BE2 /* WebPage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPage.cpp; sourceTree = "<group>"; };
                BC963D6D113DD1A500574BE2 /* WebPageMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPageMac.mm; sourceTree = "<group>"; };
                BC9B389F10F538BE00443A15 /* WebFrameProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebFrameProxy.h; sourceTree = "<group>"; };
                                BC90A1D0122DD55E00CC8C50 /* WebURLResponse.h */,
                                F6113E24126CE1820057D0A7 /* WebUserContentURLPattern.h */,
                                C0337DD0127A2980008FF4F4 /* WebWheelEvent.cpp */,
+                               BC9585C712F095B800755821 /* WebGestureEvent.cpp */,
                                1A64245D12DE29A100CAAE2C /* UpdateInfo.cpp */,
                        );
                        path = Shared;
                                C574A37712E6099D002DFE98 /* WebDragClientMac.mm in Sources */,
                                C574A58212E66681002DFE98 /* PasteboardTypes.mm in Sources */,
                                E134F01A12EA5D99004EC58D /* WKPrintingView.mm in Sources */,
+                               BC9585C812F095B800755821 /* WebGestureEvent.cpp in Sources */,
                                1A186EEB12EF7618008E5F37 /* LayerTreeHost.cpp in Sources */,
                                1A18718512EF9877008E5F37 /* LayerTreeHostMac.mm in Sources */,
                        );
index 664fd20..d84c182 100644 (file)
@@ -917,6 +917,26 @@ void WebPage::keyEvent(const WebKeyboardEvent& keyboardEvent)
     send(Messages::WebPageProxy::DidReceiveEvent(static_cast<uint32_t>(keyboardEvent.type()), handled));
 }
 
+#if ENABLE(GESTURE_EVENTS)
+static bool handleGestureEvent(const WebGestureEvent& gestureEvent, Page* page)
+{
+    Frame* frame = page->mainFrame();
+    if (!frame->view())
+        return false;
+
+    PlatformGestureEvent platformGestureEvent = platform(gestureEvent);
+    return frame->eventHandler()->handleGestureEvent(platformGestureEvent);
+}
+
+void WebPage::gestureEvent(const WebGestureEvent& gestureEvent)
+{
+    CurrentEvent currentEvent(gestureEvent);
+
+    bool handled = handleGestureEvent(gestureEvent, m_page.get());
+    send(Messages::WebPageProxy::DidReceiveEvent(static_cast<uint32_t>(gestureEvent.type()), handled));
+}
+#endif
+
 void WebPage::validateMenuItem(const String& commandName)
 {
     bool isEnabled = false;
index 00077d6..352690f 100644 (file)
@@ -100,6 +100,10 @@ struct PrintInfo;
 struct WebPageCreationParameters;
 struct WebPreferencesStore;
 
+#if ENABLE(GESTURE_EVENTS)
+class WebGestureEvent;
+#endif
+
 #if ENABLE(TOUCH_EVENTS)
 class WebTouchEvent;
 #endif
@@ -350,11 +354,15 @@ private:
     void setInitialFocus(bool);
     void setWindowResizerSize(const WebCore::IntSize&);
     void setIsInWindow(bool);
+    void validateMenuItem(const String&);
+    void executeEditCommand(const String&);
+
     void mouseEvent(const WebMouseEvent&);
     void wheelEvent(const WebWheelEvent&);
     void keyEvent(const WebKeyboardEvent&);
-    void validateMenuItem(const String&);
-    void executeEditCommand(const String&);
+#if ENABLE(GESTURE_EVENTS)
+    void gestureEvent(const WebGestureEvent&);
+#endif
 #if ENABLE(TOUCH_EVENTS)
     void touchEvent(const WebTouchEvent&);
 #endif
index f4af9d8..5d02d31 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2010 Apple Inc. All rights reserved.
+# Copyright (C) 2010, 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
@@ -32,6 +32,9 @@ messages -> WebPage {
     KeyEvent(WebKit::WebKeyboardEvent event)
     MouseEvent(WebKit::WebMouseEvent event)
     WheelEvent(WebKit::WebWheelEvent event)
+#if ENABLE(GESTURE_EVENTS)
+    GestureEvent(WebKit::WebGestureEvent event)
+#endif
 #if ENABLE(TOUCH_EVENTS)
     TouchEvent(WebKit::WebTouchEvent event)
 #endif