Title: [269143] trunk/Source
Revision
269143
Author
cl...@igalia.com
Date
2020-10-29 04:23:45 -0700 (Thu, 29 Oct 2020)

Log Message

[GTK] Smooth scrolling should not apply to continuous scrolling with sync scrolling
https://bugs.webkit.org/show_bug.cgi?id=218133

Reviewed by Adrian Perez de Castro.

Source/WebCore:

Respect PlatformWheelEvent.hasPreciseScrollingDeltas in the base
ScrollAnimator class, and make sure the flag is set correctly for
GdkEvent.

* SourcesGTK.txt:
* platform/PlatformWheelEvent.h:
(WebCore::PlatformWheelEvent::setHasPreciseScrollingDeltas):
* platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::scroll):
(WebCore::ScrollAnimator::scrollWithoutAnimation):
(WebCore::ScrollAnimator::handleWheelEvent):
* platform/ScrollAnimator.h:
* platform/gtk/GtkVersioning.h:
(gdk_event_get_source_device):
* platform/gtk/PlatformWheelEventGtk.cpp: Removed.

Source/WebKit:

Set hasPreciseScrollDeltas appropriately on scroll events created from GdkEvent.

* Shared/gtk/WebEventFactory.cpp:
(WebKit::WebEventFactory::createWebWheelEvent):

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (269142 => 269143)


--- trunk/Source/WebCore/ChangeLog	2020-10-29 09:19:25 UTC (rev 269142)
+++ trunk/Source/WebCore/ChangeLog	2020-10-29 11:23:45 UTC (rev 269143)
@@ -1,3 +1,26 @@
+2020-10-29  Chris Lord  <cl...@igalia.com>
+
+        [GTK] Smooth scrolling should not apply to continuous scrolling with sync scrolling
+        https://bugs.webkit.org/show_bug.cgi?id=218133
+
+        Reviewed by Adrian Perez de Castro.
+
+        Respect PlatformWheelEvent.hasPreciseScrollingDeltas in the base
+        ScrollAnimator class, and make sure the flag is set correctly for
+        GdkEvent.
+
+        * SourcesGTK.txt:
+        * platform/PlatformWheelEvent.h:
+        (WebCore::PlatformWheelEvent::setHasPreciseScrollingDeltas):
+        * platform/ScrollAnimator.cpp:
+        (WebCore::ScrollAnimator::scroll):
+        (WebCore::ScrollAnimator::scrollWithoutAnimation):
+        (WebCore::ScrollAnimator::handleWheelEvent):
+        * platform/ScrollAnimator.h:
+        * platform/gtk/GtkVersioning.h:
+        (gdk_event_get_source_device):
+        * platform/gtk/PlatformWheelEventGtk.cpp: Removed.
+
 2020-10-29  Cathie Chen  <cathiec...@igalia.com>
 
         IntersectionObserverCallback leaks

Modified: trunk/Source/WebCore/SourcesGTK.txt (269142 => 269143)


--- trunk/Source/WebCore/SourcesGTK.txt	2020-10-29 09:19:25 UTC (rev 269142)
+++ trunk/Source/WebCore/SourcesGTK.txt	2020-10-29 11:23:45 UTC (rev 269143)
@@ -112,7 +112,6 @@
 platform/gtk/PasteboardGtk.cpp
 platform/gtk/PlatformKeyboardEventGtk.cpp
 platform/gtk/PlatformScreenGtk.cpp
-platform/gtk/PlatformWheelEventGtk.cpp
 platform/gtk/RenderThemeGadget.cpp
 platform/gtk/RenderThemeScrollbar.cpp
 platform/gtk/ScrollbarThemeGtk.cpp

Modified: trunk/Source/WebCore/platform/PlatformWheelEvent.h (269142 => 269143)


--- trunk/Source/WebCore/platform/PlatformWheelEvent.h	2020-10-29 09:19:25 UTC (rev 269142)
+++ trunk/Source/WebCore/platform/PlatformWheelEvent.h	2020-10-29 11:23:45 UTC (rev 269143)
@@ -30,10 +30,6 @@
 #include "PlatformEvent.h"
 #include <wtf/WindowsExtras.h>
 
-#if PLATFORM(GTK)
-typedef struct _GdkEventScroll GdkEventScroll;
-#endif
-
 namespace WTF {
 class TextStream;
 }
@@ -137,14 +133,8 @@
 
     const FloatSize& scrollingVelocity() const { return m_scrollingVelocity; }
 
-#if PLATFORM(GTK)
-    explicit PlatformWheelEvent(GdkEventScroll*);
-#endif
-
-#if PLATFORM(COCOA) || PLATFORM(GTK) || USE(LIBWPE)
     bool hasPreciseScrollingDeltas() const { return m_hasPreciseScrollingDeltas; }
     void setHasPreciseScrollingDeltas(bool hasPreciseScrollingDeltas) { m_hasPreciseScrollingDeltas = hasPreciseScrollingDeltas; }
-#endif
 
 #if PLATFORM(COCOA)
     unsigned scrollCount() const { return m_scrollCount; }
@@ -196,9 +186,7 @@
     PlatformWheelEventPhase m_phase { PlatformWheelEventPhaseNone };
     PlatformWheelEventPhase m_momentumPhase { PlatformWheelEventPhaseNone };
 #endif
-#if PLATFORM(COCOA) || PLATFORM(GTK) || USE(LIBWPE)
     bool m_hasPreciseScrollingDeltas { false };
-#endif
 #if PLATFORM(COCOA)
     unsigned m_scrollCount { 0 };
     float m_unacceleratedScrollingDeltaX { 0 };

Modified: trunk/Source/WebCore/platform/ScrollAnimator.cpp (269142 => 269143)


--- trunk/Source/WebCore/platform/ScrollAnimator.cpp	2020-10-29 09:19:25 UTC (rev 269142)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp	2020-10-29 11:23:45 UTC (rev 269143)
@@ -80,8 +80,13 @@
 #endif
 }
 
-bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity, float step, float multiplier)
+bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier)
 {
+    return scrollWithoutAnimation(orientation, granularity, step, multiplier);
+}
+
+bool ScrollAnimator::scrollWithoutAnimation(ScrollbarOrientation orientation, ScrollGranularity, float step, float multiplier)
+{
     FloatPoint currentPosition = this->currentPosition();
     FloatSize delta;
     if (orientation == HorizontalScrollbar)
@@ -176,7 +181,10 @@
                 if (negative)
                     deltaY = -deltaY;
             }
-            scroll(VerticalScrollbar, granularity, verticalScrollbar->pixelStep(), -deltaY);
+            if (e.hasPreciseScrollingDeltas())
+                scrollWithoutAnimation(VerticalScrollbar, granularity, verticalScrollbar->pixelStep(), -deltaY);
+            else
+                scroll(VerticalScrollbar, granularity, verticalScrollbar->pixelStep(), -deltaY);
         }
 
         if (deltaX) {
@@ -186,7 +194,10 @@
                 if (negative)
                     deltaX = -deltaX;
             }
-            scroll(HorizontalScrollbar, granularity, horizontalScrollbar->pixelStep(), -deltaX);
+            if (e.hasPreciseScrollingDeltas())
+                scrollWithoutAnimation(HorizontalScrollbar, granularity, horizontalScrollbar->pixelStep(), -deltaX);
+            else
+                scroll(HorizontalScrollbar, granularity, horizontalScrollbar->pixelStep(), -deltaX);
         }
     }
     return handled;

Modified: trunk/Source/WebCore/platform/ScrollAnimator.h (269142 => 269143)


--- trunk/Source/WebCore/platform/ScrollAnimator.h	2020-10-29 09:19:25 UTC (rev 269142)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h	2020-10-29 11:23:45 UTC (rev 269143)
@@ -72,6 +72,7 @@
     // destination and returns true.  Scrolling may be immediate or animated.
     // The base class implementation always scrolls immediately, never animates.
     virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier);
+    bool scrollWithoutAnimation(ScrollbarOrientation, ScrollGranularity, float step, float multiplier);
 
     void scrollToOffset(const FloatPoint&);
     virtual void scrollToOffsetWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped);

Modified: trunk/Source/WebCore/platform/gtk/GtkVersioning.h (269142 => 269143)


--- trunk/Source/WebCore/platform/gtk/GtkVersioning.h	2020-10-29 09:19:25 UTC (rev 269142)
+++ trunk/Source/WebCore/platform/gtk/GtkVersioning.h	2020-10-29 11:23:45 UTC (rev 269143)
@@ -80,6 +80,12 @@
     return gdk_event_ref(event);
 }
 
+static inline GdkDevice*
+gdk_event_get_source_device(const GdkEvent* event)
+{
+    return gdk_event_get_device(event);
+}
+
 static inline void
 gtk_widget_size_allocate(GtkWidget* widget, GtkAllocation* allocation)
 {

Deleted: trunk/Source/WebCore/platform/gtk/PlatformWheelEventGtk.cpp (269142 => 269143)


--- trunk/Source/WebCore/platform/gtk/PlatformWheelEventGtk.cpp	2020-10-29 09:19:25 UTC (rev 269142)
+++ trunk/Source/WebCore/platform/gtk/PlatformWheelEventGtk.cpp	2020-10-29 11:23:45 UTC (rev 269143)
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Inc.  All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.em...@gmail.com
- * 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. ``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
- * 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 "PlatformWheelEvent.h"
-
-#include "FloatPoint.h"
-#include "GtkUtilities.h"
-#include "GtkVersioning.h"
-#include "PlatformKeyboardEvent.h"
-#include "Scrollbar.h"
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-#include <wtf/WallTime.h>
-
-namespace WebCore {
-
-// Keep this in sync with the other platform event constructors
-PlatformWheelEvent::PlatformWheelEvent(GdkEventScroll* event)
-{
-    static const float delta = 1;
-    GdkModifierType state;
-
-    m_type = PlatformEvent::Wheel;
-    m_timestamp = wallTimeForEvent(event);
-
-    gdk_event_get_state(reinterpret_cast<GdkEvent*>(event), &state);
-
-    if (state & GDK_SHIFT_MASK)
-        m_modifiers.add(Modifier::ShiftKey);
-    if (state & GDK_CONTROL_MASK)
-        m_modifiers.add(Modifier::ControlKey);
-    if (state & GDK_MOD1_MASK)
-        m_modifiers.add(Modifier::AltKey);
-    if (state & GDK_META_MASK)
-        m_modifiers.add(Modifier::MetaKey);
-    if (PlatformKeyboardEvent::modifiersContainCapsLock(state))
-        m_modifiers.add(PlatformEvent::Modifier::CapsLockKey);
-
-    m_deltaX = 0;
-    m_deltaY = 0;
-    GdkScrollDirection direction;
-
-    if (!gdk_event_get_scroll_direction(reinterpret_cast<GdkEvent*>(event), &direction)) {
-        direction = GDK_SCROLL_SMOOTH;
-        gdouble deltaX, deltaY;
-        if (gdk_event_get_scroll_deltas(reinterpret_cast<GdkEvent*>(event), &deltaX, &deltaY)) {
-            m_deltaX = -deltaX;
-            m_deltaY = -deltaY;
-        }
-    }
-
-    // Docs say an upwards scroll (away from the user) has a positive delta
-    if (!m_deltaX && !m_deltaY) {
-        switch (direction) {
-        case GDK_SCROLL_UP:
-            m_deltaY = delta;
-            break;
-        case GDK_SCROLL_DOWN:
-            m_deltaY = -delta;
-            break;
-        case GDK_SCROLL_LEFT:
-            m_deltaX = delta;
-            break;
-        case GDK_SCROLL_RIGHT:
-            m_deltaX = -delta;
-            break;
-        case GDK_SCROLL_SMOOTH:
-            break;
-        default:
-            ASSERT_NOT_REACHED();
-        }
-    }
-    m_wheelTicksX = m_deltaX;
-    m_wheelTicksY = m_deltaY;
-
-#if ENABLE(KINETIC_SCROLLING)
-    const auto isStopEvent = gdk_event_is_scroll_stop_event(reinterpret_cast<GdkEvent*>(event));
-    m_phase = isStopEvent ?  PlatformWheelEventPhaseEnded : PlatformWheelEventPhaseChanged;
-#endif // ENABLE(KINETIC_SCROLLING)
-
-    gdouble x, y, rootX, rootY;
-    gdk_event_get_coords(reinterpret_cast<GdkEvent*>(event), &x, &y);
-    gdk_event_get_root_coords(reinterpret_cast<GdkEvent*>(event), &rootX, &rootY);
-
-    m_position = IntPoint(static_cast<int>(x), static_cast<int>(y));
-    m_globalPosition = IntPoint(static_cast<int>(rootX), static_cast<int>(rootY));
-    m_granularity = ScrollByPixelWheelEvent;
-    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());
-    m_deltaY *= static_cast<float>(Scrollbar::pixelsPerLineStep());
-}
-
-} // namespace WebCore

Modified: trunk/Source/WebKit/ChangeLog (269142 => 269143)


--- trunk/Source/WebKit/ChangeLog	2020-10-29 09:19:25 UTC (rev 269142)
+++ trunk/Source/WebKit/ChangeLog	2020-10-29 11:23:45 UTC (rev 269143)
@@ -1,3 +1,15 @@
+2020-10-29  Chris Lord  <cl...@igalia.com>
+
+        [GTK] Smooth scrolling should not apply to continuous scrolling with sync scrolling
+        https://bugs.webkit.org/show_bug.cgi?id=218133
+
+        Reviewed by Adrian Perez de Castro.
+
+        Set hasPreciseScrollDeltas appropriately on scroll events created from GdkEvent.
+
+        * Shared/gtk/WebEventFactory.cpp:
+        (WebKit::WebEventFactory::createWebWheelEvent):
+
 2020-10-28  John Wilander  <wilan...@apple.com>
 
         PCM: Accept ad click data when the link opens a new window

Modified: trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp (269142 => 269143)


--- trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp	2020-10-29 09:19:25 UTC (rev 269142)
+++ trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp	2020-10-29 11:23:45 UTC (rev 269143)
@@ -280,6 +280,16 @@
     float step = static_cast<float>(Scrollbar::pixelsPerLineStep());
     FloatSize delta(wheelTicks.width() * step, wheelTicks.height() * step);
 
+    bool hasPreciseScrollingDeltas = false;
+    GdkScrollDirection direction;
+    if (!gdk_event_get_scroll_direction(event, &direction)) {
+        double deltaX, deltaY;
+        if (gdk_event_get_scroll_deltas(event, &deltaX, &deltaY)) {
+            if (auto* device = gdk_event_get_source_device(event))
+                hasPreciseScrollingDeltas = gdk_device_get_source(device) != GDK_SOURCE_MOUSE;
+        }
+    }
+
     return WebWheelEvent(WebEvent::Wheel,
         position,
         globalPosition,
@@ -288,7 +298,7 @@
         phase,
         momentumPhase,
         WebWheelEvent::ScrollByPixelWheelEvent,
-        false,
+        hasPreciseScrollingDeltas,
         modifiersForEvent(event),
         wallTimeForEvent(event));
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to