Changeset 250820 in webkit
- Timestamp:
- Oct 8, 2019 3:03:38 AM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r250819 r250820 1 2019-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 1 27 2019-10-08 Carlos Garcia Campos <cgarcia@igalia.com> 2 28 -
trunk/Source/WebKit/UIProcess/ViewGestureController.h
r250648 r250820 400 400 Seconds m_prevTime; 401 401 double m_velocity { 0 }; 402 double m_distance { 0 }; 402 403 403 404 Seconds m_startTime; -
trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp
r250648 r250820 46 46 47 47 static const double swipeCancelArea = 0.5; 48 static const double swipeCancelVelocityThreshold = 0. 001;48 static const double swipeCancelVelocityThreshold = 0.4; 49 49 50 50 static bool isEventStop(GdkEventScroll* event) … … 142 142 m_prevTime = 0_ms; 143 143 m_velocity = 0; 144 m_distance = 0; 144 145 m_cancelled = false; 145 146 } … … 179 180 180 181 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 } 185 189 186 190 Seconds time = Seconds::fromMilliseconds(eventTime); … … 204 208 { 205 209 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); 214 216 } 215 217 … … 405 407 int width = size.width(); 406 408 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; 409 412 410 413 double dimmingProgress = swipingLeft ? 1 - progress : -progress;
Note: See TracChangeset
for help on using the changeset viewer.