Changeset 250820 in webkit


Ignore:
Timestamp:
Oct 8, 2019 3:03:38 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

[GTK] Navigation gesture improvements
https://bugs.webkit.org/show_bug.cgi?id=202645

Patch by Alexander Mikhaylenko <Alexander Mikhaylenko> 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):

Location:
trunk/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r250819 r250820  
     12019-10-08  Alexander Mikhaylenko  <alexm@gnome.org>
     2
     3        [GTK] Navigation gesture improvements
     4        https://bugs.webkit.org/show_bug.cgi?id=202645
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Measure velocity threshold in pixels per second rather than distance (range [0-1])
     9        per second. The value is the same as it was on touchpads, since a fixed distance is
     10        used, but is now consistent on touchscreens, regardless of the webview width.
     11
     12        Add a threshold for cancelling gesture when the page is more than halfway
     13        through, so that it's symmetric with the first half.
     14
     15        Align the moving page to pixel grid on hidpi devices correctly. Just
     16        rounding the position doesn't work correctly, since the cairo context is
     17        pre-scaled. Multiplying by scale factor, rounding and then dividing by
     18        scale factor fixes this.
     19
     20        * UIProcess/ViewGestureController.h:
     21        * UIProcess/gtk/ViewGestureControllerGtk.cpp:
     22        (WebKit::ViewGestureController::SwipeProgressTracker::reset):
     23        (WebKit::ViewGestureController::SwipeProgressTracker::handleEvent):
     24        (WebKit::ViewGestureController::SwipeProgressTracker::shouldCancel):
     25        (WebKit::ViewGestureController::draw):
     26
    1272019-10-08  Carlos Garcia Campos  <cgarcia@igalia.com>
    228
  • trunk/Source/WebKit/UIProcess/ViewGestureController.h

    r250648 r250820  
    400400        Seconds m_prevTime;
    401401        double m_velocity { 0 };
     402        double m_distance { 0 };
    402403
    403404        Seconds m_startTime;
  • trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp

    r250648 r250820  
    4646
    4747static const double swipeCancelArea = 0.5;
    48 static const double swipeCancelVelocityThreshold = 0.001;
     48static const double swipeCancelVelocityThreshold = 0.4;
    4949
    5050static bool isEventStop(GdkEventScroll* event)
     
    142142    m_prevTime = 0_ms;
    143143    m_velocity = 0;
     144    m_distance = 0;
    144145    m_cancelled = false;
    145146}
     
    179180
    180181    double deltaX = -eventDeltaX;
    181     if (isTouchEvent(event))
    182         deltaX *= (double) Scrollbar::pixelsPerLineStep() / m_webPageProxy.viewSize().width();
    183     else
    184         deltaX *= gtkScrollDeltaMultiplier / swipeTouchpadBaseWidth;
     182    if (isTouchEvent(event)) {
     183        m_distance = m_webPageProxy.viewSize().width();
     184        deltaX *= static_cast<double>(Scrollbar::pixelsPerLineStep()) / m_distance;
     185    } else {
     186        m_distance = swipeTouchpadBaseWidth;
     187        deltaX *= gtkScrollDeltaMultiplier / m_distance;
     188    }
    185189
    186190    Seconds time = Seconds::fromMilliseconds(eventTime);
     
    204208{
    205209    bool swipingLeft = m_viewGestureController.isPhysicallySwipingLeft(m_direction);
    206 
    207     if (swipingLeft && m_velocity < 0)
    208         return true;
    209 
    210     if (!swipingLeft && m_velocity > 0)
    211         return true;
    212 
    213     return (abs(m_progress) < swipeCancelArea && abs(m_velocity) < swipeCancelVelocityThreshold);
     210    double relativeVelocity = m_velocity * (swipingLeft ? 1 : -1);
     211
     212    if (abs(m_progress) > swipeCancelArea)
     213        return (relativeVelocity * m_distance < -swipeCancelVelocityThreshold);
     214
     215    return (relativeVelocity * m_distance < swipeCancelVelocityThreshold);
    214216}
    215217
     
    405407    int width = size.width();
    406408    int height = size.height();
    407 
    408     double swipingLayerOffset = (swipingLeft ? 0 : width) + floor(width * progress);
     409    double scale = m_webPageProxy.deviceScaleFactor();
     410
     411    double swipingLayerOffset = (swipingLeft ? 0 : width) + floor(width * progress * scale) / scale;
    409412
    410413    double dimmingProgress = swipingLeft ? 1 - progress : -progress;
Note: See TracChangeset for help on using the changeset viewer.