diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-05-30 12:48:17 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-05-30 12:48:17 +0200 |
commit | 881da28418d380042aa95a97f0cbd42560a64f7c (patch) | |
tree | a794dff3274695e99c651902dde93d934ea7a5af /Source/WebKit2/Shared/WebEventConversion.cpp | |
parent | 7e104c57a70fdf551bb3d22a5d637cdcbc69dbea (diff) | |
parent | 0fcedcd17cc00d3dd44c718b3cb36c1033319671 (diff) | |
download | qtwebkit-881da28418d380042aa95a97f0cbd42560a64f7c.tar.gz |
Merge 'wip/next' into dev
Change-Id: Iff9ee5e23bb326c4371ec8ed81d56f2f05d680e9
Diffstat (limited to 'Source/WebKit2/Shared/WebEventConversion.cpp')
-rw-r--r-- | Source/WebKit2/Shared/WebEventConversion.cpp | 132 |
1 files changed, 122 insertions, 10 deletions
diff --git a/Source/WebKit2/Shared/WebEventConversion.cpp b/Source/WebKit2/Shared/WebEventConversion.cpp index 81af7eb27..f401a53bd 100644 --- a/Source/WebKit2/Shared/WebEventConversion.cpp +++ b/Source/WebKit2/Shared/WebEventConversion.cpp @@ -28,6 +28,10 @@ #include "WebEvent.h" +#if ENABLE(MAC_GESTURE_EVENTS) +#include "WebGestureEvent.h" +#endif + namespace WebKit { class WebKit2PlatformMouseEvent : public WebCore::PlatformMouseEvent { @@ -38,12 +42,27 @@ public: switch (webEvent.type()) { case WebEvent::MouseDown: m_type = WebCore::PlatformEvent::MousePressed; + m_force = WebCore::ForceAtClick; break; case WebEvent::MouseUp: m_type = WebCore::PlatformEvent::MouseReleased; + m_force = WebCore::ForceAtClick; break; case WebEvent::MouseMove: m_type = WebCore::PlatformEvent::MouseMoved; + m_force = webEvent.force(); + break; + case WebEvent::MouseForceChanged: + m_type = WebCore::PlatformEvent::MouseForceChanged; + m_force = webEvent.force(); + break; + case WebEvent::MouseForceDown: + m_type = WebCore::PlatformEvent::MouseForceDown; + m_force = WebCore::ForceAtForceClick; + break; + case WebEvent::MouseForceUp: + m_type = WebCore::PlatformEvent::MouseForceUp; + m_force = WebCore::ForceAtForceClick; break; default: ASSERT_NOT_REACHED(); @@ -82,6 +101,10 @@ public: m_position = webEvent.position(); m_globalPosition = webEvent.globalPosition(); m_clickCount = webEvent.clickCount(); +#if PLATFORM(MAC) + m_eventNumber = webEvent.eventNumber(); + m_menuTypeForEvent = webEvent.menuTypeForEvent(); +#endif m_modifierFlags = 0; if (webEvent.shiftKey()) @@ -128,7 +151,7 @@ public: m_wheelTicksY = webEvent.wheelTicks().height(); m_granularity = (webEvent.granularity() == WebWheelEvent::ScrollByPageWheelEvent) ? WebCore::ScrollByPageWheelEvent : WebCore::ScrollByPixelWheelEvent; m_directionInvertedFromDevice = webEvent.directionInvertedFromDevice(); -#if PLATFORM(MAC) +#if PLATFORM(COCOA) m_phase = static_cast<WebCore::PlatformWheelEventPhase>(webEvent.phase()); m_momentumPhase = static_cast<WebCore::PlatformWheelEventPhase>(webEvent.momentumPhase()); m_hasPreciseScrollingDeltas = webEvent.hasPreciseScrollingDeltas(); @@ -185,6 +208,10 @@ public: m_windowsVirtualKeyCode = webEvent.windowsVirtualKeyCode(); m_nativeVirtualKeyCode = webEvent.nativeVirtualKeyCode(); m_macCharCode = webEvent.macCharCode(); +#if USE(APPKIT) || PLATFORM(GTK) + m_handledByInputMethod = webEvent.handledByInputMethod(); + m_commands = webEvent.commands(); +#endif m_autoRepeat = webEvent.isAutoRepeat(); m_isKeypad = webEvent.isKeypad(); m_isSystemKey = webEvent.isSystemKey(); @@ -196,19 +223,13 @@ WebCore::PlatformKeyboardEvent platform(const WebKeyboardEvent& webEvent) return WebKit2PlatformKeyboardEvent(webEvent); } -#if ENABLE(GESTURE_EVENTS) +#if ENABLE(QT_GESTURE_EVENTS) class WebKit2PlatformGestureEvent : public WebCore::PlatformGestureEvent { public: WebKit2PlatformGestureEvent(const WebGestureEvent& webEvent) { // PlatformEvent switch (webEvent.type()) { - case WebEvent::GestureScrollBegin: - m_type = WebCore::PlatformEvent::GestureScrollBegin; - break; - case WebEvent::GestureScrollEnd: - m_type = WebCore::PlatformEvent::GestureScrollEnd; - break; case WebEvent::GestureSingleTap: m_type = WebCore::PlatformEvent::GestureTap; break; @@ -233,8 +254,6 @@ public: m_globalPosition = webEvent.globalPosition(); m_area = webEvent.area(); - m_deltaX = webEvent.delta().x(); - m_deltaY = webEvent.delta().y(); } }; @@ -245,6 +264,39 @@ WebCore::PlatformGestureEvent platform(const WebGestureEvent& webEvent) #endif #if ENABLE(TOUCH_EVENTS) + +#if PLATFORM(IOS) + +static WebCore::PlatformTouchPoint::TouchPhaseType touchEventType(const WebPlatformTouchPoint& webTouchPoint) +{ + switch (webTouchPoint.phase()) { + case WebPlatformTouchPoint::TouchReleased: + return WebCore::PlatformTouchPoint::TouchPhaseEnded; + case WebPlatformTouchPoint::TouchPressed: + return WebCore::PlatformTouchPoint::TouchPhaseBegan; + case WebPlatformTouchPoint::TouchMoved: + return WebCore::PlatformTouchPoint::TouchPhaseMoved; + case WebPlatformTouchPoint::TouchStationary: + return WebCore::PlatformTouchPoint::TouchPhaseStationary; + case WebPlatformTouchPoint::TouchCancelled: + return WebCore::PlatformTouchPoint::TouchPhaseCancelled; + } +} + +class WebKit2PlatformTouchPoint : public WebCore::PlatformTouchPoint { +public: +WebKit2PlatformTouchPoint(const WebPlatformTouchPoint& webTouchPoint) + : PlatformTouchPoint(webTouchPoint.identifier(), webTouchPoint.location(), touchEventType(webTouchPoint) +#if ENABLE(IOS_TOUCH_EVENTS) + , webTouchPoint.force() +#endif + ) +{ +} +}; + +#else + class WebKit2PlatformTouchPoint : public WebCore::PlatformTouchPoint { public: WebKit2PlatformTouchPoint(const WebPlatformTouchPoint& webTouchPoint) @@ -279,6 +331,7 @@ public: m_rotationAngle = webTouchPoint.rotationAngle(); } }; +#endif // PLATFORM(IOS) class WebKit2PlatformTouchEvent : public WebCore::PlatformTouchEvent { public: @@ -314,9 +367,24 @@ public: m_timestamp = webEvent.timestamp(); +#if PLATFORM(IOS) + unsigned touchCount = webEvent.touchPoints().size(); + m_touchPoints.reserveInitialCapacity(touchCount); + for (unsigned i = 0; i < touchCount; ++i) + m_touchPoints.uncheckedAppend(WebKit2PlatformTouchPoint(webEvent.touchPoints().at(i))); + + m_gestureScale = webEvent.gestureScale(); + m_gestureRotation = webEvent.gestureRotation(); + m_canPreventNativeGestures = webEvent.canPreventNativeGestures(); + m_isGesture = webEvent.isGesture(); + m_isPotentialTap = webEvent.isPotentialTap(); + m_position = webEvent.position(); + m_globalPosition = webEvent.position(); +#else // PlatformTouchEvent for (size_t i = 0; i < webEvent.touchPoints().size(); ++i) m_touchPoints.append(WebKit2PlatformTouchPoint(webEvent.touchPoints().at(i))); +#endif //PLATFORM(IOS) } }; @@ -326,4 +394,48 @@ WebCore::PlatformTouchEvent platform(const WebTouchEvent& webEvent) } #endif +#if ENABLE(MAC_GESTURE_EVENTS) +class WebKit2PlatformGestureEvent : public WebCore::PlatformGestureEvent { +public: + WebKit2PlatformGestureEvent(const WebGestureEvent& webEvent) + { + switch (webEvent.type()) { + case WebEvent::GestureStart: + m_type = WebCore::PlatformEvent::GestureStart; + break; + case WebEvent::GestureChange: + m_type = WebCore::PlatformEvent::GestureChange; + break; + case WebEvent::GestureEnd: + m_type = WebCore::PlatformEvent::GestureEnd; + break; + default: + ASSERT_NOT_REACHED(); + } + + m_modifiers = 0; + if (webEvent.shiftKey()) + m_modifiers |= ShiftKey; + if (webEvent.controlKey()) + m_modifiers |= CtrlKey; + if (webEvent.altKey()) + m_modifiers |= AltKey; + if (webEvent.metaKey()) + m_modifiers |= MetaKey; + + m_timestamp = webEvent.timestamp(); + + m_gestureScale = webEvent.gestureScale(); + m_gestureRotation = webEvent.gestureRotation(); + m_position = webEvent.position(); + m_globalPosition = webEvent.position(); + } +}; + +WebCore::PlatformGestureEvent platform(const WebGestureEvent& webEvent) +{ + return WebKit2PlatformGestureEvent(webEvent); +} +#endif + } // namespace WebKit |