Changeset 265138 in webkit


Ignore:
Timestamp:
Jul 31, 2020 3:57:19 AM (4 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Mouse wheel events on horizontal scrollbar not correctly handled when AC mode is forced
https://bugs.webkit.org/show_bug.cgi?id=207113

Reviewed by Adrian Perez de Castro.

Source/WebCore:

Remove GTK specific code to invert scroll direction of wheel events.

  • page/EventHandler.cpp:

(WebCore::EventHandler::handleWheelEvent):
(WebCore::EventHandler::shouldSwapScrollDirection const): Deleted.

  • platform/SourcesGLib.txt:
  • platform/glib/EventHandlerGLib.cpp: Removed.

Source/WebKit:

Move the direction swap to the UI process before passing the event to the web
process. WebHitTestResultData::isScrollbar is now an enum with values No, Verttical, Horizontal. When a wheel
event is received in the widget we check whether we should invert the direction or not.

  • Shared/API/glib/WebKitHitTestResult.cpp:

(webkitHitTestResultCreate):
(webkitHitTestResultCompare):

  • Shared/WebHitTestResultData.cpp:

(WebKit::WebHitTestResultData::WebHitTestResultData):

  • Shared/WebHitTestResultData.h:
  • UIProcess/API/APIHitTestResult.h:

(API::HitTestResult::isScrollbar const):

  • UIProcess/API/glib/WebKitWebView.cpp:

(webkitWebViewMouseTargetChanged):

  • UIProcess/API/gtk/WebKitWebViewBase.cpp:

(shouldInvertDirectionForScrollEvent):
(webkitWebViewBaseScrollEvent):
(webkitWebViewBaseScroll):
(webkitWebViewBaseSetMouseIsOverScrollbar):

  • UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
Location:
trunk/Source
Files:
1 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r265137 r265138  
     12020-07-31  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Mouse wheel events on horizontal scrollbar not correctly handled when AC mode is forced
     4        https://bugs.webkit.org/show_bug.cgi?id=207113
     5
     6        Reviewed by Adrian Perez de Castro.
     7
     8        Remove GTK specific code to invert scroll direction of wheel events.
     9
     10        * page/EventHandler.cpp:
     11        (WebCore::EventHandler::handleWheelEvent):
     12        (WebCore::EventHandler::shouldSwapScrollDirection const): Deleted.
     13        * platform/SourcesGLib.txt:
     14        * platform/glib/EventHandlerGLib.cpp: Removed.
     15
    1162020-07-10  Sergio Villar Senin  <svillar@igalia.com>
    217
  • trunk/Source/WebCore/page/EventHandler.cpp

    r265092 r265138  
    27792779}
    27802780
    2781 #if !USE(GLIB)
    2782 
    2783 bool EventHandler::shouldSwapScrollDirection(const HitTestResult&, const PlatformWheelEvent&) const
    2784 {
    2785     return false;
    2786 }
    2787 
    2788 #endif
    2789 
    27902781void EventHandler::clearLatchedStateTimerFired()
    27912782{
     
    29382929#endif
    29392930
    2940     // FIXME: It should not be necessary to do this mutation here.
    2941     // Instead, the handlers should know convert vertical scrolls appropriately.
    2942     PlatformWheelEvent adjustedEvent = shouldSwapScrollDirection(result, event) ? event.copySwappingDirection() : event;
    2943     recordWheelEventForDeltaFilter(adjustedEvent);
     2931    recordWheelEventForDeltaFilter(event);
    29442932
    29452933    if (element) {
     
    29472935            if (WeakPtr<Widget> widget = widgetForElement(*element)) {
    29482936                if (passWheelEventToWidget(event, *widget.get()))
    2949                     return completeWidgetWheelEvent(adjustedEvent, widget, scrollableArea, scrollableContainer.get());
     2937                    return completeWidgetWheelEvent(event, widget, scrollableArea, scrollableContainer.get());
    29502938            }
    29512939        }
    29522940
    2953         if (!element->dispatchWheelEvent(adjustedEvent)) {
     2941        if (!element->dispatchWheelEvent(event)) {
    29542942            m_isHandlingWheelEvent = false;
    29552943            if (scrollableArea && scrollableArea->scrollShouldClearLatchedState()) {
     
    29592947            }
    29602948
    2961             processWheelEventForScrollSnap(adjustedEvent, scrollableArea);
     2949            processWheelEventForScrollSnap(event, scrollableArea);
    29622950            return true;
    29632951        }
     
    29672955        scrollableArea->setScrollShouldClearLatchedState(false);
    29682956
    2969     bool handledEvent = processWheelEventForScrolling(adjustedEvent, scrollableContainer.get(), scrollableArea);
    2970     processWheelEventForScrollSnap(adjustedEvent, scrollableArea);
     2957    bool handledEvent = processWheelEventForScrolling(event, scrollableContainer.get(), scrollableArea);
     2958    processWheelEventForScrollSnap(event, scrollableArea);
    29712959    return handledEvent;
    29722960}
  • trunk/Source/WebCore/platform/SourcesGLib.txt

    r251036 r265138  
    2424platform/audio/glib/AudioBusGLib.cpp
    2525
    26 platform/glib/EventHandlerGLib.cpp
    2726platform/glib/FileMonitorGLib.cpp
    2827platform/glib/KeyedDecoderGlib.cpp
  • trunk/Source/WebKit/ChangeLog

    r265134 r265138  
     12020-07-31  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Mouse wheel events on horizontal scrollbar not correctly handled when AC mode is forced
     4        https://bugs.webkit.org/show_bug.cgi?id=207113
     5
     6        Reviewed by Adrian Perez de Castro.
     7
     8        Move the direction swap to the UI process before passing the event to the web
     9        process. WebHitTestResultData::isScrollbar is now an enum with values No, Verttical, Horizontal. When a wheel
     10        event is received in the widget we check whether we should invert the direction or not.
     11
     12        * Shared/API/glib/WebKitHitTestResult.cpp:
     13        (webkitHitTestResultCreate):
     14        (webkitHitTestResultCompare):
     15        * Shared/WebHitTestResultData.cpp:
     16        (WebKit::WebHitTestResultData::WebHitTestResultData):
     17        * Shared/WebHitTestResultData.h:
     18        * UIProcess/API/APIHitTestResult.h:
     19        (API::HitTestResult::isScrollbar const):
     20        * UIProcess/API/glib/WebKitWebView.cpp:
     21        (webkitWebViewMouseTargetChanged):
     22        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
     23        (shouldInvertDirectionForScrollEvent):
     24        (webkitWebViewBaseScrollEvent):
     25        (webkitWebViewBaseScroll):
     26        (webkitWebViewBaseSetMouseIsOverScrollbar):
     27        * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
     28
    1292020-07-30  Alex Christensen  <achristensen@webkit.org>
    230
  • trunk/Source/WebKit/Shared/API/glib/WebKitHitTestResult.cpp

    r218487 r265138  
    239239        context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE;
    240240
    241     if (hitTestResult.isScrollbar)
     241    if (hitTestResult.isScrollbar != WebHitTestResultData::IsScrollbar::No)
    242242        context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR;
    243243
     
    263263{
    264264    WebKitHitTestResultPrivate* priv = hitTestResult->priv;
     265    bool isScrollbar = webHitTestResult.isScrollbar != WebHitTestResultData::IsScrollbar::No;
    265266    return webHitTestResult.isContentEditable == webkit_hit_test_result_context_is_editable(hitTestResult)
    266         && webHitTestResult.isScrollbar == webkit_hit_test_result_context_is_scrollbar(hitTestResult)
     267        && isScrollbar == webkit_hit_test_result_context_is_scrollbar(hitTestResult)
    267268        && webHitTestResult.isSelected == webkit_hit_test_result_context_is_selection(hitTestResult)
    268269        && stringIsEqualToCString(webHitTestResult.absoluteLinkURL, priv->linkURI)
  • trunk/Source/WebKit/Shared/WebHitTestResultData.cpp

    r259913 r265138  
    4949    , isContentEditable(hitTestResult.isContentEditable())
    5050    , elementBoundingBox(elementBoundingBoxInWindowCoordinates(hitTestResult))
    51     , isScrollbar(hitTestResult.scrollbar())
     51    , isScrollbar(IsScrollbar::No)
    5252    , isSelected(hitTestResult.isSelected())
    5353    , isTextNode(hitTestResult.innerNode() && hitTestResult.innerNode()->isTextNode())
     
    5757    , imageSize(0)
    5858{
     59    if (auto* scrollbar = hitTestResult.scrollbar())
     60        isScrollbar = scrollbar->orientation() == HorizontalScrollbar ? IsScrollbar::Horizontal : IsScrollbar::Vertical;
    5961}
    6062
     
    6971    , isContentEditable(hitTestResult.isContentEditable())
    7072    , elementBoundingBox(elementBoundingBoxInWindowCoordinates(hitTestResult))
    71     , isScrollbar(hitTestResult.scrollbar())
     73    , isScrollbar(IsScrollbar::No)
    7274    , isSelected(hitTestResult.isSelected())
    7375    , isTextNode(hitTestResult.innerNode() && hitTestResult.innerNode()->isTextNode())
     
    7678    , imageSize(0)
    7779{
     80    if (auto* scrollbar = hitTestResult.scrollbar())
     81        isScrollbar = scrollbar->orientation() == HorizontalScrollbar ? IsScrollbar::Horizontal : IsScrollbar::Vertical;
     82
    7883    if (!includeImage)
    7984        return;
  • trunk/Source/WebKit/Shared/WebHitTestResultData.h

    r260025 r265138  
    1818 */
    1919
    20 #ifndef WebHitTestResultData_h
    21 #define WebHitTestResultData_h
     20#pragma once
    2221
    2322#include "APIObject.h"
     
    2726#include <WebCore/IntRect.h>
    2827#include <WebCore/PageOverlay.h>
     28#include <wtf/EnumTraits.h>
    2929#include <wtf/Forward.h>
    3030#include <wtf/RefPtr.h>
     
    5454    bool isContentEditable;
    5555    WebCore::IntRect elementBoundingBox;
    56     bool isScrollbar;
     56    enum class IsScrollbar { No, Vertical, Horizontal };
     57    IsScrollbar isScrollbar;
    5758    bool isSelected;
    5859    bool isTextNode;
     
    9192} // namespace WebKit
    9293
    93 #endif // WebHitTestResultData_h
     94namespace WTF {
     95
     96template<> struct EnumTraits<WebKit::WebHitTestResultData::IsScrollbar> {
     97    using values = EnumValues<
     98    WebKit::WebHitTestResultData::IsScrollbar,
     99    WebKit::WebHitTestResultData::IsScrollbar::No,
     100    WebKit::WebHitTestResultData::IsScrollbar::Vertical,
     101    WebKit::WebHitTestResultData::IsScrollbar::Horizontal
     102    >;
     103};
     104
     105} // namespace WTF
  • trunk/Source/WebKit/UIProcess/API/APIHitTestResult.h

    r224179 r265138  
    6363    WebCore::IntRect elementBoundingBox() const { return m_data.elementBoundingBox; }
    6464
    65     bool isScrollbar() const { return m_data.isScrollbar; }
     65    bool isScrollbar() const { return m_data.isScrollbar != WebKit::WebHitTestResultData::IsScrollbar::No; }
    6666
    6767    bool isSelected() const { return m_data.isSelected; }
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp

    r263444 r265138  
    25662566#if PLATFORM(GTK)
    25672567    webkitWebViewBaseSetTooltipArea(WEBKIT_WEB_VIEW_BASE(webView), hitTestResult.elementBoundingBox);
     2568    webkitWebViewBaseSetMouseIsOverScrollbar(WEBKIT_WEB_VIEW_BASE(webView), hitTestResult.isScrollbar);
    25682569#endif
    25692570
  • trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp

    r264647 r265138  
    269269    CString tooltipText;
    270270    IntRect tooltipArea;
     271    WebHitTestResultData::IsScrollbar mouseIsOverScrollbar;
    271272    GRefPtr<AtkObject> accessible;
    272273    GtkWidget* dialog { nullptr };
     
    12081209#endif
    12091210
     1211static bool shouldInvertDirectionForScrollEvent(WebHitTestResultData::IsScrollbar isScrollbar, bool isShiftPressed)
     1212{
     1213    // Shift+Wheel scrolls in the perpendicular direction, unless we are over a scrollbar
     1214    // in which case we always want to follow the scrollbar direction.
     1215    switch (isScrollbar) {
     1216    case WebHitTestResultData::IsScrollbar::No:
     1217        return isShiftPressed;
     1218    case WebHitTestResultData::IsScrollbar::Horizontal:
     1219        return true;
     1220    case WebHitTestResultData::IsScrollbar::Vertical:
     1221        return false;
     1222    }
     1223    RELEASE_ASSERT_NOT_REACHED();
     1224}
     1225
    12101226#if !USE(GTK4)
    12111227static void webkitWebViewBaseHandleWheelEvent(WebKitWebViewBase* webViewBase, GdkEvent* event, Optional<WebWheelEvent::Phase> phase = WTF::nullopt, Optional<WebWheelEvent::Phase> momentum = WTF::nullopt)
     
    12341250        return GDK_EVENT_PROPAGATE;
    12351251
    1236     // Shift+Wheel scrolls in the perpendicular direction.
    1237     if (event->state & GDK_SHIFT_MASK) {
     1252    if (shouldInvertDirectionForScrollEvent(priv->mouseIsOverScrollbar, event->state & GDK_SHIFT_MASK)) {
    12381253        switch (event->direction) {
    12391254        case GDK_SCROLL_UP:
     
    12701285    auto* event = gtk_event_controller_get_current_event(controller);
    12711286
    1272     // Shift+Wheel scrolls in the perpendicular direction.
    1273     if (gdk_event_get_modifier_state(event) & GDK_SHIFT_MASK)
     1287    if (shouldInvertDirectionForScrollEvent(priv->mouseIsOverScrollbar, gdk_event_get_modifier_state(event) & GDK_SHIFT_MASK))
    12741288        std::swap(deltaX, deltaY);
    12751289
     
    20672081}
    20682082
     2083void webkitWebViewBaseSetMouseIsOverScrollbar(WebKitWebViewBase* webViewBase, WebHitTestResultData::IsScrollbar isScrollbar)
     2084{
     2085    webViewBase->priv->mouseIsOverScrollbar = isScrollbar;
     2086}
     2087
    20692088#if ENABLE(DRAG_SUPPORT)
    20702089void webkitWebViewBaseStartDrag(WebKitWebViewBase* webViewBase, SelectionData&& selectionData, OptionSet<DragOperation> dragOperationMask, RefPtr<ShareableBitmap>&& image)
  • trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h

    r263825 r265138  
    3636#include "ViewSnapshotStore.h"
    3737#include "WebContextMenuProxyGtk.h"
     38#include "WebHitTestResultData.h"
    3839#include "WebInspectorProxy.h"
    3940#include "WebKitInputMethodContext.h"
     
    4950void webkitWebViewBaseSetTooltipText(WebKitWebViewBase*, const char*);
    5051void webkitWebViewBaseSetTooltipArea(WebKitWebViewBase*, const WebCore::IntRect&);
     52void webkitWebViewBaseSetMouseIsOverScrollbar(WebKitWebViewBase*, WebKit::WebHitTestResultData::IsScrollbar);
    5153void webkitWebViewBaseForwardNextKeyEvent(WebKitWebViewBase*);
    5254void webkitWebViewBaseForwardNextWheelEvent(WebKitWebViewBase*);
Note: See TracChangeset for help on using the changeset viewer.