Title: [96613] trunk
Revision
96613
Author
jon...@apple.com
Date
2011-10-04 11:06:44 -0700 (Tue, 04 Oct 2011)

Log Message

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.

Source/_javascript_Core:

* 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.

Modified Paths

Added Paths

Property Changed

Diff

Modified: trunk/LayoutTests/ChangeLog (96612 => 96613)


--- trunk/LayoutTests/ChangeLog	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/LayoutTests/ChangeLog	2011-10-04 18:06:44 UTC (rev 96613)
@@ -1,3 +1,15 @@
+2011-10-03  Jon Lee  <jon...@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 <ke...@chromium.org>
 
         Resource loader should block HTTP redirects to local resources
Property changes on: trunk/LayoutTests/ChangeLog
___________________________________________________________________

Deleted: svn:executable

Added: trunk/LayoutTests/fast/events/wheelevent-direction-inverted-from-device-expected.txt (0 => 96613)


--- trunk/LayoutTests/fast/events/wheelevent-direction-inverted-from-device-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/wheelevent-direction-inverted-from-device-expected.txt	2011-10-04 18:06:44 UTC (rev 96613)
@@ -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
+

Added: trunk/LayoutTests/fast/events/wheelevent-direction-inverted-from-device.html (0 => 96613)


--- trunk/LayoutTests/fast/events/wheelevent-direction-inverted-from-device.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/wheelevent-direction-inverted-from-device.html	2011-10-04 18:06:44 UTC (rev 96613)
@@ -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=""
+<link rel="stylesheet" href=""
+
+<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=""
+
+</body>
+</html>
\ No newline at end of file

Modified: trunk/LayoutTests/platform/mac-wk2/Skipped (96612 => 96613)


--- trunk/LayoutTests/platform/mac-wk2/Skipped	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/LayoutTests/platform/mac-wk2/Skipped	2011-10-04 18:06:44 UTC (rev 96613)
@@ -157,6 +157,7 @@
 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

Modified: trunk/Source/_javascript_Core/ChangeLog (96612 => 96613)


--- trunk/Source/_javascript_Core/ChangeLog	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-10-04 18:06:44 UTC (rev 96613)
@@ -1,3 +1,13 @@
+2011-10-03  Jon Lee  <jon...@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  <o...@webkit.org>
 
         MinGW warning fix after r96286.

Modified: trunk/Source/_javascript_Core/wtf/Platform.h (96612 => 96613)


--- trunk/Source/_javascript_Core/wtf/Platform.h	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/_javascript_Core/wtf/Platform.h	2011-10-04 18:06:44 UTC (rev 96613)
@@ -1104,4 +1104,8 @@
 #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 */

Modified: trunk/Source/WebCore/ChangeLog (96612 => 96613)


--- trunk/Source/WebCore/ChangeLog	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/WebCore/ChangeLog	2011-10-04 18:06:44 UTC (rev 96613)
@@ -1,3 +1,38 @@
+2011-10-03  Jon Lee  <jon...@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.duraff...@st.com>
 
         [EFL] Fix compilation when SQLite and/or libxslt are not installed in /usr/include
Property changes on: trunk/Source/WebCore/ChangeLog
___________________________________________________________________

Deleted: svn:executable

Modified: trunk/Source/WebCore/dom/WheelEvent.cpp (96612 => 96613)


--- trunk/Source/WebCore/dom/WheelEvent.cpp	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/WebCore/dom/WheelEvent.cpp	2011-10-04 18:06:44 UTC (rev 96613)
@@ -39,13 +39,15 @@
 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 @@
     
     m_rawDelta = IntPoint(rawDeltaX, rawDeltaY);
     m_granularity = Pixel;
-    
+    m_directionInvertedFromDevice = false;
+
     initCoordinates(IntPoint(pageX, pageY));
 }
 
@@ -101,9 +104,9 @@
     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

Modified: trunk/Source/WebCore/dom/WheelEvent.h (96612 => 96613)


--- trunk/Source/WebCore/dom/WheelEvent.h	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/WebCore/dom/WheelEvent.h	2011-10-04 18:06:44 UTC (rev 96613)
@@ -44,10 +44,10 @@
         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 @@
         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 @@
         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 {

Modified: trunk/Source/WebCore/dom/WheelEvent.idl (96612 => 96613)


--- trunk/Source/WebCore/dom/WheelEvent.idl	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/WebCore/dom/WheelEvent.idl	2011-10-04 18:06:44 UTC (rev 96613)
@@ -39,6 +39,7 @@
         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;

Modified: trunk/Source/WebCore/platform/PlatformWheelEvent.h (96612 => 96613)


--- trunk/Source/WebCore/platform/PlatformWheelEvent.h	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/WebCore/platform/PlatformWheelEvent.h	2011-10-04 18:06:44 UTC (rev 96613)
@@ -97,6 +97,7 @@
             , 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 @@
             , 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 @@
         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 @@
         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;

Modified: trunk/Source/WebCore/platform/efl/PlatformWheelEventEfl.cpp (96612 => 96613)


--- trunk/Source/WebCore/platform/efl/PlatformWheelEventEfl.cpp	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/WebCore/platform/efl/PlatformWheelEventEfl.cpp	2011-10-04 18:06:44 UTC (rev 96613)
@@ -51,6 +51,7 @@
     , 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.

Modified: trunk/Source/WebCore/platform/gtk/PlatformWheelEventGtk.cpp (96612 => 96613)


--- trunk/Source/WebCore/platform/gtk/PlatformWheelEventGtk.cpp	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/WebCore/platform/gtk/PlatformWheelEventGtk.cpp	2011-10-04 18:06:44 UTC (rev 96613)
@@ -67,6 +67,7 @@
     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());

Modified: trunk/Source/WebCore/platform/mac/WheelEventMac.mm (96612 => 96613)


--- trunk/Source/WebCore/platform/mac/WheelEventMac.mm	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/WebCore/platform/mac/WheelEventMac.mm	2011-10-04 18:06:44 UTC (rev 96613)
@@ -115,6 +115,12 @@
         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

Modified: trunk/Source/WebCore/platform/qt/WheelEventQt.cpp (96612 => 96613)


--- trunk/Source/WebCore/platform/qt/WheelEventQt.cpp	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/WebCore/platform/qt/WheelEventQt.cpp	2011-10-04 18:06:44 UTC (rev 96613)
@@ -67,6 +67,7 @@
     , 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 @@
     , 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

Modified: trunk/Source/WebCore/platform/win/WheelEventWin.cpp (96612 => 96613)


--- trunk/Source/WebCore/platform/win/WheelEventWin.cpp	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/WebCore/platform/win/WheelEventWin.cpp	2011-10-04 18:06:44 UTC (rev 96613)
@@ -71,6 +71,7 @@
     , m_ctrlKey(false)
     , m_altKey(false)
     , m_metaKey(false)
+    , m_directionInvertedFromDevice(false)
 {
     m_deltaX = delta.width();
     m_deltaY = delta.height();
@@ -95,6 +96,7 @@
     , 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

Modified: trunk/Source/WebCore/platform/wx/MouseWheelEventWx.cpp (96612 => 96613)


--- trunk/Source/WebCore/platform/wx/MouseWheelEventWx.cpp	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/WebCore/platform/wx/MouseWheelEventWx.cpp	2011-10-04 18:06:44 UTC (rev 96613)
@@ -45,6 +45,7 @@
     , 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());

Modified: trunk/Source/WebKit2/ChangeLog (96612 => 96613)


--- trunk/Source/WebKit2/ChangeLog	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/WebKit2/ChangeLog	2011-10-04 18:06:44 UTC (rev 96613)
@@ -1,3 +1,24 @@
+2011-10-03  Jon Lee  <jon...@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  <naya...@motorola.com>
 
         [WebKit2][gtk] Generate gtk-doc for WebKit2-GTK.

Modified: trunk/Source/WebKit2/Shared/WebEvent.h (96612 => 96613)


--- trunk/Source/WebKit2/Shared/WebEvent.h	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/WebKit2/Shared/WebEvent.h	2011-10-04 18:06:44 UTC (rev 96613)
@@ -179,7 +179,7 @@
 
     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 @@
     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 @@
     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

Modified: trunk/Source/WebKit2/Shared/WebEventConversion.cpp (96612 => 96613)


--- trunk/Source/WebKit2/Shared/WebEventConversion.cpp	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/WebKit2/Shared/WebEventConversion.cpp	2011-10-04 18:06:44 UTC (rev 96613)
@@ -110,6 +110,7 @@
         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());

Modified: trunk/Source/WebKit2/Shared/WebWheelEvent.cpp (96612 => 96613)


--- trunk/Source/WebKit2/Shared/WebWheelEvent.cpp	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/WebKit2/Shared/WebWheelEvent.cpp	2011-10-04 18:06:44 UTC (rev 96613)
@@ -40,6 +40,7 @@
     , 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 @@
 }
 
 #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 @@
     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 @@
         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;

Modified: trunk/Source/WebKit2/Shared/mac/WebEventFactory.mm (96612 => 96613)


--- trunk/Source/WebKit2/Shared/mac/WebEventFactory.mm	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/WebKit2/Shared/mac/WebEventFactory.mm	2011-10-04 18:06:44 UTC (rev 96613)
@@ -1096,8 +1096,12 @@
     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 *)

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (96612 => 96613)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2011-10-04 18:04:21 UTC (rev 96612)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2011-10-04 18:06:44 UTC (rev 96613)
@@ -2670,7 +2670,7 @@
     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
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to