Changeset 227966 in webkit


Ignore:
Timestamp:
Feb 1, 2018 8:04:09 AM (6 years ago)
Author:
Carlos Garcia Campos
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):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r227965 r227966  
     12018-02-01  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Shift + mouse scroll should scroll horizontally
     4        https://bugs.webkit.org/show_bug.cgi?id=181629
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        We currently turn vertical scroll into horizontal when scrolling over the horizontal scrollbar. When Shift key is
     9        pressed, we still want to scroll in the scrollbar direction when scrolling over a scrollbar, so we need to swap
     10        directions in both scrollbars depending on whther the Shift key is pressed or not.
     11
     12        * page/EventHandler.cpp:
     13        (WebCore::EventHandler::shouldSwapScrollDirection const): Renamed.
     14        (WebCore::EventHandler::handleWheelEvent): Use the new name.
     15        (WebCore::EventHandler::shouldTurnVerticalTicksIntoHorizontal const): Deleted.
     16        * page/EventHandler.h:
     17        * platform/PlatformWheelEvent.h:
     18        (WebCore::PlatformWheelEvent::copySwappingDirection const): Swap the direction of the event.
     19        (WebCore::PlatformWheelEvent::copyTurningVerticalTicksIntoHorizontalTicks const): Deleted.
     20        * platform/glib/EventHandlerGLib.cpp:
     21        (WebCore::EventHandler::shouldSwapScrollDirection const): Take into account whether the Shift key is present.
     22        (WebCore::EventHandler::shouldTurnVerticalTicksIntoHorizontal const): Deleted.
     23
    1242018-02-01  Carlos Garcia Campos  <cgarcia@igalia.com>
    225
  • trunk/Source/WebCore/page/EventHandler.cpp

    r226313 r227966  
    26402640#if !PLATFORM(GTK) && !PLATFORM(WPE)
    26412641
    2642 bool EventHandler::shouldTurnVerticalTicksIntoHorizontal(const HitTestResult&, const PlatformWheelEvent&) const
     2642bool EventHandler::shouldSwapScrollDirection(const HitTestResult&, const PlatformWheelEvent&) const
    26432643{
    26442644    return false;
     
    27842784    // FIXME: It should not be necessary to do this mutation here.
    27852785    // Instead, the handlers should know convert vertical scrolls appropriately.
    2786     PlatformWheelEvent adjustedEvent = event;
    2787     if (shouldTurnVerticalTicksIntoHorizontal(result, event))
    2788         adjustedEvent = event.copyTurningVerticalTicksIntoHorizontalTicks();
    2789 
     2786    PlatformWheelEvent adjustedEvent = shouldSwapScrollDirection(result, event) ? event.copySwappingDirection() : event;
    27902787    platformRecordWheelEvent(adjustedEvent);
    27912788
  • trunk/Source/WebCore/page/EventHandler.h

    r227759 r227966  
    385385    bool logicalScrollOverflow(ScrollLogicalDirection, ScrollGranularity, Node* startingNode = nullptr);
    386386   
    387     bool shouldTurnVerticalTicksIntoHorizontal(const HitTestResult&, const PlatformWheelEvent&) const;
     387    bool shouldSwapScrollDirection(const HitTestResult&, const PlatformWheelEvent&) const;
    388388   
    389389    bool mouseDownMayStartSelect() const { return m_mouseDownMayStartSelect; }
  • trunk/Source/WebCore/platform/PlatformWheelEvent.h

    r222392 r227966  
    8282    }
    8383
    84     PlatformWheelEvent copyTurningVerticalTicksIntoHorizontalTicks() const
     84    PlatformWheelEvent copySwappingDirection() const
    8585    {
    8686        PlatformWheelEvent copy = *this;
    87         copy.m_deltaX = copy.m_deltaY;
    88         copy.m_deltaY = 0;
    89         copy.m_wheelTicksX = copy.m_wheelTicksY;
    90         copy.m_wheelTicksY = 0;
     87        std::swap(copy.m_deltaX, copy.m_deltaY);
     88        std::swap(copy.m_wheelTicksX, copy.m_wheelTicksY);
    9189        return copy;
    9290    }
  • trunk/Source/WebCore/platform/glib/EventHandlerGLib.cpp

    r222595 r227966  
    129129// add the deltas and ticks here so that this behavior is consistent
    130130// for styled scrollbars.
    131 bool EventHandler::shouldTurnVerticalTicksIntoHorizontal(const HitTestResult& result, const PlatformWheelEvent& event) const
     131bool EventHandler::shouldSwapScrollDirection(const HitTestResult& result, const PlatformWheelEvent& event) const
    132132{
    133133#if PLATFORM(GTK)
     
    136136    if (!scrollbar)
    137137        scrollbar = result.scrollbar();
    138     return scrollbar && scrollbar->orientation() == HorizontalScrollbar;
     138    if (!scrollbar)
     139        return false;
     140
     141    // The directions are already swapped when shift key is pressed, but when scrolling
     142    // over scrollbars we always want to follow the scrollbar direction.
     143    return scrollbar->orientation() == HorizontalScrollbar ? !event.shiftKey() : event.shiftKey();
    139144#else
    140145    UNUSED_PARAM(result);
  • trunk/Source/WebKit/ChangeLog

    r227961 r227966  
     12018-02-01  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Shift + mouse scroll should scroll horizontally
     4        https://bugs.webkit.org/show_bug.cgi?id=181629
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Swap scroll direction when Shift is pressed for consistency with GtkScrolledWindow.
     9
     10        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
     11        (webkitWebViewBaseScrollEvent):
     12
    1132018-02-01  Carlos Garcia Campos  <cgarcia@igalia.com>
    214
  • trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp

    r227961 r227966  
    831831        return GDK_EVENT_PROPAGATE;
    832832
     833    // Shift+Wheel scrolls in the perpendicular direction.
     834    if (event->state & GDK_SHIFT_MASK) {
     835        switch (event->direction) {
     836        case GDK_SCROLL_UP:
     837            event->direction = GDK_SCROLL_LEFT;
     838            break;
     839        case GDK_SCROLL_LEFT:
     840            event->direction = GDK_SCROLL_UP;
     841            break;
     842        case GDK_SCROLL_DOWN:
     843            event->direction = GDK_SCROLL_RIGHT;
     844            break;
     845        case GDK_SCROLL_RIGHT:
     846            event->direction = GDK_SCROLL_DOWN;
     847            break;
     848        case GDK_SCROLL_SMOOTH:
     849            std::swap(event->delta_x, event->delta_y);
     850            break;
     851        }
     852    }
     853
    833854    webkitWebViewBaseHandleWheelEvent(webViewBase, reinterpret_cast<GdkEvent*>(event));
    834855
Note: See TracChangeset for help on using the changeset viewer.