Title: [121025] trunk/Source
Revision
121025
Author
[email protected]
Date
2012-06-22 08:18:46 -0700 (Fri, 22 Jun 2012)

Log Message

Suppress horizontal conversion of PlatformWheelEvents when hasPreciseScrollingDeltas is true
https://bugs.webkit.org/show_bug.cgi?id=89580

Source/WebCore:

WebKit GTK and Chromium Linux force vertical wheel events to
scroll horizontally when over horizontal scroll bars.  This is
undesirable for touchpad scrolling with
hasPreciseScrollingDeltas() == true. Modified shouldTurnVerticalTicksIntoHorizontal
to not perform this conversion for PlatformWheelEvents with preciseScrollingDeltas.

Reviewed by Adam Barth.

Unit tests in EventHandlerTest.cpp

* page/EventHandler.cpp:
(WebCore::EventHandler::shouldTurnVerticalTicksIntoHorizontal):
(WebCore::EventHandler::handleWheelEvent):
* page/EventHandler.h:
(EventHandler):
* page/chromium/EventHandlerChromium.cpp:
(WebCore::EventHandler::shouldTurnVerticalTicksIntoHorizontal):
* page/gtk/EventHandlerGtk.cpp:
(WebCore::EventHandler::shouldTurnVerticalTicksIntoHorizontal):

Source/WebKit/chromium:

WebKit GTK and Chromium Linux force vertical wheel events to
scroll horizontally when over horizontal scroll bars.  This is
undesirable for touchpad scrolling with hasPreciseScrollingDeltas() == true.

Added unit tests to show that
EventHandler::shouldTurnVerticalTicksIntoHorizontal() is true
only for PlatformWheelEvents when !hasPreciseScrollingDeltas().

Reviewed by Adam Barth.

* WebKit.gypi:
* tests/EventHandlerTest.cpp: Added.
(MockScrollbar):
(MockScrollbar::MockScrollbar):
(MockScrollbar::~MockScrollbar):
(MockHitTestResult):
(MockHitTestResult::MockHitTestResult):
(MockHitTestResult::scrollbar):
(MockPlatformWheelEvent):
(MockPlatformWheelEvent::MockPlatformWheelEvent):
(EventHandlerTest):
(EventHandlerTest::EventHandlerTest):
(EventHandlerTest::externalShouldTurnVerticalTicksIntoHorizontal):
(TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (121024 => 121025)


--- trunk/Source/WebCore/ChangeLog	2012-06-22 14:47:33 UTC (rev 121024)
+++ trunk/Source/WebCore/ChangeLog	2012-06-22 15:18:46 UTC (rev 121025)
@@ -1,3 +1,28 @@
+2012-06-22  Robert Kroeger  <[email protected]>
+
+        Suppress horizontal conversion of PlatformWheelEvents when hasPreciseScrollingDeltas is true
+        https://bugs.webkit.org/show_bug.cgi?id=89580
+
+        WebKit GTK and Chromium Linux force vertical wheel events to
+        scroll horizontally when over horizontal scroll bars.  This is
+        undesirable for touchpad scrolling with
+        hasPreciseScrollingDeltas() == true. Modified shouldTurnVerticalTicksIntoHorizontal
+        to not perform this conversion for PlatformWheelEvents with preciseScrollingDeltas.
+
+        Reviewed by Adam Barth.
+
+        Unit tests in EventHandlerTest.cpp
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::shouldTurnVerticalTicksIntoHorizontal): 
+        (WebCore::EventHandler::handleWheelEvent):
+        * page/EventHandler.h:
+        (EventHandler):
+        * page/chromium/EventHandlerChromium.cpp:
+        (WebCore::EventHandler::shouldTurnVerticalTicksIntoHorizontal):
+        * page/gtk/EventHandlerGtk.cpp:
+        (WebCore::EventHandler::shouldTurnVerticalTicksIntoHorizontal):
+
 2012-06-22  Ilya Tikhonovsky  <[email protected]>
 
         Web Inspector: partially instrument DOM Tree native memory.

Modified: trunk/Source/WebCore/page/EventHandler.cpp (121024 => 121025)


--- trunk/Source/WebCore/page/EventHandler.cpp	2012-06-22 14:47:33 UTC (rev 121024)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2012-06-22 15:18:46 UTC (rev 121025)
@@ -2284,7 +2284,7 @@
 }
 
 #if !PLATFORM(GTK) && !(PLATFORM(CHROMIUM) && (OS(UNIX) && !OS(DARWIN)))
-bool EventHandler::shouldTurnVerticalTicksIntoHorizontal(const HitTestResult&) const
+bool EventHandler::shouldTurnVerticalTicksIntoHorizontal(const HitTestResult&, const PlatformWheelEvent&) const
 {
     return false;
 }
@@ -2339,7 +2339,7 @@
     // Instead, the handlers should know convert vertical scrolls
     // appropriately.
     PlatformWheelEvent event = e;
-    if (m_baseEventType == PlatformEvent::NoType && shouldTurnVerticalTicksIntoHorizontal(result))
+    if (m_baseEventType == PlatformEvent::NoType && shouldTurnVerticalTicksIntoHorizontal(result, e))
         event = event.copyTurningVerticalTicksIntoHorizontalTicks();
 
     if (node) {

Modified: trunk/Source/WebCore/page/EventHandler.h (121024 => 121025)


--- trunk/Source/WebCore/page/EventHandler.h	2012-06-22 14:47:33 UTC (rev 121024)
+++ trunk/Source/WebCore/page/EventHandler.h	2012-06-22 15:18:46 UTC (rev 121025)
@@ -48,6 +48,8 @@
 #include <wtf/HashMap.h>
 #endif
 
+class EventHandlerTest;
+
 namespace WebCore {
 
 class Clipboard;
@@ -227,6 +229,8 @@
 #endif
 
 private:
+    friend class ::EventHandlerTest;
+
 #if ENABLE(DRAG_SUPPORT)
     static DragState& dragState();
     static const double TextDragDelay;
@@ -266,7 +270,7 @@
     void autoscrollTimerFired(Timer<EventHandler>*);
     bool logicalScrollOverflow(ScrollLogicalDirection, ScrollGranularity, Node* startingNode = 0);
     
-    bool shouldTurnVerticalTicksIntoHorizontal(const HitTestResult&) const;
+    bool shouldTurnVerticalTicksIntoHorizontal(const HitTestResult&, const PlatformWheelEvent&) const;
     bool mouseDownMayStartSelect() const { return m_mouseDownMayStartSelect; }
 
     static bool isKeyboardOptionTab(KeyboardEvent*);

Modified: trunk/Source/WebCore/page/chromium/EventHandlerChromium.cpp (121024 => 121025)


--- trunk/Source/WebCore/page/chromium/EventHandlerChromium.cpp	2012-06-22 14:47:33 UTC (rev 121024)
+++ trunk/Source/WebCore/page/chromium/EventHandlerChromium.cpp	2012-06-22 15:18:46 UTC (rev 121025)
@@ -158,9 +158,9 @@
 // GTK+ must scroll horizontally if the mouse pointer is on top of the
 // horizontal scrollbar while scrolling with the wheel.
 // This code comes from gtk/EventHandlerGtk.cpp.
-bool EventHandler::shouldTurnVerticalTicksIntoHorizontal(const HitTestResult& result) const
+bool EventHandler::shouldTurnVerticalTicksIntoHorizontal(const HitTestResult& result, const PlatformWheelEvent& event) const
 {
-    return result.scrollbar() && result.scrollbar()->orientation() == HorizontalScrollbar;
+    return !event.hasPreciseScrollingDeltas() && result.scrollbar() && result.scrollbar()->orientation() == HorizontalScrollbar;
 }
 #endif
 

Modified: trunk/Source/WebCore/page/gtk/EventHandlerGtk.cpp (121024 => 121025)


--- trunk/Source/WebCore/page/gtk/EventHandlerGtk.cpp	2012-06-22 14:47:33 UTC (rev 121024)
+++ trunk/Source/WebCore/page/gtk/EventHandlerGtk.cpp	2012-06-22 15:18:46 UTC (rev 121025)
@@ -126,7 +126,7 @@
 // horizontal scrollbar while scrolling with the wheel; we need to
 // add the deltas and ticks here so that this behavior is consistent
 // for styled scrollbars.
-bool EventHandler::shouldTurnVerticalTicksIntoHorizontal(const HitTestResult& result) const
+bool EventHandler::shouldTurnVerticalTicksIntoHorizontal(const HitTestResult& result, const PlatformWheelEvent&) const
 {
     return result.scrollbar() && result.scrollbar()->orientation() == HorizontalScrollbar;
 }

Modified: trunk/Source/WebKit/chromium/ChangeLog (121024 => 121025)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-06-22 14:47:33 UTC (rev 121024)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-06-22 15:18:46 UTC (rev 121025)
@@ -1,3 +1,33 @@
+2012-06-22  Robert Kroeger  <[email protected]>
+
+        Suppress horizontal conversion of PlatformWheelEvents when hasPreciseScrollingDeltas is true
+        https://bugs.webkit.org/show_bug.cgi?id=89580
+
+        WebKit GTK and Chromium Linux force vertical wheel events to
+        scroll horizontally when over horizontal scroll bars.  This is
+        undesirable for touchpad scrolling with hasPreciseScrollingDeltas() == true.
+
+        Added unit tests to show that
+        EventHandler::shouldTurnVerticalTicksIntoHorizontal() is true
+        only for PlatformWheelEvents when !hasPreciseScrollingDeltas().
+
+        Reviewed by Adam Barth.
+
+        * WebKit.gypi:
+        * tests/EventHandlerTest.cpp: Added.
+        (MockScrollbar):
+        (MockScrollbar::MockScrollbar):
+        (MockScrollbar::~MockScrollbar):
+        (MockHitTestResult):
+        (MockHitTestResult::MockHitTestResult):
+        (MockHitTestResult::scrollbar):
+        (MockPlatformWheelEvent):
+        (MockPlatformWheelEvent::MockPlatformWheelEvent):
+        (EventHandlerTest):
+        (EventHandlerTest::EventHandlerTest):
+        (EventHandlerTest::externalShouldTurnVerticalTicksIntoHorizontal):
+        (TEST):
+
 2012-06-22  Amy Ousterhout  <[email protected]>
 
         Renamed DeviceOrientation to DeviceOrientationData

Modified: trunk/Source/WebKit/chromium/WebKit.gypi (121024 => 121025)


--- trunk/Source/WebKit/chromium/WebKit.gypi	2012-06-22 14:47:33 UTC (rev 121024)
+++ trunk/Source/WebKit/chromium/WebKit.gypi	2012-06-22 15:18:46 UTC (rev 121025)
@@ -102,6 +102,7 @@
             'tests/DecimalTest.cpp',
             'tests/DragImageTest.cpp',
             'tests/DrawingBufferChromiumTest.cpp',
+            'tests/EventHandlerTest.cpp',
             'tests/EventListenerTest.cpp',
             'tests/FakeCCLayerTreeHostClient.h',
             'tests/FakeGraphicsContext3DTest.cpp',

Added: trunk/Source/WebKit/chromium/tests/EventHandlerTest.cpp (0 => 121025)


--- trunk/Source/WebKit/chromium/tests/EventHandlerTest.cpp	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/EventHandlerTest.cpp	2012-06-22 15:18:46 UTC (rev 121025)
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2012 Google 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 "config.h"
+
+#include "EventHandler.h"
+
+#include "Frame.h"
+#include "HitTestResult.h"
+#include "PlatformWheelEvent.h"
+#include "ScrollTypes.h"
+#include "Scrollbar.h"
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+using namespace std;
+using namespace WebCore;
+
+class MockScrollbar : public Scrollbar {
+public:
+    MockScrollbar(ScrollbarOrientation orientation) : Scrollbar(0, orientation, RegularScrollbar) { }
+    virtual ~MockScrollbar() { }
+};
+
+class MockHitTestResult : public HitTestResult {
+public:
+    MockHitTestResult(Scrollbar* scrollbar) : HitTestResult()
+    {
+        setScrollbar(scrollbar);
+    }
+
+};
+
+class MockPlatformWheelEvent : public PlatformWheelEvent {
+public:
+    MockPlatformWheelEvent(bool hasPreciseScrollingDeltas) : PlatformWheelEvent()
+    {
+        m_hasPreciseScrollingDeltas = hasPreciseScrollingDeltas;
+    }
+};
+
+class EventHandlerTest : public EventHandler {
+public:
+    EventHandlerTest() : EventHandler(0) { };
+    bool externalShouldTurnVerticalTicksIntoHorizontal(const HitTestResult& hitTestResult, const PlatformWheelEvent& wheelEvent)
+    {
+         return EventHandler::shouldTurnVerticalTicksIntoHorizontal(hitTestResult, wheelEvent);
+    }
+};
+
+TEST(EventHandler, shouldTurnVerticalTicksIntoHorizontal)
+{
+    EventHandlerTest handler;
+
+    RefPtr<MockScrollbar> verticalScrollbar = adoptRef(new MockScrollbar(VerticalScrollbar));
+    RefPtr<MockScrollbar> horizontalScrollbar = adoptRef(new MockScrollbar(HorizontalScrollbar));
+
+    // Verify that the MockScrollbar instances have the correct orientations.
+    EXPECT_EQ(VerticalScrollbar, verticalScrollbar->orientation());
+    EXPECT_EQ(HorizontalScrollbar, horizontalScrollbar->orientation());
+
+    MockHitTestResult noScrollbarHitTestResult(0);
+    MockHitTestResult horizontalScrollbarHitTestResult(horizontalScrollbar.get());
+    MockHitTestResult verticalScrollbarHitTestResult(verticalScrollbar.get());
+
+    // Verify that the MockHitTestResult instances have the right scrollbars.
+    EXPECT_EQ(horizontalScrollbar, horizontalScrollbarHitTestResult.scrollbar());
+    EXPECT_EQ(verticalScrollbar, verticalScrollbarHitTestResult.scrollbar());
+    EXPECT_EQ(0, noScrollbarHitTestResult.scrollbar());
+    EXPECT_EQ(HorizontalScrollbar, horizontalScrollbarHitTestResult.scrollbar()->orientation());
+
+    MockPlatformWheelEvent preciseWheelEvent(true);
+    MockPlatformWheelEvent basicWheelEvent(false);
+
+    // Verify that the wheel event instances have the right hasPreciseScrollingDeltas setting.
+    EXPECT_TRUE(preciseWheelEvent.hasPreciseScrollingDeltas());
+    EXPECT_FALSE(basicWheelEvent.hasPreciseScrollingDeltas());
+
+#if OS(UNIX) && !OS(DARWIN)
+    EXPECT_FALSE(handler.externalShouldTurnVerticalTicksIntoHorizontal(noScrollbarHitTestResult, basicWheelEvent));
+    EXPECT_FALSE(handler.externalShouldTurnVerticalTicksIntoHorizontal(noScrollbarHitTestResult, preciseWheelEvent));
+
+    EXPECT_FALSE(handler.externalShouldTurnVerticalTicksIntoHorizontal(verticalScrollbarHitTestResult, basicWheelEvent));
+    EXPECT_FALSE(handler.externalShouldTurnVerticalTicksIntoHorizontal(verticalScrollbarHitTestResult, preciseWheelEvent));
+
+    EXPECT_TRUE(handler.externalShouldTurnVerticalTicksIntoHorizontal(horizontalScrollbarHitTestResult, basicWheelEvent));
+    EXPECT_FALSE(handler.externalShouldTurnVerticalTicksIntoHorizontal(horizontalScrollbarHitTestResult, preciseWheelEvent));
+#else
+    EXPECT_FALSE(handler.externalShouldTurnVerticalTicksIntoHorizontal(noScrollbarHitTestResult, basicWheelEvent));
+    EXPECT_FALSE(handler.externalShouldTurnVerticalTicksIntoHorizontal(noScrollbarHitTestResult, preciseWheelEvent));
+
+    EXPECT_FALSE(handler.externalShouldTurnVerticalTicksIntoHorizontal(verticalScrollbarHitTestResult, basicWheelEvent));
+    EXPECT_FALSE(handler.externalShouldTurnVerticalTicksIntoHorizontal(verticalScrollbarHitTestResult, preciseWheelEvent));
+
+    EXPECT_FALSE(handler.externalShouldTurnVerticalTicksIntoHorizontal(horizontalScrollbarHitTestResult, basicWheelEvent));
+    EXPECT_FALSE(handler.externalShouldTurnVerticalTicksIntoHorizontal(horizontalScrollbarHitTestResult, preciseWheelEvent));
+#endif
+}
+
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to