Commit 99b7847a authored by weinig@apple.com's avatar weinig@apple.com

Add events to represent the start/end of a gesture scroll

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: http://svn.webkit.org/repository/webkit/trunk@76745 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 04df567e
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.
......
......@@ -600,18 +600,21 @@
#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
......
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.
......@@ -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
......@@ -5083,6 +5083,7 @@
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 */; };
......@@ -11400,6 +11401,7 @@
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>"; };
......@@ -18296,6 +18298,7 @@
BC772C4D0C4EB3040083285F /* MIMETypeRegistry.h */,
4B2708C50AF19EE40065127F /* Pasteboard.h */,
935C476609AC4D4300A6AAB4 /* PlatformKeyboardEvent.h */,
BC9585DF12F0989500755821 /* PlatformGestureEvent.h */,
932871BF0B20DEB70049035A /* PlatformMenuDescription.h */,
935C476709AC4D4300A6AAB4 /* PlatformMouseEvent.h */,
BCEC01D60C274EB4009F4EC9 /* PlatformScreen.h */,
......@@ -22436,6 +22439,7 @@
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;
......@@ -78,6 +78,10 @@
#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)
{
......
......@@ -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();
......
/*
* 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
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.
......@@ -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"',
......
/*
* 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.
......
......@@ -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:
......
......@@ -29,6 +29,11 @@
#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
/*
* 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)
......@@ -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
......
......@@ -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
......@@ -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;
}];
}
}