- Revision
- 284596
- Author
- cl...@igalia.com
- Date
- 2021-10-21 02:53:50 -0700 (Thu, 21 Oct 2021)
Log Message
[GTK] Slow scrolling (not matching GTK native scroll amount)
https://bugs.webkit.org/show_bug.cgi?id=197100
Reviewed by Simon Fraser.
Fix up behaviour with interrupting smooth scrolling, mainly on
keyboard-initiated scrolling, but also for the mouse-wheel. When
interrupting a smooth scroll, the animation curve is now changed from
ease-in-out to ease-out and the duration is recalculated.
No new tests, covered by existing tests.
* platform/ScrollAnimation.h:
(WebCore::ScrollAnimation::destinationOffset const):
* platform/ScrollAnimationSmooth.cpp:
(WebCore::ScrollAnimationSmooth::ScrollAnimationSmooth):
(WebCore::ScrollAnimationSmooth::startAnimatedScrollToDestination):
(WebCore::ScrollAnimationSmooth::retargetActiveAnimation):
(WebCore::ScrollAnimationSmooth::animateScroll):
(WebCore::ScrollAnimationSmooth::startOrRetargetAnimation): Deleted.
* platform/ScrollAnimationSmooth.h:
* platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::scroll):
* platform/ScrollingEffectsController.cpp:
(WebCore::ScrollingEffectsController::retargetAnimatedScrollBy):
(WebCore::ScrollingEffectsController::handleWheelEvent):
* platform/ScrollingEffectsController.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (284595 => 284596)
--- trunk/Source/WebCore/ChangeLog 2021-10-21 09:48:26 UTC (rev 284595)
+++ trunk/Source/WebCore/ChangeLog 2021-10-21 09:53:50 UTC (rev 284596)
@@ -1,3 +1,33 @@
+2021-10-21 Chris Lord <cl...@igalia.com>
+
+ [GTK] Slow scrolling (not matching GTK native scroll amount)
+ https://bugs.webkit.org/show_bug.cgi?id=197100
+
+ Reviewed by Simon Fraser.
+
+ Fix up behaviour with interrupting smooth scrolling, mainly on
+ keyboard-initiated scrolling, but also for the mouse-wheel. When
+ interrupting a smooth scroll, the animation curve is now changed from
+ ease-in-out to ease-out and the duration is recalculated.
+
+ No new tests, covered by existing tests.
+
+ * platform/ScrollAnimation.h:
+ (WebCore::ScrollAnimation::destinationOffset const):
+ * platform/ScrollAnimationSmooth.cpp:
+ (WebCore::ScrollAnimationSmooth::ScrollAnimationSmooth):
+ (WebCore::ScrollAnimationSmooth::startAnimatedScrollToDestination):
+ (WebCore::ScrollAnimationSmooth::retargetActiveAnimation):
+ (WebCore::ScrollAnimationSmooth::animateScroll):
+ (WebCore::ScrollAnimationSmooth::startOrRetargetAnimation): Deleted.
+ * platform/ScrollAnimationSmooth.h:
+ * platform/ScrollAnimator.cpp:
+ (WebCore::ScrollAnimator::scroll):
+ * platform/ScrollingEffectsController.cpp:
+ (WebCore::ScrollingEffectsController::retargetAnimatedScrollBy):
+ (WebCore::ScrollingEffectsController::handleWheelEvent):
+ * platform/ScrollingEffectsController.h:
+
2021-10-20 Brady Eidson <beid...@apple.com>
WebKit Managed Notifications: Skeleton NotificationProvider
Modified: trunk/Source/WebCore/platform/ScrollAnimation.h (284595 => 284596)
--- trunk/Source/WebCore/platform/ScrollAnimation.h 2021-10-21 09:48:26 UTC (rev 284595)
+++ trunk/Source/WebCore/platform/ScrollAnimation.h 2021-10-21 09:53:50 UTC (rev 284596)
@@ -78,6 +78,7 @@
virtual void updateScrollExtents() { };
FloatPoint currentOffset() const { return m_currentOffset; }
+ virtual std::optional<FloatPoint> destinationOffset() const { return std::nullopt; }
virtual void serviceAnimation(MonotonicTime) = 0;
Modified: trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp (284595 => 284596)
--- trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp 2021-10-21 09:48:26 UTC (rev 284595)
+++ trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp 2021-10-21 09:53:50 UTC (rev 284596)
@@ -41,7 +41,7 @@
ScrollAnimationSmooth::ScrollAnimationSmooth(ScrollAnimationClient& client)
: ScrollAnimation(Type::Smooth, client)
- , m_easeInOutTimingFunction(CubicBezierTimingFunction::create(CubicBezierTimingFunction::TimingFunctionPreset::EaseInOut))
+ , m_timingFunction(CubicBezierTimingFunction::create())
{
}
@@ -49,11 +49,21 @@
bool ScrollAnimationSmooth::startAnimatedScrollToDestination(const FloatPoint& fromOffset, const FloatPoint& destinationOffset)
{
+ if (!isActive() && fromOffset == destinationOffset)
+ return false;
+
+ auto extents = m_client.scrollExtentsForAnimation(*this);
+
+ m_startTime = MonotonicTime::now();
m_startOffset = fromOffset;
- m_duration = durationFromDistance(destinationOffset - m_startOffset);
+ m_destinationOffset = destinationOffset.constrainedBetween(extents.minimumScrollOffset(), extents.maximumScrollOffset());
+ m_duration = durationFromDistance(m_destinationOffset - m_startOffset);
+ downcast<CubicBezierTimingFunction>(*m_timingFunction).setTimingFunctionPreset(CubicBezierTimingFunction::TimingFunctionPreset::EaseInOut);
- auto extents = m_client.scrollExtentsForAnimation(*this);
- return startOrRetargetAnimation(extents, destinationOffset);
+ if (!isActive())
+ didStart(MonotonicTime::now());
+
+ return true;
}
bool ScrollAnimationSmooth::retargetActiveAnimation(const FloatPoint& newOffset)
@@ -62,18 +72,18 @@
return false;
auto extents = m_client.scrollExtentsForAnimation(*this);
- return startOrRetargetAnimation(extents, newOffset);
-}
-bool ScrollAnimationSmooth::startOrRetargetAnimation(const ScrollExtents& extents, const FloatPoint& destinationOffset)
-{
- m_destinationOffset = destinationOffset.constrainedBetween(extents.minimumScrollOffset(), extents.maximumScrollOffset());
- bool needToScroll = m_startOffset != m_destinationOffset;
+ m_startTime = MonotonicTime::now();
+ m_startOffset = m_currentOffset;
+ m_destinationOffset = newOffset.constrainedBetween(extents.minimumScrollOffset(), extents.maximumScrollOffset());
+ m_duration = durationFromDistance(m_destinationOffset - m_startOffset);
+ downcast<CubicBezierTimingFunction>(*m_timingFunction).setTimingFunctionPreset(CubicBezierTimingFunction::TimingFunctionPreset::EaseOut);
+ m_timingFunction = CubicBezierTimingFunction::create(CubicBezierTimingFunction::TimingFunctionPreset::EaseOut);
- if (needToScroll && !isActive())
- didStart(MonotonicTime::now());
+ if (m_currentOffset == m_destinationOffset)
+ return false;
- return needToScroll;
+ return true;
}
void ScrollAnimationSmooth::updateScrollExtents()
@@ -108,7 +118,7 @@
currentTime = std::min(currentTime, endTime);
double fractionComplete = (currentTime - m_startTime) / m_duration;
- double progress = m_easeInOutTimingFunction->transformProgress(fractionComplete, m_duration.value());
+ double progress = m_timingFunction->transformProgress(fractionComplete, m_duration.value());
m_currentOffset = {
linearInterpolation(progress, m_startOffset.x(), m_destinationOffset.x()),
Modified: trunk/Source/WebCore/platform/ScrollAnimationSmooth.h (284595 => 284596)
--- trunk/Source/WebCore/platform/ScrollAnimationSmooth.h 2021-10-21 09:48:26 UTC (rev 284595)
+++ trunk/Source/WebCore/platform/ScrollAnimationSmooth.h 2021-10-21 09:53:50 UTC (rev 284596)
@@ -41,12 +41,10 @@
bool startAnimatedScrollToDestination(const FloatPoint& fromOffset, const FloatPoint& destinationOffset);
bool retargetActiveAnimation(const FloatPoint& newOffset) final;
- const FloatPoint& destinationOffset() const { return m_destinationOffset; }
+ std::optional<FloatPoint> destinationOffset() const final { return m_destinationOffset; }
private:
- bool startOrRetargetAnimation(const ScrollExtents&, const FloatPoint& destinationOffset);
-
void updateScrollExtents() final;
void serviceAnimation(MonotonicTime) final;
@@ -59,7 +57,7 @@
FloatPoint m_startOffset;
FloatPoint m_destinationOffset;
- RefPtr<TimingFunction> m_easeInOutTimingFunction;
+ RefPtr<TimingFunction> m_timingFunction;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/ScrollAnimator.cpp (284595 => 284596)
--- trunk/Source/WebCore/platform/ScrollAnimator.cpp 2021-10-21 09:48:26 UTC (rev 284595)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp 2021-10-21 09:53:50 UTC (rev 284596)
@@ -89,6 +89,9 @@
}
if (m_scrollableArea.scrollAnimatorEnabled() && platformAllowsScrollAnimation() && !behavior.contains(ScrollBehavior::NeverAnimate)) {
+ if (m_scrollController.retargetAnimatedScrollBy(delta))
+ return true;
+
auto startOffset = offsetFromPosition(m_currentPosition);
auto extents = scrollExtents();
auto destinationOffset = (startOffset + delta).constrainedBetween(extents.minimumScrollOffset(), extents.maximumScrollOffset());
Modified: trunk/Source/WebCore/platform/ScrollingEffectsController.cpp (284595 => 284596)
--- trunk/Source/WebCore/platform/ScrollingEffectsController.cpp 2021-10-21 09:48:26 UTC (rev 284595)
+++ trunk/Source/WebCore/platform/ScrollingEffectsController.cpp 2021-10-21 09:53:50 UTC (rev 284596)
@@ -118,6 +118,20 @@
return downcast<ScrollAnimationSmooth>(*m_currentAnimation).retargetActiveAnimation(newDestinationOffset);
}
+bool ScrollingEffectsController::retargetAnimatedScrollBy(FloatSize offset)
+{
+ if (!is<ScrollAnimationSmooth>(m_currentAnimation.get()))
+ return false;
+
+ LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController " << this << " retargetAnimatedScrollBy " << offset);
+
+ ASSERT(m_currentAnimation->isActive());
+ if (auto destinationOffset = m_currentAnimation->destinationOffset())
+ return m_currentAnimation->retargetActiveAnimation(*destinationOffset + offset);
+
+ return false;
+}
+
void ScrollingEffectsController::stopAnimatedScroll()
{
LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController " << this << " stopAnimatedScroll");
@@ -351,10 +365,7 @@
#if ENABLE(SMOOTH_SCROLLING)
if (m_client.scrollAnimationEnabled() && !m_inScrollGesture) {
- if (is<ScrollAnimationSmooth>(m_currentAnimation.get())) {
- auto lastDestinationOffset = downcast<ScrollAnimationSmooth>(*m_currentAnimation).destinationOffset();
- retargetAnimatedScroll(lastDestinationOffset + FloatSize { deltaX, deltaY });
- } else
+ if (!retargetAnimatedScrollBy({ deltaX, deltaY }))
startAnimatedScrollToDestination(scrollOffset, scrollOffset + FloatSize { deltaX, deltaY });
return true;
}
Modified: trunk/Source/WebCore/platform/ScrollingEffectsController.h (284595 => 284596)
--- trunk/Source/WebCore/platform/ScrollingEffectsController.h 2021-10-21 09:48:26 UTC (rev 284595)
+++ trunk/Source/WebCore/platform/ScrollingEffectsController.h 2021-10-21 09:53:50 UTC (rev 284596)
@@ -135,6 +135,7 @@
bool startAnimatedScrollToDestination(FloatPoint startOffset, FloatPoint destinationOffset);
bool retargetAnimatedScroll(FloatPoint newDestinationOffset);
+ bool retargetAnimatedScrollBy(FloatSize);
void stopAnimatedScroll();
void stopKeyboardScrolling();