- Revision
- 279736
- Author
- commit-qu...@webkit.org
- Date
- 2021-07-08 11:14:23 -0700 (Thu, 08 Jul 2021)
Log Message
[GTK] Too easy to trigger navigation swipe on touchscreen
https://bugs.webkit.org/show_bug.cgi?id=226745
Patch by Alexander Mikhaylenko <al...@gnome.org> on 2021-07-08
Reviewed by Michael Catanzaro.
ViewGestureController uses both x and y deltas to figure out whether to proceed
with a swipe, in the cross-platform part of the code. However, that was optimized
out during the touch handling rewrite, bring it back.
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::wheelEventWasNotHandledByWebCore):
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseHandleWheelEvent):
(webkitWebViewBaseScroll):
(webkitWebViewBaseTouchDragUpdate):
(webkitWebViewBaseTouchDragEnd):
* UIProcess/ViewGestureController.h:
* UIProcess/gtk/ViewGestureControllerGtk.cpp:
(WebKit::ViewGestureController::PendingSwipeTracker::scrollEventGetScrollingDeltas):
(WebKit::ViewGestureController::SwipeProgressTracker::handleEvent):
(WebKit::ViewGestureController::beginSimulatedSwipeInDirectionForTesting):
(WebKit::ViewGestureController::completeSimulatedSwipeInDirectionForTesting):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (279735 => 279736)
--- trunk/Source/WebKit/ChangeLog 2021-07-08 18:07:12 UTC (rev 279735)
+++ trunk/Source/WebKit/ChangeLog 2021-07-08 18:14:23 UTC (rev 279736)
@@ -1,3 +1,28 @@
+2021-07-08 Alexander Mikhaylenko <al...@gnome.org>
+
+ [GTK] Too easy to trigger navigation swipe on touchscreen
+ https://bugs.webkit.org/show_bug.cgi?id=226745
+
+ Reviewed by Michael Catanzaro.
+
+ ViewGestureController uses both x and y deltas to figure out whether to proceed
+ with a swipe, in the cross-platform part of the code. However, that was optimized
+ out during the touch handling rewrite, bring it back.
+
+ * UIProcess/API/gtk/PageClientImpl.cpp:
+ (WebKit::PageClientImpl::wheelEventWasNotHandledByWebCore):
+ * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+ (webkitWebViewBaseHandleWheelEvent):
+ (webkitWebViewBaseScroll):
+ (webkitWebViewBaseTouchDragUpdate):
+ (webkitWebViewBaseTouchDragEnd):
+ * UIProcess/ViewGestureController.h:
+ * UIProcess/gtk/ViewGestureControllerGtk.cpp:
+ (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventGetScrollingDeltas):
+ (WebKit::ViewGestureController::SwipeProgressTracker::handleEvent):
+ (WebKit::ViewGestureController::beginSimulatedSwipeInDirectionForTesting):
+ (WebKit::ViewGestureController::completeSimulatedSwipeInDirectionForTesting):
+
2021-07-08 Garrett Davidson <garrett_david...@apple.com>
_WKWebAuthenticationPanel is returning the wrong operation type in clientDataJSON
Modified: trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp (279735 => 279736)
--- trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp 2021-07-08 18:07:12 UTC (rev 279735)
+++ trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp 2021-07-08 18:14:23 UTC (rev 279736)
@@ -424,9 +424,9 @@
ViewGestureController* controller = webkitWebViewBaseViewGestureController(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
if (controller && controller->isSwipeGestureEnabled()) {
- // While we don't use deltaY, none of the params can be null in GTK4 so we have to pass something.
double deltaX, deltaY;
gdk_event_get_scroll_deltas(event.nativeEvent(), &deltaX, &deltaY);
+ FloatSize delta(deltaX, deltaY);
int32_t eventTime = static_cast<int32_t>(gdk_event_get_time(event.nativeEvent()));
@@ -435,7 +435,7 @@
bool isEnd = gdk_event_is_scroll_stop_event(event.nativeEvent()) ? true : false;
- PlatformGtkScrollData scrollData = { .delta = deltaX, .eventTime = eventTime, .source = source, .isEnd = isEnd };
+ PlatformGtkScrollData scrollData = { .delta = delta, .eventTime = eventTime, .source = source, .isEnd = isEnd };
controller->wheelEventWasNotHandledByWebCore(&scrollData);
return;
}
Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp (279735 => 279736)
--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp 2021-07-08 18:07:12 UTC (rev 279735)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp 2021-07-08 18:14:23 UTC (rev 279736)
@@ -1264,8 +1264,9 @@
{
ViewGestureController* controller = webkitWebViewBaseViewGestureController(webViewBase);
if (controller && controller->isSwipeGestureEnabled()) {
- double deltaX;
- gdk_event_get_scroll_deltas(event, &deltaX, nullptr);
+ double deltaX, deltaY;
+ gdk_event_get_scroll_deltas(event, &deltaX, &deltaY);
+ FloatSize delta(deltaX, deltaY);
int32_t eventTime = static_cast<int32_t>(gdk_event_get_time(event));
@@ -1274,7 +1275,7 @@
bool isEnd = gdk_event_is_scroll_stop_event(event) ? true : false;
- PlatformGtkScrollData scrollData = { .delta = deltaX, .eventTime = eventTime, .source = source, .isEnd = isEnd };
+ PlatformGtkScrollData scrollData = { .delta = delta, .eventTime = eventTime, .source = source, .isEnd = isEnd };
if (controller->handleScrollWheelEvent(&scrollData))
return;
}
@@ -1335,6 +1336,8 @@
ViewGestureController* controller = webkitWebViewBaseViewGestureController(webViewBase);
if (controller && controller->isSwipeGestureEnabled()) {
+ FloatSize delta(deltaX, deltaY);
+
int32_t eventTime = static_cast<int32_t>(gtk_event_controller_get_current_event_time(eventController));
GdkDevice* device = gdk_event_get_device(event);
@@ -1342,7 +1345,7 @@
bool isEnd = gdk_scroll_event_is_stop(event) ? true : false;
- PlatformGtkScrollData scrollData = { .delta = deltaX, .eventTime = eventTime, .source = source, .isEnd = isEnd };
+ PlatformGtkScrollData scrollData = { .delta = delta, .eventTime = eventTime, .source = source, .isEnd = isEnd };
if (controller->handleScrollWheelEvent(&scrollData))
return GDK_EVENT_STOP;
}
@@ -1981,8 +1984,9 @@
ViewGestureController* controller = webkitWebViewBaseViewGestureController(webViewBase);
if (controller && controller->isSwipeGestureEnabled()) {
+ FloatSize delta(deltaX, deltaY);
int32_t eventTime = static_cast<int32_t>(gtk_event_controller_get_current_event_time(GTK_EVENT_CONTROLLER(gesture)));
- PlatformGtkScrollData scrollData = { .delta = deltaX, .eventTime = eventTime, .source = GDK_SOURCE_TOUCHSCREEN, .isEnd = false };
+ PlatformGtkScrollData scrollData = { .delta = delta, .eventTime = eventTime, .source = GDK_SOURCE_TOUCHSCREEN, .isEnd = false };
if (controller->handleScrollWheelEvent(&scrollData))
return;
}
@@ -2006,7 +2010,7 @@
ViewGestureController* controller = webkitWebViewBaseViewGestureController(webViewBase);
if (controller && controller->isSwipeGestureEnabled()) {
int32_t eventTime = static_cast<int32_t>(gtk_event_controller_get_current_event_time(GTK_EVENT_CONTROLLER(gesture)));
- PlatformGtkScrollData scrollData = { .delta = 0, .eventTime = eventTime, .source = GDK_SOURCE_TOUCHSCREEN, .isEnd = true };
+ PlatformGtkScrollData scrollData = { .delta = FloatSize(), .eventTime = eventTime, .source = GDK_SOURCE_TOUCHSCREEN, .isEnd = true };
controller->handleScrollWheelEvent(&scrollData);
}
}
Modified: trunk/Source/WebKit/UIProcess/ViewGestureController.h (279735 => 279736)
--- trunk/Source/WebKit/UIProcess/ViewGestureController.h 2021-07-08 18:07:12 UTC (rev 279735)
+++ trunk/Source/WebKit/UIProcess/ViewGestureController.h 2021-07-08 18:14:23 UTC (rev 279736)
@@ -30,6 +30,7 @@
#include "WebPageProxyIdentifier.h"
#include <WebCore/Color.h>
#include <WebCore/FloatRect.h>
+#include <WebCore/FloatSize.h>
#include <wtf/MonotonicTime.h>
#include <wtf/RetainPtr.h>
#include <wtf/RunLoop.h>
@@ -80,7 +81,7 @@
typedef NSEvent* PlatformScrollEvent;
#elif PLATFORM(GTK)
typedef struct {
- double delta;
+ WebCore::FloatSize delta;
int32_t eventTime;
GdkInputSource source;
bool isEnd;
Modified: trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp (279735 => 279736)
--- trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp 2021-07-08 18:07:12 UTC (rev 279735)
+++ trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp 2021-07-08 18:14:23 UTC (rev 279736)
@@ -97,7 +97,7 @@
{
double multiplier = isTouchEvent(event) ? Scrollbar::pixelsPerLineStep() : gtkScrollDeltaMultiplier;
// GTK deltas are inverted compared to NSEvent, so invert them again
- return -FloatSize(event->delta, 0) * multiplier;
+ return -event->delta * multiplier;
}
bool ViewGestureController::handleScrollWheelEvent(PlatformGtkScrollData* event)
@@ -180,9 +180,8 @@
}
uint32_t eventTime = event->eventTime;
- double eventDeltaX = event->delta;
- double deltaX = -eventDeltaX;
+ double deltaX = -event->delta.width();
if (isTouchEvent(event)) {
m_distance = m_webPageProxy.viewSize().width();
deltaX *= static_cast<double>(Scrollbar::pixelsPerLineStep()) / m_distance;
@@ -638,11 +637,12 @@
if (!canSwipeInDirection(direction))
return false;
- double delta = swipeTouchpadBaseWidth / gtkScrollDeltaMultiplier * 0.75;
+ double deltaX = swipeTouchpadBaseWidth / gtkScrollDeltaMultiplier * 0.75;
if (isPhysicallySwipingLeft(direction))
- delta = -delta;
+ deltaX = -deltaX;
+ FloatSize delta(deltaX, 0);
PlatformGtkScrollData scrollData = { .delta = delta, .eventTime = GDK_CURRENT_TIME, .source = GDK_SOURCE_TOUCHPAD, .isEnd = false };
handleScrollWheelEvent(&scrollData);
@@ -651,7 +651,7 @@
bool ViewGestureController::completeSimulatedSwipeInDirectionForTesting(SwipeDirection)
{
- PlatformGtkScrollData scrollData = { .delta = 0, .eventTime = GDK_CURRENT_TIME, .source = GDK_SOURCE_TOUCHPAD, .isEnd = true };
+ PlatformGtkScrollData scrollData = { .delta = FloatSize(), .eventTime = GDK_CURRENT_TIME, .source = GDK_SOURCE_TOUCHPAD, .isEnd = true };
handleScrollWheelEvent(&scrollData);
return true;