- Revision
- 263887
- Author
- [email protected]
- Date
- 2020-07-03 01:37:56 -0700 (Fri, 03 Jul 2020)
Log Message
[GTK4] Support kinetic scrolling
https://bugs.webkit.org/show_bug.cgi?id=213791
Patch by Alexander Mikhaylenko <[email protected]> on 2020-07-03
Reviewed by Carlos Garcia Campos.
GtkEventControllerScroll skips the last event and exposes it in a separate signal.
Normally one would add the KINETIC flag and listen to decelerate signal, but since
WebKit already has code for calculating the velocity for GTK3, just use the same
code path as scroll signal handler.
* Shared/gtk/NativeWebWheelEventGtk.cpp:
(WebKit::NativeWebWheelEvent::NativeWebWheelEvent):
* Shared/gtk/WebEventFactory.cpp:
(WebKit::WebEventFactory::createWebWheelEvent):
* Shared/gtk/WebEventFactory.h:
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseScrollEnd):
(webkitWebViewBaseConstructed):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (263886 => 263887)
--- trunk/Source/WebKit/ChangeLog 2020-07-03 07:42:38 UTC (rev 263886)
+++ trunk/Source/WebKit/ChangeLog 2020-07-03 08:37:56 UTC (rev 263887)
@@ -1,3 +1,24 @@
+2020-07-03 Alexander Mikhaylenko <[email protected]>
+
+ [GTK4] Support kinetic scrolling
+ https://bugs.webkit.org/show_bug.cgi?id=213791
+
+ Reviewed by Carlos Garcia Campos.
+
+ GtkEventControllerScroll skips the last event and exposes it in a separate signal.
+ Normally one would add the KINETIC flag and listen to decelerate signal, but since
+ WebKit already has code for calculating the velocity for GTK3, just use the same
+ code path as scroll signal handler.
+
+ * Shared/gtk/NativeWebWheelEventGtk.cpp:
+ (WebKit::NativeWebWheelEvent::NativeWebWheelEvent):
+ * Shared/gtk/WebEventFactory.cpp:
+ (WebKit::WebEventFactory::createWebWheelEvent):
+ * Shared/gtk/WebEventFactory.h:
+ * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+ (webkitWebViewBaseScrollEnd):
+ (webkitWebViewBaseConstructed):
+
2020-07-02 Alex Christensen <[email protected]>
Make _WKWebsiteDataStoreConfiguration SPI for HSTS storage to replace _WKProcessPoolConfiguration.hstsStorageDirectory
Modified: trunk/Source/WebKit/Shared/gtk/NativeWebWheelEventGtk.cpp (263886 => 263887)
--- trunk/Source/WebKit/Shared/gtk/NativeWebWheelEventGtk.cpp 2020-07-03 07:42:38 UTC (rev 263886)
+++ trunk/Source/WebKit/Shared/gtk/NativeWebWheelEventGtk.cpp 2020-07-03 08:37:56 UTC (rev 263887)
@@ -44,7 +44,7 @@
}
NativeWebWheelEvent::NativeWebWheelEvent(GdkEvent* event, const WebCore::IntPoint& position, const WebCore::FloatSize& wheelTicks)
- : WebWheelEvent(WebEventFactory::createWebWheelEvent(event, position, position, wheelTicks, WebWheelEvent::Phase::PhaseChanged, WebWheelEvent::Phase::PhaseNone))
+ : WebWheelEvent(WebEventFactory::createWebWheelEvent(event, position, position, wheelTicks))
, m_nativeEvent(gdk_event_copy(event))
{
}
Modified: trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp (263886 => 263887)
--- trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp 2020-07-03 07:42:38 UTC (rev 263886)
+++ trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp 2020-07-03 08:37:56 UTC (rev 263887)
@@ -265,6 +265,14 @@
return createWebWheelEvent(event, position, globalPosition, wheelTicks.value(), phase, momentumPhase);
}
+WebWheelEvent WebEventFactory::createWebWheelEvent(const GdkEvent* event, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& wheelTicks)
+{
+ WebWheelEvent::Phase phase = gdk_event_is_scroll_stop_event(event) ?
+ WebWheelEvent::Phase::PhaseEnded :
+ WebWheelEvent::Phase::PhaseChanged;
+ return createWebWheelEvent(event, position, globalPosition, wheelTicks, phase, WebWheelEvent::Phase::PhaseNone);
+}
+
WebWheelEvent WebEventFactory::createWebWheelEvent(const GdkEvent* event, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& wheelTicks, WebWheelEvent::Phase phase, WebWheelEvent::Phase momentumPhase)
{
// FIXME: [GTK] Add a setting to change the pixels per line used for scrolling
Modified: trunk/Source/WebKit/Shared/gtk/WebEventFactory.h (263886 => 263887)
--- trunk/Source/WebKit/Shared/gtk/WebEventFactory.h 2020-07-03 07:42:38 UTC (rev 263886)
+++ trunk/Source/WebKit/Shared/gtk/WebEventFactory.h 2020-07-03 08:37:56 UTC (rev 263887)
@@ -43,6 +43,7 @@
static WebMouseEvent createWebMouseEvent(const WebCore::IntPoint&);
static WebWheelEvent createWebWheelEvent(const GdkEvent*);
static WebWheelEvent createWebWheelEvent(const GdkEvent*, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase);
+ static WebWheelEvent createWebWheelEvent(const GdkEvent*, const WebCore::IntPoint&, const WebCore::IntPoint&, const WebCore::FloatSize&);
static WebWheelEvent createWebWheelEvent(const GdkEvent*, const WebCore::IntPoint&, const WebCore::IntPoint&, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase);
static WebWheelEvent createWebWheelEvent(const GdkEvent*, const WebCore::IntPoint&, const WebCore::IntPoint&, const WebCore::FloatSize& wheelTicks, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase);
static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const String&, bool handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<EditingRange>&&, Vector<String>&& commands);
Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp (263886 => 263887)
--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp 2020-07-03 07:42:38 UTC (rev 263886)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp 2020-07-03 08:37:56 UTC (rev 263887)
@@ -1277,6 +1277,11 @@
return GDK_EVENT_STOP;
}
+
+static void webkitWebViewBaseScrollEnd(WebKitWebViewBase* webViewBase, GtkEventController* controller)
+{
+ webkitWebViewBaseScroll(webViewBase, 0, 0, controller);
+}
#endif
#if !USE(GTK4)
@@ -1916,6 +1921,7 @@
#if USE(GTK4)
auto* controller = gtk_event_controller_scroll_new(GTK_EVENT_CONTROLLER_SCROLL_BOTH_AXES);
g_signal_connect_object(controller, "scroll", G_CALLBACK(webkitWebViewBaseScroll), viewWidget, G_CONNECT_SWAPPED);
+ g_signal_connect_object(controller, "scroll-end", G_CALLBACK(webkitWebViewBaseScrollEnd), viewWidget, G_CONNECT_SWAPPED);
gtk_widget_add_controller(viewWidget, controller);
controller = gtk_event_controller_motion_new();