Title: [227966] trunk/Source
Revision
227966
Author
[email protected]
Date
2018-02-01 08:04:09 -0800 (Thu, 01 Feb 2018)

Log Message

[GTK] Shift + mouse scroll should scroll horizontally
https://bugs.webkit.org/show_bug.cgi?id=181629

Reviewed by Michael Catanzaro.

Source/WebCore:

We currently turn vertical scroll into horizontal when scrolling over the horizontal scrollbar. When Shift key is
pressed, we still want to scroll in the scrollbar direction when scrolling over a scrollbar, so we need to swap
directions in both scrollbars depending on whther the Shift key is pressed or not.

* page/EventHandler.cpp:
(WebCore::EventHandler::shouldSwapScrollDirection const): Renamed.
(WebCore::EventHandler::handleWheelEvent): Use the new name.
(WebCore::EventHandler::shouldTurnVerticalTicksIntoHorizontal const): Deleted.
* page/EventHandler.h:
* platform/PlatformWheelEvent.h:
(WebCore::PlatformWheelEvent::copySwappingDirection const): Swap the direction of the event.
(WebCore::PlatformWheelEvent::copyTurningVerticalTicksIntoHorizontalTicks const): Deleted.
* platform/glib/EventHandlerGLib.cpp:
(WebCore::EventHandler::shouldSwapScrollDirection const): Take into account whether the Shift key is present.
(WebCore::EventHandler::shouldTurnVerticalTicksIntoHorizontal const): Deleted.

Source/WebKit:

Swap scroll direction when Shift is pressed for consistency with GtkScrolledWindow.

* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseScrollEvent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (227965 => 227966)


--- trunk/Source/WebCore/ChangeLog	2018-02-01 15:55:14 UTC (rev 227965)
+++ trunk/Source/WebCore/ChangeLog	2018-02-01 16:04:09 UTC (rev 227966)
@@ -1,5 +1,28 @@
 2018-02-01  Carlos Garcia Campos  <[email protected]>
 
+        [GTK] Shift + mouse scroll should scroll horizontally
+        https://bugs.webkit.org/show_bug.cgi?id=181629
+
+        Reviewed by Michael Catanzaro.
+
+        We currently turn vertical scroll into horizontal when scrolling over the horizontal scrollbar. When Shift key is
+        pressed, we still want to scroll in the scrollbar direction when scrolling over a scrollbar, so we need to swap
+        directions in both scrollbars depending on whther the Shift key is pressed or not.
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::shouldSwapScrollDirection const): Renamed.
+        (WebCore::EventHandler::handleWheelEvent): Use the new name.
+        (WebCore::EventHandler::shouldTurnVerticalTicksIntoHorizontal const): Deleted.
+        * page/EventHandler.h:
+        * platform/PlatformWheelEvent.h:
+        (WebCore::PlatformWheelEvent::copySwappingDirection const): Swap the direction of the event.
+        (WebCore::PlatformWheelEvent::copyTurningVerticalTicksIntoHorizontalTicks const): Deleted.
+        * platform/glib/EventHandlerGLib.cpp:
+        (WebCore::EventHandler::shouldSwapScrollDirection const): Take into account whether the Shift key is present.
+        (WebCore::EventHandler::shouldTurnVerticalTicksIntoHorizontal const): Deleted.
+
+2018-02-01  Carlos Garcia Campos  <[email protected]>
+
         [GTK] Problem with Washington Post images
         https://bugs.webkit.org/show_bug.cgi?id=181421
 

Modified: trunk/Source/WebCore/page/EventHandler.cpp (227965 => 227966)


--- trunk/Source/WebCore/page/EventHandler.cpp	2018-02-01 15:55:14 UTC (rev 227965)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2018-02-01 16:04:09 UTC (rev 227966)
@@ -2639,7 +2639,7 @@
 
 #if !PLATFORM(GTK) && !PLATFORM(WPE)
 
-bool EventHandler::shouldTurnVerticalTicksIntoHorizontal(const HitTestResult&, const PlatformWheelEvent&) const
+bool EventHandler::shouldSwapScrollDirection(const HitTestResult&, const PlatformWheelEvent&) const
 {
     return false;
 }
@@ -2783,10 +2783,7 @@
 
     // FIXME: It should not be necessary to do this mutation here.
     // Instead, the handlers should know convert vertical scrolls appropriately.
-    PlatformWheelEvent adjustedEvent = event;
-    if (shouldTurnVerticalTicksIntoHorizontal(result, event))
-        adjustedEvent = event.copyTurningVerticalTicksIntoHorizontalTicks();
-
+    PlatformWheelEvent adjustedEvent = shouldSwapScrollDirection(result, event) ? event.copySwappingDirection() : event;
     platformRecordWheelEvent(adjustedEvent);
 
     if (element) {

Modified: trunk/Source/WebCore/page/EventHandler.h (227965 => 227966)


--- trunk/Source/WebCore/page/EventHandler.h	2018-02-01 15:55:14 UTC (rev 227965)
+++ trunk/Source/WebCore/page/EventHandler.h	2018-02-01 16:04:09 UTC (rev 227966)
@@ -384,7 +384,7 @@
 
     bool logicalScrollOverflow(ScrollLogicalDirection, ScrollGranularity, Node* startingNode = nullptr);
     
-    bool shouldTurnVerticalTicksIntoHorizontal(const HitTestResult&, const PlatformWheelEvent&) const;
+    bool shouldSwapScrollDirection(const HitTestResult&, const PlatformWheelEvent&) const;
     
     bool mouseDownMayStartSelect() const { return m_mouseDownMayStartSelect; }
 

Modified: trunk/Source/WebCore/platform/PlatformWheelEvent.h (227965 => 227966)


--- trunk/Source/WebCore/platform/PlatformWheelEvent.h	2018-02-01 15:55:14 UTC (rev 227965)
+++ trunk/Source/WebCore/platform/PlatformWheelEvent.h	2018-02-01 16:04:09 UTC (rev 227966)
@@ -81,13 +81,11 @@
     {
     }
 
-    PlatformWheelEvent copyTurningVerticalTicksIntoHorizontalTicks() const
+    PlatformWheelEvent copySwappingDirection() const
     {
         PlatformWheelEvent copy = *this;
-        copy.m_deltaX = copy.m_deltaY;
-        copy.m_deltaY = 0;
-        copy.m_wheelTicksX = copy.m_wheelTicksY;
-        copy.m_wheelTicksY = 0;
+        std::swap(copy.m_deltaX, copy.m_deltaY);
+        std::swap(copy.m_wheelTicksX, copy.m_wheelTicksY);
         return copy;
     }
 

Modified: trunk/Source/WebCore/platform/glib/EventHandlerGLib.cpp (227965 => 227966)


--- trunk/Source/WebCore/platform/glib/EventHandlerGLib.cpp	2018-02-01 15:55:14 UTC (rev 227965)
+++ trunk/Source/WebCore/platform/glib/EventHandlerGLib.cpp	2018-02-01 16:04:09 UTC (rev 227966)
@@ -128,7 +128,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 PlatformWheelEvent& event) const
+bool EventHandler::shouldSwapScrollDirection(const HitTestResult& result, const PlatformWheelEvent& event) const
 {
 #if PLATFORM(GTK)
     FrameView* view = m_frame.view();
@@ -135,7 +135,12 @@
     Scrollbar* scrollbar = view ? view->scrollbarAtPoint(event.position()) : nullptr;
     if (!scrollbar)
         scrollbar = result.scrollbar();
-    return scrollbar && scrollbar->orientation() == HorizontalScrollbar;
+    if (!scrollbar)
+        return false;
+
+    // The directions are already swapped when shift key is pressed, but when scrolling
+    // over scrollbars we always want to follow the scrollbar direction.
+    return scrollbar->orientation() == HorizontalScrollbar ? !event.shiftKey() : event.shiftKey();
 #else
     UNUSED_PARAM(result);
     UNUSED_PARAM(event);

Modified: trunk/Source/WebKit/ChangeLog (227965 => 227966)


--- trunk/Source/WebKit/ChangeLog	2018-02-01 15:55:14 UTC (rev 227965)
+++ trunk/Source/WebKit/ChangeLog	2018-02-01 16:04:09 UTC (rev 227966)
@@ -1,5 +1,17 @@
 2018-02-01  Carlos Garcia Campos  <[email protected]>
 
+        [GTK] Shift + mouse scroll should scroll horizontally
+        https://bugs.webkit.org/show_bug.cgi?id=181629
+
+        Reviewed by Michael Catanzaro.
+
+        Swap scroll direction when Shift is pressed for consistency with GtkScrolledWindow.
+
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseScrollEvent):
+
+2018-02-01  Carlos Garcia Campos  <[email protected]>
+
         REGRESSION(r227893): fast/events/touch/touch-stale-node-crash.html and other tests crash
         https://bugs.webkit.org/show_bug.cgi?id=182350
 

Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp (227965 => 227966)


--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp	2018-02-01 15:55:14 UTC (rev 227965)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp	2018-02-01 16:04:09 UTC (rev 227966)
@@ -830,6 +830,27 @@
     if (priv->authenticationDialog)
         return GDK_EVENT_PROPAGATE;
 
+    // Shift+Wheel scrolls in the perpendicular direction.
+    if (event->state & GDK_SHIFT_MASK) {
+        switch (event->direction) {
+        case GDK_SCROLL_UP:
+            event->direction = GDK_SCROLL_LEFT;
+            break;
+        case GDK_SCROLL_LEFT:
+            event->direction = GDK_SCROLL_UP;
+            break;
+        case GDK_SCROLL_DOWN:
+            event->direction = GDK_SCROLL_RIGHT;
+            break;
+        case GDK_SCROLL_RIGHT:
+            event->direction = GDK_SCROLL_DOWN;
+            break;
+        case GDK_SCROLL_SMOOTH:
+            std::swap(event->delta_x, event->delta_y);
+            break;
+        }
+    }
+
     webkitWebViewBaseHandleWheelEvent(webViewBase, reinterpret_cast<GdkEvent*>(event));
 
     return GDK_EVENT_STOP;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to