Title: [282814] trunk/Source/WebCore
Revision
282814
Author
[email protected]
Date
2021-09-21 07:54:01 -0700 (Tue, 21 Sep 2021)

Log Message

ScrollAnimationSmooth should only have one way to start an animation
https://bugs.webkit.org/show_bug.cgi?id=230529

Reviewed by Martin Robinson.

Remove the ScrollbarOrientation/ScrollGranularity/step/multiplier entry point on
ScrollAnimationSmooth; the caller can do the math to compute the end point.

* page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp:
(WebCore::ScrollingTreeScrollingNodeDelegateNicosia::handleWheelEvent):
* platform/ScrollAnimationSmooth.cpp:
(WebCore::ScrollAnimationSmooth::startAnimatedScroll): Deleted.
* platform/ScrollAnimationSmooth.h:
* platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::scroll):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (282813 => 282814)


--- trunk/Source/WebCore/ChangeLog	2021-09-21 14:50:52 UTC (rev 282813)
+++ trunk/Source/WebCore/ChangeLog	2021-09-21 14:54:01 UTC (rev 282814)
@@ -1,3 +1,21 @@
+2021-09-21  Simon Fraser  <[email protected]>
+
+        ScrollAnimationSmooth should only have one way to start an animation
+        https://bugs.webkit.org/show_bug.cgi?id=230529
+
+        Reviewed by Martin Robinson.
+
+        Remove the ScrollbarOrientation/ScrollGranularity/step/multiplier entry point on
+        ScrollAnimationSmooth; the caller can do the math to compute the end point.
+
+        * page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp:
+        (WebCore::ScrollingTreeScrollingNodeDelegateNicosia::handleWheelEvent):
+        * platform/ScrollAnimationSmooth.cpp:
+        (WebCore::ScrollAnimationSmooth::startAnimatedScroll): Deleted.
+        * platform/ScrollAnimationSmooth.h:
+        * platform/ScrollAnimator.cpp:
+        (WebCore::ScrollAnimator::scroll):
+
 2021-09-21  Antti Koivisto  <[email protected]>
 
         [LFC][Integration] Enable markers and highlights

Modified: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp (282813 => 282814)


--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp	2021-09-21 14:50:52 UTC (rev 282813)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp	2021-09-21 14:54:01 UTC (rev 282814)
@@ -162,8 +162,9 @@
 #if ENABLE(SMOOTH_SCROLLING)
     if (m_scrollAnimatorEnabled && !wheelEvent.hasPreciseScrollingDeltas()) {
         ensureScrollAnimationSmooth();
-        m_smoothAnimation->startAnimatedScroll(HorizontalScrollbar, ScrollByPixel, currentScrollPosition(), 1, deltaX);
-        m_smoothAnimation->startAnimatedScroll(VerticalScrollbar, ScrollByPixel, currentScrollPosition(), 1, deltaY);
+        auto currentOffset = scrollingNode().currentScrollOffset();
+        auto destinationOffset = currentOffset + FloatSize { deltaX, deltaY };
+        m_smoothAnimation->startAnimatedScrollToDestination(currentOffset, destinationOffset);
         return WheelEventHandlingResult::handled();
     }
 #endif

Modified: trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp (282813 => 282814)


--- trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp	2021-09-21 14:50:52 UTC (rev 282813)
+++ trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp	2021-09-21 14:54:01 UTC (rev 282814)
@@ -56,25 +56,6 @@
 
 ScrollAnimationSmooth::~ScrollAnimationSmooth() = default;
 
-bool ScrollAnimationSmooth::startAnimatedScroll(ScrollbarOrientation orientation, ScrollGranularity, const FloatPoint& fromOffset, float step, float multiplier)
-{
-    m_startOffset = fromOffset;
-    auto destinationOffset = fromOffset;
-    switch (orientation) {
-    case HorizontalScrollbar:
-        destinationOffset.setX(destinationOffset.x() + step * multiplier);
-        break;
-    case VerticalScrollbar:
-        destinationOffset.setY(destinationOffset.y() + step * multiplier);
-        break;
-    }
-
-    m_duration = durationFromDistance(destinationOffset - m_startOffset);
-
-    auto extents = m_client.scrollExtentsForAnimation(*this);
-    return startOrRetargetAnimation(extents, destinationOffset);
-}
-
 bool ScrollAnimationSmooth::startAnimatedScrollToDestination(const FloatPoint& fromOffset, const FloatPoint& destinationOffset)
 {
     m_startOffset = fromOffset;

Modified: trunk/Source/WebCore/platform/ScrollAnimationSmooth.h (282813 => 282814)


--- trunk/Source/WebCore/platform/ScrollAnimationSmooth.h	2021-09-21 14:50:52 UTC (rev 282813)
+++ trunk/Source/WebCore/platform/ScrollAnimationSmooth.h	2021-09-21 14:54:01 UTC (rev 282814)
@@ -40,7 +40,6 @@
     ScrollAnimationSmooth(ScrollAnimationClient&);
     virtual ~ScrollAnimationSmooth();
 
-    bool startAnimatedScroll(ScrollbarOrientation, ScrollGranularity, const FloatPoint& fromOffset, float step, float multiplier);
     bool startAnimatedScrollToDestination(const FloatPoint& fromOffset, const FloatPoint& destinationOffset);
 
     bool retargetActiveAnimation(const FloatPoint& newOffset) final;

Modified: trunk/Source/WebCore/platform/ScrollAnimator.cpp (282813 => 282814)


--- trunk/Source/WebCore/platform/ScrollAnimator.cpp	2021-09-21 14:50:52 UTC (rev 282813)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp	2021-09-21 14:54:01 UTC (rev 282814)
@@ -87,8 +87,12 @@
     }
 
 #if ENABLE(SMOOTH_SCROLLING) && !PLATFORM(IOS_FAMILY)
-    if (m_scrollableArea.scrollAnimatorEnabled() && platformAllowsScrollAnimation() && !behavior.contains(ScrollBehavior::NeverAnimate))
-        return m_scrollAnimation->startAnimatedScroll(orientation, granularity, offsetFromPosition(m_currentPosition), step, multiplier);
+    if (m_scrollableArea.scrollAnimatorEnabled() && platformAllowsScrollAnimation() && !behavior.contains(ScrollBehavior::NeverAnimate)) {
+        auto startOffset = offsetFromPosition(m_currentPosition);
+        auto extents = scrollExtents();
+        auto destinationOffset = (startOffset + delta).constrainedBetween(extents.minimumScrollOffset(), extents.maximumScrollOffset());
+        return m_scrollAnimation->startAnimatedScrollToDestination(startOffset, destinationOffset);
+    }
 #endif
 
     return scrollToPositionWithoutAnimation(currentPosition() + delta);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to