Extend DOM WheelEvent to differentiate between physical and logical scroll directions
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Oct 2011 18:06:44 +0000 (18:06 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Oct 2011 18:06:44 +0000 (18:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68959
<rdar://problem/10036688>

Reviewed by Sam Weinig.

Source/JavaScriptCore:

* wtf/Platform.h: Added HAVE_INVERTED_WHEEL_EVENTS for Lion and later.

Source/WebCore:

Test: fast/events/wheelevent-direction-inverted-from-device.html

* dom/WheelEvent.cpp:
(WebCore::WheelEvent::WheelEvent):
(WebCore::WheelEvent::initWheelEvent):
(WebCore::WheelEventDispatchMediator::WheelEventDispatchMediator):
* dom/WheelEvent.h:
(WebCore::WheelEvent::create):
(WebCore::WheelEvent::webkitDirectionInvertedFromDevice):
* dom/WheelEvent.idl: Added the webkitDirectionInvertedFromDevice idl attribute.
* platform/PlatformWheelEvent.h:
(WebCore::PlatformWheelEvent::PlatformWheelEvent):
(WebCore::PlatformWheelEvent::webkitDirectionInvertedFromDevice):
* platform/efl/PlatformWheelEventEfl.cpp:
(WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.
* platform/gtk/PlatformWheelEventGtk.cpp:
(WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.
* platform/mac/WheelEventMac.mm:
(WebCore::PlatformWheelEvent::PlatformWheelEvent): if building on Lion or later, use
[NSEvent isDirectionInvertedFromDevice].
* platform/qt/WheelEventQt.cpp:
(WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.
* platform/win/WheelEventWin.cpp:
(WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.
* platform/wx/MouseWheelEventWx.cpp:
(WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.

Source/WebKit2:

* Shared/WebEvent.h:
(WebKit::WebWheelEvent::directionInvertedFromDevice):
* Shared/WebEventConversion.cpp:
(WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
* Shared/WebWheelEvent.cpp:
(WebKit::WebWheelEvent::WebWheelEvent):
(WebKit::WebWheelEvent::encode):
(WebKit::WebWheelEvent::decode):
* Shared/mac/WebEventFactory.mm:
(WebKit::WebEventFactory::createWebWheelEvent): get the flag from the NSEvent.
* UIProcess/WebPageProxy.cpp:
(WebKit::coalesce):

LayoutTests:

* fast/events/wheelevent-direction-inverted-from-device-expected.txt: Added.
* fast/events/wheelevent-direction-inverted-from-device.html: Added.
* platform/mac-wk2/Skipped: WKTR does not support mouse scroll events yet.

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

23 files changed:
LayoutTests/ChangeLog [changed mode: 0755->0644]
LayoutTests/fast/events/wheelevent-direction-inverted-from-device-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/wheelevent-direction-inverted-from-device.html [new file with mode: 0644]
LayoutTests/platform/mac-wk2/Skipped
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/wtf/Platform.h
Source/WebCore/ChangeLog [changed mode: 0755->0644]
Source/WebCore/dom/WheelEvent.cpp
Source/WebCore/dom/WheelEvent.h
Source/WebCore/dom/WheelEvent.idl
Source/WebCore/platform/PlatformWheelEvent.h
Source/WebCore/platform/efl/PlatformWheelEventEfl.cpp
Source/WebCore/platform/gtk/PlatformWheelEventGtk.cpp
Source/WebCore/platform/mac/WheelEventMac.mm
Source/WebCore/platform/qt/WheelEventQt.cpp
Source/WebCore/platform/win/WheelEventWin.cpp
Source/WebCore/platform/wx/MouseWheelEventWx.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebEvent.h
Source/WebKit2/Shared/WebEventConversion.cpp
Source/WebKit2/Shared/WebWheelEvent.cpp
Source/WebKit2/Shared/mac/WebEventFactory.mm
Source/WebKit2/UIProcess/WebPageProxy.cpp

old mode 100755 (executable)
new mode 100644 (file)
index 8d13cd6..040bfbc
@@ -1,3 +1,15 @@
+2011-10-03  Jon Lee  <jonlee@apple.com>
+
+        Extend DOM WheelEvent to differentiate between physical and logical scroll directions
+        https://bugs.webkit.org/show_bug.cgi?id=68959
+        <rdar://problem/10036688>
+
+        Reviewed by Sam Weinig.
+
+        * fast/events/wheelevent-direction-inverted-from-device-expected.txt: Added.
+        * fast/events/wheelevent-direction-inverted-from-device.html: Added.
+        * platform/mac-wk2/Skipped: WKTR does not support mouse scroll events yet.
+
 2011-10-03 Ken Buchanan <kenrb@chromium.org>
 
         Resource loader should block HTTP redirects to local resources
diff --git a/LayoutTests/fast/events/wheelevent-direction-inverted-from-device-expected.txt b/LayoutTests/fast/events/wheelevent-direction-inverted-from-device-expected.txt
new file mode 100644 (file)
index 0000000..d305b0f
--- /dev/null
@@ -0,0 +1,12 @@
+This test checks for the existence of the webkitDirectionInvertedFromDevice property in the WheelEvent.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Scroll over me
+sending scroll event to green target
+PASS result != undefined is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/events/wheelevent-direction-inverted-from-device.html b/LayoutTests/fast/events/wheelevent-direction-inverted-from-device.html
new file mode 100644 (file)
index 0000000..a6e0a19
--- /dev/null
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+
+<p id="description"></p>
+<div style="width:100px; height:80px; background-color:green; color:white" id="target">Scroll over me</div>
+<div id="console"></div>
+
+<script src="../js/resources/js-test-pre.js"></script>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+
+<script>
+description("This test checks for the existence of the webkitDirectionInvertedFromDevice property in the WheelEvent.");
+var t = document.getElementById("target");
+var c = document.getElementById('console');
+var result = undefined;
+function scrollHandler(event) {
+    result = event.webkitDirectionInvertedFromDevice;
+    event.preventDefault();
+};
+t.addEventListener('mousewheel', scrollHandler, false);
+
+if (window.layoutTestController && window.eventSender) {
+    debug("sending scroll event to green target");
+    eventSender.mouseMoveTo(t.offsetLeft + 10, t.offsetTop + 10);
+    eventSender.continuousMouseScrollBy(0,10);
+    shouldBeTrue('result != undefined');
+}
+
+var successfullyParsed = true;
+</script>
+
+<script src="../js/resources/js-test-post.js"></script>
+
+</body>
+</html>
\ No newline at end of file
index 5f5bb3a..5856e30 100644 (file)
@@ -157,6 +157,7 @@ fast/events/selectstart-prevent-selection-on-right-click.html
 fast/events/standalone-image-drag-to-editable.html
 fast/events/wheelevent-in-horizontal-scrollbar-in-rtl.html
 fast/events/wheelevent-in-vertical-scrollbar-in-rtl.html
+fast/events/wheelevent-direction-inverted-from-device.html
 fast/files/apply-blob-url-to-xhr.html
 fast/files/file-reader-abort.html
 fast/files/read-blob-async.html
index f649791..71bd16b 100644 (file)
@@ -1,3 +1,13 @@
+2011-10-03  Jon Lee  <jonlee@apple.com>
+
+        Extend DOM WheelEvent to differentiate between physical and logical scroll directions
+        https://bugs.webkit.org/show_bug.cgi?id=68959
+        <rdar://problem/10036688>
+
+        Reviewed by Sam Weinig.
+
+        * wtf/Platform.h: Added HAVE_INVERTED_WHEEL_EVENTS for Lion and later.
+
 2011-10-04  Csaba Osztrogonác  <ossy@webkit.org>
 
         MinGW warning fix after r96286.
index aff68a3..66611a8 100644 (file)
 #define WTF_USE_REQUEST_ANIMATION_FRAME_TIMER 1
 #endif
 
+#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD)
+#define HAVE_INVERTED_WHEEL_EVENTS 1
+#endif
+
 #endif /* WTF_Platform_h */
old mode 100755 (executable)
new mode 100644 (file)
index 35b67e7..541de1f
@@ -1,3 +1,38 @@
+2011-10-03  Jon Lee  <jonlee@apple.com>
+
+        Extend DOM WheelEvent to differentiate between physical and logical scroll directions
+        https://bugs.webkit.org/show_bug.cgi?id=68959
+        <rdar://problem/10036688>
+
+        Reviewed by Sam Weinig.
+
+        Test: fast/events/wheelevent-direction-inverted-from-device.html
+
+        * dom/WheelEvent.cpp:
+        (WebCore::WheelEvent::WheelEvent):
+        (WebCore::WheelEvent::initWheelEvent):
+        (WebCore::WheelEventDispatchMediator::WheelEventDispatchMediator):
+        * dom/WheelEvent.h:
+        (WebCore::WheelEvent::create):
+        (WebCore::WheelEvent::webkitDirectionInvertedFromDevice):
+        * dom/WheelEvent.idl: Added the webkitDirectionInvertedFromDevice idl attribute.
+        * platform/PlatformWheelEvent.h:
+        (WebCore::PlatformWheelEvent::PlatformWheelEvent):
+        (WebCore::PlatformWheelEvent::webkitDirectionInvertedFromDevice):
+        * platform/efl/PlatformWheelEventEfl.cpp:
+        (WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.
+        * platform/gtk/PlatformWheelEventGtk.cpp:
+        (WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.
+        * platform/mac/WheelEventMac.mm:
+        (WebCore::PlatformWheelEvent::PlatformWheelEvent): if building on Lion or later, use
+        [NSEvent isDirectionInvertedFromDevice].
+        * platform/qt/WheelEventQt.cpp:
+        (WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.
+        * platform/win/WheelEventWin.cpp:
+        (WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.
+        * platform/wx/MouseWheelEventWx.cpp:
+        (WebCore::PlatformWheelEvent::PlatformWheelEvent): default to false.
+
 2011-10-04  Rémi Duraffort  <remi.duraffort@st.com>
 
         [EFL] Fix compilation when SQLite and/or libxslt are not installed in /usr/include
index 85b5622..b8a5e0b 100644 (file)
@@ -39,13 +39,15 @@ WheelEvent::WheelEvent()
 WheelEvent::WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta,
                        Granularity granularity, PassRefPtr<AbstractView> view,
                        const IntPoint& screenLocation, const IntPoint& pageLocation,
-                       bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
+                       bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
+                       bool directionInvertedFromDevice)
     : MouseRelatedEvent(eventNames().mousewheelEvent,
                         true, true, view, 0, screenLocation, pageLocation,
                         ctrlKey, altKey, shiftKey, metaKey)
     , m_wheelDelta(IntPoint(static_cast<int>(wheelTicks.x() * tickMultiplier), static_cast<int>(wheelTicks.y() * tickMultiplier)))
     , m_rawDelta(roundedIntPoint(rawDelta))
     , m_granularity(granularity)
+    , m_directionInvertedFromDevice(directionInvertedFromDevice)
 {
 }
 
@@ -69,7 +71,8 @@ void WheelEvent::initWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<Abstrac
     
     m_rawDelta = IntPoint(rawDeltaX, rawDeltaY);
     m_granularity = Pixel;
-    
+    m_directionInvertedFromDevice = false;
+
     initCoordinates(IntPoint(pageX, pageY));
 }
 
@@ -101,9 +104,9 @@ WheelEventDispatchMediator::WheelEventDispatchMediator(const PlatformWheelEvent&
     if (!(event.deltaX() || event.deltaY()))
         return;
 
-    setEvent(WheelEvent::create(FloatPoint(event.wheelTicksX(), event.wheelTicksY()), FloatPoint(event.deltaX(), event.deltaY()), granularity(event),
-        view, IntPoint(event.globalX(), event.globalY()), IntPoint(event.x(), event.y()), event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey()));
-
+    setEvent(WheelEvent::create(FloatPoint(event.wheelTicksX(), event.wheelTicksY()), FloatPoint(event.deltaX(), event.deltaY()),
+                                granularity(event), view, IntPoint(event.globalX(), event.globalY()), IntPoint(event.x(), event.y()),
+                                event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), event.webkitDirectionInvertedFromDevice()));
 }
 
 WheelEvent* WheelEventDispatchMediator::event() const
index 5223ce4..9cbf7c6 100644 (file)
@@ -44,10 +44,10 @@ namespace WebCore {
         static PassRefPtr<WheelEvent> create(const FloatPoint& wheelTicks,
             const FloatPoint& rawDelta, Granularity granularity, PassRefPtr<AbstractView> view,
             const IntPoint& screenLocation, const IntPoint& pageLocation,
-            bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
+            bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool directionInvertedFromDevice)
         {
             return adoptRef(new WheelEvent(wheelTicks, rawDelta, granularity, view,
-                screenLocation, pageLocation, ctrlKey, altKey, shiftKey, metaKey));
+                screenLocation, pageLocation, ctrlKey, altKey, shiftKey, metaKey, directionInvertedFromDevice));
         }
 
         void initWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<AbstractView>,
@@ -65,6 +65,7 @@ namespace WebCore {
         int rawDeltaY() const { return m_rawDelta.y(); }
         Granularity granularity() const { return m_granularity; }
 
+        bool webkitDirectionInvertedFromDevice() const { return m_directionInvertedFromDevice; }
         // Needed for Objective-C legacy support
         bool isHorizontal() const { return m_wheelDelta.x(); }
 
@@ -73,13 +74,14 @@ namespace WebCore {
         WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta,
                    Granularity granularity, PassRefPtr<AbstractView>,
                    const IntPoint& screenLocation, const IntPoint& pageLocation,
-                   bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
+                   bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool directionInvertedFromDevice);
 
         virtual bool isWheelEvent() const;
 
         IntPoint m_wheelDelta;
         IntPoint m_rawDelta;
         Granularity m_granularity;
+        bool m_directionInvertedFromDevice;
     };
 
 class WheelEventDispatchMediator : public EventDispatchMediator {
index bd8151b..e0fd563 100644 (file)
@@ -39,6 +39,7 @@ module events {
         readonly attribute long    offsetY;
         readonly attribute long    x;
         readonly attribute long    y;
+        readonly attribute boolean webkitDirectionInvertedFromDevice;
 
 #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
         readonly attribute boolean isHorizontal;
index 537ef4c..dd5ec7f 100644 (file)
@@ -97,6 +97,7 @@ namespace WebCore {
             , m_ctrlKey(false)
             , m_altKey(false)
             , m_metaKey(false)
+            , m_directionInvertedFromDevice(false)
 #if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
             , m_hasPreciseScrollingDeltas(false)
             , m_phase(PlatformWheelEventPhaseNone)
@@ -119,6 +120,7 @@ namespace WebCore {
             , m_ctrlKey(ctrlKey)
             , m_altKey(altKey)
             , m_metaKey(metaKey)
+            , m_directionInvertedFromDevice(false)
 #if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
             , m_hasPreciseScrollingDeltas(false)
             , m_phase(PlatformWheelEventPhaseNone)
@@ -150,6 +152,8 @@ namespace WebCore {
         int globalX() const { return m_globalPosition.x(); } // Screen coordinates.
         int globalY() const { return m_globalPosition.y(); }
 
+        bool webkitDirectionInvertedFromDevice() const { return m_directionInvertedFromDevice; }
+
         void accept() { m_isAccepted = true; }
         void ignore() { m_isAccepted = false; }
 
@@ -215,6 +219,7 @@ namespace WebCore {
         bool m_ctrlKey;
         bool m_altKey;
         bool m_metaKey;
+        bool m_directionInvertedFromDevice;
 #if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
         bool m_hasPreciseScrollingDeltas;
         PlatformWheelEventPhase m_phase;
index 704db38..f1ae3b8 100644 (file)
@@ -51,6 +51,7 @@ PlatformWheelEvent::PlatformWheelEvent(const Evas_Event_Mouse_Wheel* ev)
     , m_ctrlKey(evas_key_modifier_is_set(ev->modifiers, "Control"))
     , m_altKey(evas_key_modifier_is_set(ev->modifiers, "Alt"))
     , m_metaKey(evas_key_modifier_is_set(ev->modifiers, "Meta"))
+    , m_directionInvertedFromDevice(false)
 {
     // A negative z value means (in EFL) that we are scrolling down, so we need
     // to invert the value.
index fc6206f..bcdccd8 100644 (file)
@@ -67,6 +67,7 @@ PlatformWheelEvent::PlatformWheelEvent(GdkEventScroll* event)
     m_ctrlKey = event->state & GDK_CONTROL_MASK;
     m_altKey = event->state & GDK_MOD1_MASK;
     m_metaKey = event->state & GDK_META_MASK;
+    m_directionInvertedFromDevice = false;
 
     // FIXME: retrieve the user setting for the number of lines to scroll on each wheel event
     m_deltaX *= static_cast<float>(Scrollbar::pixelsPerLineStep());
index 2494e69..39ad60b 100644 (file)
@@ -115,6 +115,12 @@ PlatformWheelEvent::PlatformWheelEvent(NSEvent* event, NSView *windowView)
         m_deltaY *= static_cast<float>(Scrollbar::pixelsPerLineStep());
         m_hasPreciseScrollingDeltas = false;
     }
+
+#if HAVE(INVERTED_WHEEL_EVENTS)
+    m_directionInvertedFromDevice = [event isDirectionInvertedFromDevice];
+#else
+    m_directionInvertedFromDevice = false;
+#endif
 }
 
 } // namespace WebCore
index aa61d91..223ecb4 100644 (file)
@@ -67,6 +67,7 @@ PlatformWheelEvent::PlatformWheelEvent(QGraphicsSceneWheelEvent* e)
     , m_ctrlKey(e->modifiers() & Qt::ControlModifier)
     , m_altKey(e->modifiers() & Qt::AltModifier)
     , m_metaKey(e->modifiers() & Qt::MetaModifier)
+    , m_directionInvertedFromDevice(false)
 #endif
 {
 #ifndef QT_NO_WHEELEVENT
@@ -86,6 +87,7 @@ PlatformWheelEvent::PlatformWheelEvent(QWheelEvent* e)
     , m_ctrlKey(e->modifiers() & Qt::ControlModifier)
     , m_altKey(e->modifiers() & Qt::AltModifier)
     , m_metaKey(e->modifiers() & Qt::MetaModifier)
+    , m_directionInvertedFromDevice(false)
 #endif
 {
 #ifndef QT_NO_WHEELEVENT
index 3fb8118..6ae68a8 100644 (file)
@@ -71,6 +71,7 @@ PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, const FloatSize& delta, const
     , m_ctrlKey(false)
     , m_altKey(false)
     , m_metaKey(false)
+    , m_directionInvertedFromDevice(false)
 {
     m_deltaX = delta.width();
     m_deltaY = delta.height();
@@ -95,6 +96,7 @@ PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, WPARAM wParam, LPARAM lParam,
     , m_ctrlKey(wParam & MK_CONTROL)
     , m_altKey(GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT)
     , m_metaKey(m_altKey) // FIXME: We'll have to test other browsers
+    , m_directionInvertedFromDevice(false)
 {
     // How many pixels should we scroll per line?  Gecko uses the height of the
     // current line, which means scroll distance changes as you go through the
index aa41df4..2349251 100644 (file)
@@ -45,6 +45,7 @@ PlatformWheelEvent::PlatformWheelEvent(const wxMouseEvent& event, const wxPoint&
     , m_wheelTicksX(m_deltaX)
     , m_wheelTicksY(m_deltaY)
     , m_isAccepted(false)
+    , m_directionInvertedFromDevice(false)
 {
     // FIXME: retrieve the user setting for the number of lines to scroll on each wheel event
     m_deltaY *= static_cast<float>(Scrollbar::pixelsPerLineStep());
index 56540f0..bff775d 100644 (file)
@@ -1,3 +1,24 @@
+2011-10-03  Jon Lee  <jonlee@apple.com>
+
+        Extend DOM WheelEvent to differentiate between physical and logical scroll directions
+        https://bugs.webkit.org/show_bug.cgi?id=68959
+        <rdar://problem/10036688>
+
+        Reviewed by Sam Weinig.
+
+        * Shared/WebEvent.h:
+        (WebKit::WebWheelEvent::directionInvertedFromDevice):
+        * Shared/WebEventConversion.cpp:
+        (WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
+        * Shared/WebWheelEvent.cpp:
+        (WebKit::WebWheelEvent::WebWheelEvent):
+        (WebKit::WebWheelEvent::encode):
+        (WebKit::WebWheelEvent::decode):
+        * Shared/mac/WebEventFactory.mm:
+        (WebKit::WebEventFactory::createWebWheelEvent): get the flag from the NSEvent.
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::coalesce):
+
 2011-10-04  Nayan Kumar K  <nayankk@motorola.com>
 
         [WebKit2][gtk] Generate gtk-doc for WebKit2-GTK.
index 178c50d..347ac15 100644 (file)
@@ -179,7 +179,7 @@ public:
 
     WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, Modifiers, double timestamp);
 #if PLATFORM(MAC)
-    WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, Phase phase, Phase momentumPhase,bool hasPreciseScrollingDeltas, Modifiers, double timestamp);
+    WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, Phase, Phase momentumPhase, bool hasPreciseScrollingDeltas, Modifiers, double timestamp, bool directionInvertedFromDevice);
 #endif
 
     const WebCore::IntPoint position() const { return m_position; }
@@ -187,6 +187,7 @@ public:
     const WebCore::FloatSize delta() const { return m_delta; }
     const WebCore::FloatSize wheelTicks() const { return m_wheelTicks; }
     Granularity granularity() const { return static_cast<Granularity>(m_granularity); }
+    bool directionInvertedFromDevice() const { return m_directionInvertedFromDevice; }
 #if PLATFORM(MAC)
     Phase phase() const { return static_cast<Phase>(m_phase); }
     Phase momentumPhase() const { return static_cast<Phase>(m_momentumPhase); }
@@ -204,6 +205,7 @@ private:
     WebCore::FloatSize m_delta;
     WebCore::FloatSize m_wheelTicks;
     uint32_t m_granularity; // Granularity
+    bool m_directionInvertedFromDevice;
 #if PLATFORM(MAC)
     uint32_t m_phase; // Phase
     uint32_t m_momentumPhase; // Phase
index 9c2fad1..21bf0f9 100644 (file)
@@ -110,6 +110,7 @@ public:
         m_ctrlKey = webEvent.controlKey();
         m_altKey = webEvent.altKey();
         m_metaKey = webEvent.metaKey();
+        m_directionInvertedFromDevice = webEvent.directionInvertedFromDevice();
 #if PLATFORM(MAC)
         m_phase = static_cast<WebCore::PlatformWheelEventPhase>(webEvent.phase());
         m_momentumPhase = static_cast<WebCore::PlatformWheelEventPhase>(webEvent.momentumPhase());
index 5940bcc..845b9e5 100644 (file)
@@ -40,6 +40,7 @@ WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint
     , m_delta(delta)
     , m_wheelTicks(wheelTicks)
     , m_granularity(granularity)
+    , m_directionInvertedFromDevice(false)
 #if PLATFORM(MAC)
     , m_phase(PhaseNone)
     , m_hasPreciseScrollingDeltas(false)
@@ -49,13 +50,14 @@ WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint
 }
 
 #if PLATFORM(MAC)
-WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Granularity granularity, Phase phase, Phase momentumPhase, bool hasPreciseScrollingDeltas, Modifiers modifiers, double timestamp)
+WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Granularity granularity, Phase phase, Phase momentumPhase, bool hasPreciseScrollingDeltas, Modifiers modifiers, double timestamp, bool directionInvertedFromDevice)
     : WebEvent(type, modifiers, timestamp)
     , m_position(position)
     , m_globalPosition(globalPosition)
     , m_delta(delta)
     , m_wheelTicks(wheelTicks)
     , m_granularity(granularity)
+    , m_directionInvertedFromDevice(directionInvertedFromDevice)
     , m_phase(phase)
     , m_momentumPhase(momentumPhase)
     , m_hasPreciseScrollingDeltas(hasPreciseScrollingDeltas)
@@ -73,6 +75,7 @@ void WebWheelEvent::encode(CoreIPC::ArgumentEncoder* encoder) const
     encoder->encode(m_delta);
     encoder->encode(m_wheelTicks);
     encoder->encode(m_granularity);
+    encoder->encode(m_directionInvertedFromDevice);
 #if PLATFORM(MAC)
     encoder->encode(m_phase);
     encoder->encode(m_momentumPhase);
@@ -94,6 +97,8 @@ bool WebWheelEvent::decode(CoreIPC::ArgumentDecoder* decoder, WebWheelEvent& t)
         return false;
     if (!decoder->decode(t.m_granularity))
         return false;
+    if (!decoder->decode(t.m_directionInvertedFromDevice))
+        return false;
 #if PLATFORM(MAC)
     if (!decoder->decode(t.m_phase))
         return false;
index 046f572..8e72387 100644 (file)
@@ -1096,8 +1096,12 @@ WebWheelEvent WebEventFactory::createWebWheelEvent(NSEvent *event, NSView *windo
     bool hasPreciseScrollingDeltas          = continuous;
     WebEvent::Modifiers modifiers           = modifiersForEvent(event);
     double timestamp                        = [event timestamp];
-    
-    return WebWheelEvent(WebEvent::Wheel, IntPoint(position), IntPoint(globalPosition), FloatSize(deltaX, deltaY), FloatSize(wheelTicksX, wheelTicksY), granularity, phase, momentumPhase, hasPreciseScrollingDeltas, modifiers, timestamp);
+#if HAVE(INVERTED_WHEEL_EVENTS)
+    bool directionInvertedFromDevice        = [event isDirectionInvertedFromDevice];
+#else
+    bool directionInvertedFromDevice        = false;
+#endif
+    return WebWheelEvent(WebEvent::Wheel, IntPoint(position), IntPoint(globalPosition), FloatSize(deltaX, deltaY), FloatSize(wheelTicksX, wheelTicksY), granularity, phase, momentumPhase, hasPreciseScrollingDeltas, modifiers, timestamp, directionInvertedFromDevice);
 }
 
 WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(NSEvent *event, NSView *)
index 6c0447e..abfd99f 100644 (file)
@@ -2670,7 +2670,7 @@ static WebWheelEvent coalesce(const WebWheelEvent& a, const WebWheelEvent& b)
     FloatSize mergedWheelTicks = a.wheelTicks() + b.wheelTicks();
 
 #if PLATFORM(MAC)
-    return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.phase(), b.momentumPhase(), b.hasPreciseScrollingDeltas(), b.modifiers(), b.timestamp());
+    return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.phase(), b.momentumPhase(), b.hasPreciseScrollingDeltas(), b.modifiers(), b.timestamp(), b.directionInvertedFromDevice());
 #else
     return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.modifiers(), b.timestamp());
 #endif