WebKit Bugzilla
Attachment 362717 Details for
Bug 194943
: [GTK] Navigation gesture improvements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194943-20190222183136.patch (text/plain), 6.88 KB, created by
Alice Mikhaylenko
on 2019-02-22 05:31:38 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Alice Mikhaylenko
Created:
2019-02-22 05:31:38 PST
Size:
6.88 KB
patch
obsolete
>Subversion Revision: 241942 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 286d055c39d8eda6b3427003626f95d9021ba32d..f0a348342ad1d0fcb6d74f4d5bf05781a985d9da 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,26 @@ >+2019-02-22 Alexander Mikhaylenko <exalm7659@gmail.com> >+ >+ [GTK] Navigation gesture improvements >+ https://bugs.webkit.org/show_bug.cgi?id=194943 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Cancel the gesture if progress is less than 0.5 and velocity is not high enough. >+ >+ Allow to continue the gesture during animation. Introduce finished state to be used >+ when showing snapshot after the animation ends. >+ >+ Fix duration calculation, also slow it down so that the initial velocity matches >+ what it was during the gesture. >+ >+ * UIProcess/ViewGestureController.h: Add shouldCancel() and State::Finishing to SwipeProgressTracker. >+ * UIProcess/gtk/ViewGestureControllerGtk.cpp: >+ (WebKit::ViewGestureController::SwipeProgressTracker::handleEvent): >+ Fix velocity calculation, allow scrolling during State::Animating. >+ (WebKit::ViewGestureController::SwipeProgressTracker::shouldCancel): Added. >+ (WebKit::ViewGestureController::SwipeProgressTracker::startAnimation): Use shouldCancel() and fix duration calculation. >+ (WebKit::ViewGestureController::SwipeProgressTracker::endAnimation): Set state to State::Finishing when the animation ends. >+ > 2019-02-21 Adrian Perez de Castro <aperez@igalia.com> > > [WPE][GTK] No API documentation generated for WebKitUserContentFilterStore >diff --git a/Source/WebKit/UIProcess/ViewGestureController.h b/Source/WebKit/UIProcess/ViewGestureController.h >index b5411bb95af5bdf8260c53387335bb326500469c..431c2766d08261e52cefb206d6cd299b12cf1394 100644 >--- a/Source/WebKit/UIProcess/ViewGestureController.h >+++ b/Source/WebKit/UIProcess/ViewGestureController.h >@@ -374,9 +374,12 @@ private: > None, > Pending, > Scrolling, >- Animating >+ Animating, >+ Finishing > }; > >+ bool shouldCancel(); >+ > void startAnimation(); > gboolean onAnimationTick(GdkFrameClock*); > void endAnimation(); >diff --git a/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp b/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp >index 4af6ef0b5716d6e99daf6d79522dcd8e2d5fbe77..484fbe5b8b50b6e1689f22935eeaae4b7f066dc9 100644 >--- a/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp >+++ b/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp >@@ -35,6 +35,12 @@ using namespace WebCore; > static const Seconds swipeMinAnimationDuration = 100_ms; > static const Seconds swipeMaxAnimationDuration = 400_ms; > >+// This is derivative of the easing function at t=0 >+static const double swipeAnimationDurationMultiplier = 3; >+ >+static const double swipeCancelArea = 0.5; >+static const double swipeCancelVelocityThreshold = 0.001; >+ > static const double swipeOverlayShadowOpacity = 0.06; > static const double swipeOverlayDimmingOpacity = 0.12; > static const double swipeOverlayShadowWidth = 81; >@@ -135,15 +141,25 @@ void ViewGestureController::SwipeProgressTracker::reset() > > bool ViewGestureController::SwipeProgressTracker::handleEvent(GdkEventScroll* event) > { >+ // Don't allow scrolling while the next page is loading >+ if (m_state == State::Finishing) >+ return true; >+ >+ // Stop current animation, if any >+ if (m_state == State::Animating) { >+ GtkWidget* widget = m_webPageProxy.viewWidget(); >+ gtk_widget_remove_tick_callback(widget, m_tickCallbackID); >+ m_tickCallbackID = 0; >+ >+ m_cancelled = false; >+ m_state = State::Pending; >+ } >+ > if (m_state == State::Pending) { > m_viewGestureController.beginSwipeGesture(m_targetItem.get(), m_direction); > m_state = State::Scrolling; > } > >- // Don't allow scrolling during animation >- if (m_state == State::Animating) >- return true; >- > if (m_state != State::Scrolling) > return false; > >@@ -152,11 +168,14 @@ bool ViewGestureController::SwipeProgressTracker::handleEvent(GdkEventScroll* ev > return false; > } > >+ double deltaX = -event->delta_x / Scrollbar::pixelsPerLineStep(); >+ > Seconds time = Seconds::fromMilliseconds(event->time); >- m_velocity = -event->delta_x / (time - m_prevTime).milliseconds(); >+ if (time != m_prevTime) >+ m_velocity = deltaX / (time - m_prevTime).milliseconds(); > > m_prevTime = time; >- m_progress -= event->delta_x / Scrollbar::pixelsPerLineStep(); >+ m_progress += deltaX; > > bool swipingLeft = m_viewGestureController.isPhysicallySwipingLeft(m_direction); > float maxProgress = swipingLeft ? 1 : 0; >@@ -168,10 +187,22 @@ bool ViewGestureController::SwipeProgressTracker::handleEvent(GdkEventScroll* ev > return true; > } > >-void ViewGestureController::SwipeProgressTracker::startAnimation() >+bool ViewGestureController::SwipeProgressTracker::shouldCancel() > { > bool swipingLeft = m_viewGestureController.isPhysicallySwipingLeft(m_direction); >- m_cancelled = swipingLeft ? (m_velocity <= 0) : (m_velocity >= 0); >+ >+ if (swipingLeft && m_velocity < 0) >+ return true; >+ >+ if (!swipingLeft && m_velocity > 0) >+ return true; >+ >+ return (abs(m_progress) < swipeCancelArea && abs(m_velocity) < swipeCancelVelocityThreshold); >+} >+ >+void ViewGestureController::SwipeProgressTracker::startAnimation() >+{ >+ m_cancelled = shouldCancel(); > > m_state = State::Animating; > m_viewGestureController.willEndSwipeGesture(*m_targetItem, m_cancelled); >@@ -180,10 +211,13 @@ void ViewGestureController::SwipeProgressTracker::startAnimation() > if (m_cancelled) > m_endProgress = 0; > else >- m_endProgress = swipingLeft ? 1 : -1; >+ m_endProgress = m_viewGestureController.isPhysicallySwipingLeft(m_direction) ? 1 : -1; > >- Seconds duration = Seconds::fromMilliseconds(std::abs((m_progress - m_endProgress) / m_velocity) * Scrollbar::pixelsPerLineStep()); >- duration = std::min(std::max(duration, swipeMinAnimationDuration), swipeMaxAnimationDuration); >+ Seconds duration = swipeMaxAnimationDuration; >+ if ((m_endProgress - m_progress) * m_velocity > 0) { >+ duration = Seconds::fromMilliseconds(std::abs((m_progress - m_endProgress) / m_velocity * swipeAnimationDurationMultiplier)); >+ duration = clampTo<WTF::Seconds>(duration, swipeMinAnimationDuration, swipeMaxAnimationDuration); >+ } > > GtkWidget* widget = m_webPageProxy.viewWidget(); > m_startTime = Seconds::fromMicroseconds(gdk_frame_clock_get_frame_time(gtk_widget_get_frame_clock(widget))); >@@ -226,6 +260,7 @@ gboolean ViewGestureController::SwipeProgressTracker::onAnimationTick(GdkFrameCl > > void ViewGestureController::SwipeProgressTracker::endAnimation() > { >+ m_state = State::Finishing; > m_viewGestureController.endSwipeGesture(m_targetItem.get(), m_cancelled); > } >
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
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194943
: 362717