Title: [250820] trunk/Source/WebKit
- Revision
- 250820
- Author
- [email protected]
- Date
- 2019-10-08 03:03:38 -0700 (Tue, 08 Oct 2019)
Log Message
[GTK] Navigation gesture improvements
https://bugs.webkit.org/show_bug.cgi?id=202645
Patch by Alexander Mikhaylenko <[email protected]> on 2019-10-08
Reviewed by Carlos Garcia Campos.
Measure velocity threshold in pixels per second rather than distance (range [0-1])
per second. The value is the same as it was on touchpads, since a fixed distance is
used, but is now consistent on touchscreens, regardless of the webview width.
Add a threshold for cancelling gesture when the page is more than halfway
through, so that it's symmetric with the first half.
Align the moving page to pixel grid on hidpi devices correctly. Just
rounding the position doesn't work correctly, since the cairo context is
pre-scaled. Multiplying by scale factor, rounding and then dividing by
scale factor fixes this.
* UIProcess/ViewGestureController.h:
* UIProcess/gtk/ViewGestureControllerGtk.cpp:
(WebKit::ViewGestureController::SwipeProgressTracker::reset):
(WebKit::ViewGestureController::SwipeProgressTracker::handleEvent):
(WebKit::ViewGestureController::SwipeProgressTracker::shouldCancel):
(WebKit::ViewGestureController::draw):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (250819 => 250820)
--- trunk/Source/WebKit/ChangeLog 2019-10-08 09:06:30 UTC (rev 250819)
+++ trunk/Source/WebKit/ChangeLog 2019-10-08 10:03:38 UTC (rev 250820)
@@ -1,3 +1,29 @@
+2019-10-08 Alexander Mikhaylenko <[email protected]>
+
+ [GTK] Navigation gesture improvements
+ https://bugs.webkit.org/show_bug.cgi?id=202645
+
+ Reviewed by Carlos Garcia Campos.
+
+ Measure velocity threshold in pixels per second rather than distance (range [0-1])
+ per second. The value is the same as it was on touchpads, since a fixed distance is
+ used, but is now consistent on touchscreens, regardless of the webview width.
+
+ Add a threshold for cancelling gesture when the page is more than halfway
+ through, so that it's symmetric with the first half.
+
+ Align the moving page to pixel grid on hidpi devices correctly. Just
+ rounding the position doesn't work correctly, since the cairo context is
+ pre-scaled. Multiplying by scale factor, rounding and then dividing by
+ scale factor fixes this.
+
+ * UIProcess/ViewGestureController.h:
+ * UIProcess/gtk/ViewGestureControllerGtk.cpp:
+ (WebKit::ViewGestureController::SwipeProgressTracker::reset):
+ (WebKit::ViewGestureController::SwipeProgressTracker::handleEvent):
+ (WebKit::ViewGestureController::SwipeProgressTracker::shouldCancel):
+ (WebKit::ViewGestureController::draw):
+
2019-10-08 Carlos Garcia Campos <[email protected]>
Unreviewed. Remove unused WebKitSoupRequestGeneric after r250597
Modified: trunk/Source/WebKit/UIProcess/ViewGestureController.h (250819 => 250820)
--- trunk/Source/WebKit/UIProcess/ViewGestureController.h 2019-10-08 09:06:30 UTC (rev 250819)
+++ trunk/Source/WebKit/UIProcess/ViewGestureController.h 2019-10-08 10:03:38 UTC (rev 250820)
@@ -399,6 +399,7 @@
Seconds m_prevTime;
double m_velocity { 0 };
+ double m_distance { 0 };
Seconds m_startTime;
Seconds m_endTime;
Modified: trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp (250819 => 250820)
--- trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp 2019-10-08 09:06:30 UTC (rev 250819)
+++ trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp 2019-10-08 10:03:38 UTC (rev 250820)
@@ -45,7 +45,7 @@
static const double swipeAnimationDurationMultiplier = 3;
static const double swipeCancelArea = 0.5;
-static const double swipeCancelVelocityThreshold = 0.001;
+static const double swipeCancelVelocityThreshold = 0.4;
static bool isEventStop(GdkEventScroll* event)
{
@@ -141,6 +141,7 @@
m_endTime = 0_ms;
m_prevTime = 0_ms;
m_velocity = 0;
+ m_distance = 0;
m_cancelled = false;
}
@@ -178,10 +179,13 @@
gdk_event_get_scroll_deltas(reinterpret_cast<GdkEvent*>(event), &eventDeltaX, nullptr);
double deltaX = -eventDeltaX;
- if (isTouchEvent(event))
- deltaX *= (double) Scrollbar::pixelsPerLineStep() / m_webPageProxy.viewSize().width();
- else
- deltaX *= gtkScrollDeltaMultiplier / swipeTouchpadBaseWidth;
+ if (isTouchEvent(event)) {
+ m_distance = m_webPageProxy.viewSize().width();
+ deltaX *= static_cast<double>(Scrollbar::pixelsPerLineStep()) / m_distance;
+ } else {
+ m_distance = swipeTouchpadBaseWidth;
+ deltaX *= gtkScrollDeltaMultiplier / m_distance;
+ }
Seconds time = Seconds::fromMilliseconds(eventTime);
if (time != m_prevTime)
@@ -203,14 +207,12 @@
bool ViewGestureController::SwipeProgressTracker::shouldCancel()
{
bool swipingLeft = m_viewGestureController.isPhysicallySwipingLeft(m_direction);
+ double relativeVelocity = m_velocity * (swipingLeft ? 1 : -1);
- if (swipingLeft && m_velocity < 0)
- return true;
+ if (abs(m_progress) > swipeCancelArea)
+ return (relativeVelocity * m_distance < -swipeCancelVelocityThreshold);
- if (!swipingLeft && m_velocity > 0)
- return true;
-
- return (abs(m_progress) < swipeCancelArea && abs(m_velocity) < swipeCancelVelocityThreshold);
+ return (relativeVelocity * m_distance < swipeCancelVelocityThreshold);
}
void ViewGestureController::SwipeProgressTracker::startAnimation()
@@ -404,8 +406,9 @@
auto size = m_webPageProxy.drawingArea()->size();
int width = size.width();
int height = size.height();
+ double scale = m_webPageProxy.deviceScaleFactor();
- double swipingLayerOffset = (swipingLeft ? 0 : width) + floor(width * progress);
+ double swipingLayerOffset = (swipingLeft ? 0 : width) + floor(width * progress * scale) / scale;
double dimmingProgress = swipingLeft ? 1 - progress : -progress;
if (isRTL)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes