WebKit Bugzilla
Attachment 369370 Details for
Bug 197690
: [GTK] Support navigation gesture on touchscreens
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197690-20190508152932.patch (text/plain), 6.17 KB, created by
Alice Mikhaylenko
on 2019-05-08 03:29:34 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Alice Mikhaylenko
Created:
2019-05-08 03:29:34 PDT
Size:
6.17 KB
patch
obsolete
>Subversion Revision: 245007 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 33eff1465fc00de4679db854460c2972e0d4b1f9..ceb05199cc0bf1c6cc59ff6ca5c4b351461f4ca8 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,37 @@ >+2019-05-08 Alexander Mikhaylenko <exalm7659@gmail.com> >+ >+ [GTK] Support navigation gesture on touchscreens >+ https://bugs.webkit.org/show_bug.cgi?id=197690 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Touch events generate scroll events that are handled in webkitWebViewBaseHandleWheelEvent(), >+ bypassing webkitWebViewBaseScrollEvent(). Because of that, ViewGestureController never receives >+ them. Hence pass scroll events to ViewGestureController in webkitWebViewBaseHandleWheelEvent() >+ instead. >+ >+ For touch events, gesture progress calculation has to take window width into account to make >+ the page perfectly follow finger, and deltas are additionally divided by Scrollbar::pixelsPerLineStep(), >+ so compensate for that. >+ >+ For touchpad events, change delta multiplier to 10 to match GTK behavior, and introduce a 400px >+ base width so the swipe speed doesn't change from the previous behavior. >+ >+ Because of the multiplier change, threshold for triggering the gesture with touchpad is now 4 >+ times larger. >+ >+ * UIProcess/API/gtk/WebKitWebViewBase.cpp: >+ (webkitWebViewBaseHandleWheelEvent): Moved ViewGestureController >+ (webkitWebViewBaseScrollEvent): >+ * UIProcess/gtk/ViewGestureControllerGtk.cpp: >+ (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanInfluenceSwipe): >+ Allow events from touchscreen devices. >+ (WebKit::isTouchEvent): Added. >+ (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventGetScrollingDeltas): >+ Change delta multipliers. >+ (WebKit::ViewGestureController::SwipeProgressTracker::handleEvent): >+ Change delta multipliers, account for view width for touchscreen events. >+ > 2019-05-07 Antti Koivisto <antti@apple.com> > > <body> with overflow:hidden CSS is scrollable on iOS >diff --git a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp >index 10ea4b22cd6d3fd8025c77a231546ea1dc329c32..a917ffa270ff20b92ed0d1b78c6c89c63bee5840 100644 >--- a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp >+++ b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp >@@ -850,6 +850,10 @@ static gboolean webkitWebViewBaseButtonReleaseEvent(GtkWidget* widget, GdkEventB > > static void webkitWebViewBaseHandleWheelEvent(WebKitWebViewBase* webViewBase, GdkEvent* event, Optional<WebWheelEvent::Phase> phase = WTF::nullopt, Optional<WebWheelEvent::Phase> momentum = WTF::nullopt) > { >+ ViewGestureController* controller = webkitWebViewBaseViewGestureController(webViewBase); >+ if (controller && controller->isSwipeGestureEnabled() && controller->handleScrollWheelEvent(reinterpret_cast<GdkEventScroll*>(event))) >+ return; >+ > WebKitWebViewBasePrivate* priv = webViewBase->priv; > ASSERT(!priv->dialog); > if (phase) >@@ -890,10 +894,6 @@ static gboolean webkitWebViewBaseScrollEvent(GtkWidget* widget, GdkEventScroll* > } > } > >- ViewGestureController* controller = webkitWebViewBaseViewGestureController(webViewBase); >- if (controller && controller->isSwipeGestureEnabled() && controller->handleScrollWheelEvent(event)) >- return GDK_EVENT_STOP; >- > webkitWebViewBaseHandleWheelEvent(webViewBase, reinterpret_cast<GdkEvent*>(event)); > > return GDK_EVENT_STOP; >diff --git a/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp b/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp >index 6584c34fe4ec0336e0ccf0556dbaa7fc907be11e..4bae03ab9dfc2ca0ee9a6a61cb6e1afd63155f4b 100644 >--- a/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp >+++ b/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp >@@ -36,6 +36,10 @@ static const Seconds swipeMinAnimationDuration = 100_ms; > static const Seconds swipeMaxAnimationDuration = 400_ms; > static const double swipeAnimationBaseVelocity = 0.002; > >+// GTK divides all scroll deltas by 10, compensate for that >+static const double gtkScrollDeltaMultiplier = 10; >+static const double swipeTouchpadBaseWidth = 400; >+ > // This is derivative of the easing function at t=0 > static const double swipeAnimationDurationMultiplier = 3; > >@@ -82,13 +86,23 @@ bool ViewGestureController::PendingSwipeTracker::scrollEventCanInfluenceSwipe(Gd > > // FIXME: Should it maybe be allowed on mice/trackpoints as well? The GDK_SCROLL_SMOOTH > // requirement already filters out most mice, and it works pretty well on a trackpoint >- return event->direction == GDK_SCROLL_SMOOTH && source == GDK_SOURCE_TOUCHPAD; >+ return event->direction == GDK_SCROLL_SMOOTH && (source == GDK_SOURCE_TOUCHPAD || source == GDK_SOURCE_TOUCHSCREEN); >+} >+ >+static bool isTouchEvent(GdkEventScroll* event) >+{ >+ GdkDevice* device = gdk_event_get_source_device(reinterpret_cast<GdkEvent*>(event)); >+ GdkInputSource source = gdk_device_get_source(device); >+ >+ return source == GDK_SOURCE_TOUCHSCREEN; > } > > FloatSize ViewGestureController::PendingSwipeTracker::scrollEventGetScrollingDeltas(GdkEventScroll* event) > { >+ double multiplier = isTouchEvent(event) ? Scrollbar::pixelsPerLineStep() : gtkScrollDeltaMultiplier; >+ > // GdkEventScroll deltas are inverted compared to NSEvent, so invert them again >- return -FloatSize(event->delta_x, event->delta_y) * Scrollbar::pixelsPerLineStep(); >+ return -FloatSize(event->delta_x, event->delta_y) * multiplier; > } > > bool ViewGestureController::handleScrollWheelEvent(GdkEventScroll* event) >@@ -169,7 +183,11 @@ bool ViewGestureController::SwipeProgressTracker::handleEvent(GdkEventScroll* ev > return false; > } > >- double deltaX = -event->delta_x / Scrollbar::pixelsPerLineStep(); >+ double deltaX = -event->delta_x; >+ if (isTouchEvent(event)) >+ deltaX *= (double) Scrollbar::pixelsPerLineStep() / m_webPageProxy.viewSize().width(); >+ else >+ deltaX *= gtkScrollDeltaMultiplier / swipeTouchpadBaseWidth; > > Seconds time = Seconds::fromMilliseconds(event->time); > if (time != m_prevTime)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
mcatanzaro
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 197690
:
369370
|
369375
|
369376
|
369391