- Revision
- 273733
- Author
- [email protected]
- Date
- 2021-03-02 09:57:53 -0800 (Tue, 02 Mar 2021)
Log Message
Eliminate ScrollAnimatorGeneric::m_smoothAnimation
https://bugs.webkit.org/show_bug.cgi?id=222588
Patch by Martin Robinson <[email protected]> on 2021-03-02
Reviewed by Simon Fraser.
No new tests. This change should not change behavior.
Eliminate the extra ScrollAnimationSmooth in ScrollAnimatorGeneric. The base
class already knows how to do scroll animations for programmatic scrolls,
so we can reuse that animation for doing ScrollAnimator::scroll(...). This
makes the code easier to understand and should simplify managing interactions
between the different animations in the future.
* platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::ScrollAnimator): Renamed m_animationProgrammaticScroll
to m_scrollAnimation. The more generic name reflects the fact that it is also
used for doing scrolling from UI interaction now.
(WebCore::ScrollAnimator::scroll): Use the ScrollAnimationSmooth member to do
animated scrolls when necessary.
(WebCore::ScrollAnimator::scrollToPositionWithoutAnimation): Make sure the animation
is up to date with the current position when scrolling without it. This is
how ScrollAnimatorGeneric treated its ScrollAnimationSmooth.
(WebCore::ScrollAnimator::scrollToPositionWithAnimation): Rename member.
(WebCore::ScrollAnimator::cancelAnimations): Ditto.
(WebCore::ScrollAnimator::willEndLiveResize): Ditto.
(WebCore::ScrollAnimator::didAddVerticalScrollbar): Ditto.
(WebCore::ScrollAnimator::didAddHorizontalScrollbar): Ditto.
* platform/ScrollAnimator.h: Ditto.
* platform/generic/ScrollAnimatorGeneric.cpp:
(WebCore::ScrollAnimatorGeneric::ScrollAnimatorGeneric): Eliminate ScrollAnimationSmooth.
(WebCore::ScrollAnimatorGeneric::scrollToPositionWithoutAnimation): Ditto.
(WebCore::ScrollAnimatorGeneric::didAddVerticalScrollbar): Ditto.
(WebCore::ScrollAnimatorGeneric::didAddHorizontalScrollbar): Ditto.
(WebCore::ScrollAnimatorGeneric::ensureSmoothScrollingAnimation): Deleted.
(WebCore::ScrollAnimatorGeneric::scroll): Deleted.
(WebCore::ScrollAnimatorGeneric::willEndLiveResize): Deleted.
* platform/generic/ScrollAnimatorGeneric.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (273732 => 273733)
--- trunk/Source/WebCore/ChangeLog 2021-03-02 17:16:24 UTC (rev 273732)
+++ trunk/Source/WebCore/ChangeLog 2021-03-02 17:57:53 UTC (rev 273733)
@@ -1,3 +1,43 @@
+2021-03-02 Martin Robinson <[email protected]>
+
+ Eliminate ScrollAnimatorGeneric::m_smoothAnimation
+ https://bugs.webkit.org/show_bug.cgi?id=222588
+
+ Reviewed by Simon Fraser.
+
+ No new tests. This change should not change behavior.
+
+ Eliminate the extra ScrollAnimationSmooth in ScrollAnimatorGeneric. The base
+ class already knows how to do scroll animations for programmatic scrolls,
+ so we can reuse that animation for doing ScrollAnimator::scroll(...). This
+ makes the code easier to understand and should simplify managing interactions
+ between the different animations in the future.
+
+ * platform/ScrollAnimator.cpp:
+ (WebCore::ScrollAnimator::ScrollAnimator): Renamed m_animationProgrammaticScroll
+ to m_scrollAnimation. The more generic name reflects the fact that it is also
+ used for doing scrolling from UI interaction now.
+ (WebCore::ScrollAnimator::scroll): Use the ScrollAnimationSmooth member to do
+ animated scrolls when necessary.
+ (WebCore::ScrollAnimator::scrollToPositionWithoutAnimation): Make sure the animation
+ is up to date with the current position when scrolling without it. This is
+ how ScrollAnimatorGeneric treated its ScrollAnimationSmooth.
+ (WebCore::ScrollAnimator::scrollToPositionWithAnimation): Rename member.
+ (WebCore::ScrollAnimator::cancelAnimations): Ditto.
+ (WebCore::ScrollAnimator::willEndLiveResize): Ditto.
+ (WebCore::ScrollAnimator::didAddVerticalScrollbar): Ditto.
+ (WebCore::ScrollAnimator::didAddHorizontalScrollbar): Ditto.
+ * platform/ScrollAnimator.h: Ditto.
+ * platform/generic/ScrollAnimatorGeneric.cpp:
+ (WebCore::ScrollAnimatorGeneric::ScrollAnimatorGeneric): Eliminate ScrollAnimationSmooth.
+ (WebCore::ScrollAnimatorGeneric::scrollToPositionWithoutAnimation): Ditto.
+ (WebCore::ScrollAnimatorGeneric::didAddVerticalScrollbar): Ditto.
+ (WebCore::ScrollAnimatorGeneric::didAddHorizontalScrollbar): Ditto.
+ (WebCore::ScrollAnimatorGeneric::ensureSmoothScrollingAnimation): Deleted.
+ (WebCore::ScrollAnimatorGeneric::scroll): Deleted.
+ (WebCore::ScrollAnimatorGeneric::willEndLiveResize): Deleted.
+ * platform/generic/ScrollAnimatorGeneric.h:
+
2021-03-02 Xabier Rodriguez Calvar <[email protected]>
[GStreamer] Error instead of asserting on the player in the source
Modified: trunk/Source/WebCore/platform/ScrollAnimator.cpp (273732 => 273733)
--- trunk/Source/WebCore/platform/ScrollAnimator.cpp 2021-03-02 17:16:24 UTC (rev 273732)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp 2021-03-02 17:57:53 UTC (rev 273733)
@@ -57,7 +57,7 @@
#if ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)
, m_scrollController(*this)
#endif
- , m_animationProgrammaticScroll(makeUnique<ScrollAnimationSmooth>(
+ , m_scrollAnimation(makeUnique<ScrollAnimationSmooth>(
[this]() -> ScrollExtents {
return { m_scrollableArea.minimumScrollPosition(), m_scrollableArea.maximumScrollPosition(), m_scrollableArea.visibleSize() };
},
@@ -99,6 +99,13 @@
UNUSED_PARAM(behavior);
#endif
+#if ENABLE(SMOOTH_SCROLLING) && !PLATFORM(IOS_FAMILY)
+ if (m_scrollableArea.scrollAnimatorEnabled()) {
+ m_scrollAnimation->setCurrentPosition(m_currentPosition);
+ return m_scrollAnimation->scroll(orientation, granularity, step, multiplier);
+ }
+#endif
+
return scrollToPositionWithoutAnimation(positionFromStep(orientation, step, multiplier));
}
@@ -117,6 +124,7 @@
if (adjustedPosition == currentPosition && adjustedPosition == scrollableArea().scrollPosition() && !scrollableArea().scrollOriginChanged())
return false;
+ m_scrollAnimation->setCurrentPosition(adjustedPosition);
m_currentPosition = adjustedPosition;
notifyPositionChanged(adjustedPosition - currentPosition);
updateActiveScrollSnapIndexForOffset();
@@ -134,8 +142,8 @@
if (!positionChanged && !scrollableArea().scrollOriginChanged())
return false;
- m_animationProgrammaticScroll->setCurrentPosition(m_currentPosition);
- m_animationProgrammaticScroll->scroll(newPosition);
+ m_scrollAnimation->setCurrentPosition(m_currentPosition);
+ m_scrollAnimation->scroll(newPosition);
scrollableArea().setScrollBehaviorStatus(ScrollBehaviorStatus::InNonNativeAnimation);
return true;
}
@@ -338,23 +346,23 @@
void ScrollAnimator::cancelAnimations()
{
#if !USE(REQUEST_ANIMATION_FRAME_TIMER)
- m_animationProgrammaticScroll->stop();
+ m_scrollAnimation->stop();
#endif
}
void ScrollAnimator::willEndLiveResize()
{
- m_animationProgrammaticScroll->updateVisibleLengths();
+ m_scrollAnimation->updateVisibleLengths();
}
void ScrollAnimator::didAddVerticalScrollbar(Scrollbar*)
{
- m_animationProgrammaticScroll->updateVisibleLengths();
+ m_scrollAnimation->updateVisibleLengths();
}
void ScrollAnimator::didAddHorizontalScrollbar(Scrollbar*)
{
- m_animationProgrammaticScroll->updateVisibleLengths();
+ m_scrollAnimation->updateVisibleLengths();
}
FloatPoint ScrollAnimator::adjustScrollOffsetForSnappingIfNeeded(const FloatPoint& offset, ScrollSnapPointSelectionMethod method)
Modified: trunk/Source/WebCore/platform/ScrollAnimator.h (273732 => 273733)
--- trunk/Source/WebCore/platform/ScrollAnimator.h 2021-03-02 17:16:24 UTC (rev 273732)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h 2021-03-02 17:57:53 UTC (rev 273733)
@@ -182,7 +182,7 @@
#endif
FloatPoint m_currentPosition;
- std::unique_ptr<ScrollAnimation> m_animationProgrammaticScroll;
+ std::unique_ptr<ScrollAnimation> m_scrollAnimation;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp (273732 => 273733)
--- trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp 2021-03-02 17:16:24 UTC (rev 273732)
+++ trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp 2021-03-02 17:57:53 UTC (rev 273733)
@@ -55,70 +55,17 @@
return { m_scrollableArea.minimumScrollPosition(), m_scrollableArea.maximumScrollPosition(), m_scrollableArea.visibleSize() };
},
[this](FloatPoint&& position) {
-#if ENABLE(SMOOTH_SCROLLING)
- if (m_smoothAnimation)
- m_smoothAnimation->setCurrentPosition(position);
-#endif
+ m_scrollAnimation->setCurrentPosition(position);
updatePosition(WTFMove(position));
});
-
-#if ENABLE(SMOOTH_SCROLLING)
- if (scrollableArea.scrollAnimatorEnabled())
- ensureSmoothScrollingAnimation();
-#endif
}
ScrollAnimatorGeneric::~ScrollAnimatorGeneric() = default;
-#if ENABLE(SMOOTH_SCROLLING)
-void ScrollAnimatorGeneric::ensureSmoothScrollingAnimation()
-{
- if (m_smoothAnimation) {
- if (!m_smoothAnimation->isActive())
- m_smoothAnimation->setCurrentPosition(m_currentPosition);
- return;
- }
-
- m_smoothAnimation = makeUnique<ScrollAnimationSmooth>(
- [this]() -> ScrollExtents {
- return { m_scrollableArea.minimumScrollPosition(), m_scrollableArea.maximumScrollPosition(), m_scrollableArea.visibleSize() };
- },
- m_currentPosition,
- [this](FloatPoint&& position) {
- updatePosition(WTFMove(position));
- },
- [this] {
- m_scrollableArea.setScrollBehaviorStatus(ScrollBehaviorStatus::NotInAnimation);
- });
-}
-#endif
-
-#if ENABLE(SMOOTH_SCROLLING)
-bool ScrollAnimatorGeneric::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier, ScrollBehavior behavior)
-{
- if (!m_scrollableArea.scrollAnimatorEnabled())
- return ScrollAnimator::scroll(orientation, granularity, step, multiplier, behavior);
-
- // This method doesn't do directional snapping, but our base class does. It will call into
- // ScrollAnimatorGeneric::scroll again with the snapped positions and ScrollBehavior::Default.
- if (behavior == ScrollBehavior::DoDirectionalSnapping)
- return ScrollAnimator::scroll(orientation, granularity, step, multiplier, behavior);
-
- ensureSmoothScrollingAnimation();
- return m_smoothAnimation->scroll(orientation, granularity, step, multiplier);
-}
-#endif
-
bool ScrollAnimatorGeneric::scrollToPositionWithoutAnimation(const FloatPoint& position, ScrollClamping clamping)
{
m_kineticAnimation->stop();
m_kineticAnimation->clearScrollHistory();
-
-#if ENABLE(SMOOTH_SCROLLING)
- if (m_smoothAnimation)
- m_smoothAnimation->setCurrentPosition(position);
-#endif
-
return ScrollAnimator::scrollToPositionWithoutAnimation(position, clamping);
}
@@ -143,14 +90,6 @@
return ScrollAnimator::handleWheelEvent(event);
}
-void ScrollAnimatorGeneric::willEndLiveResize()
-{
-#if ENABLE(SMOOTH_SCROLLING)
- if (m_smoothAnimation)
- m_smoothAnimation->updateVisibleLengths();
-#endif
-}
-
void ScrollAnimatorGeneric::updatePosition(FloatPoint&& position)
{
FloatSize delta = position - m_currentPosition;
@@ -161,10 +100,8 @@
void ScrollAnimatorGeneric::didAddVerticalScrollbar(Scrollbar* scrollbar)
{
-#if ENABLE(SMOOTH_SCROLLING)
- if (m_smoothAnimation)
- m_smoothAnimation->updateVisibleLengths();
-#endif
+ ScrollAnimator::didAddVerticalScrollbar(scrollbar);
+
if (!scrollbar->isOverlayScrollbar())
return;
m_verticalOverlayScrollbar = scrollbar;
@@ -176,10 +113,8 @@
void ScrollAnimatorGeneric::didAddHorizontalScrollbar(Scrollbar* scrollbar)
{
-#if ENABLE(SMOOTH_SCROLLING)
- if (m_smoothAnimation)
- m_smoothAnimation->updateVisibleLengths();
-#endif
+ ScrollAnimator::didAddHorizontalScrollbar(scrollbar);
+
if (!scrollbar->isOverlayScrollbar())
return;
m_horizontalOverlayScrollbar = scrollbar;
Modified: trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.h (273732 => 273733)
--- trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.h 2021-03-02 17:16:24 UTC (rev 273732)
+++ trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.h 2021-03-02 17:57:53 UTC (rev 273733)
@@ -44,11 +44,7 @@
virtual ~ScrollAnimatorGeneric();
private:
-#if ENABLE(SMOOTH_SCROLLING)
- bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier, ScrollBehavior) override;
-#endif
bool scrollToPositionWithoutAnimation(const FloatPoint&, ScrollClamping) override;
- void willEndLiveResize() override;
bool handleWheelEvent(const PlatformWheelEvent&) override;
@@ -72,11 +68,6 @@
void hideOverlayScrollbars();
void updateOverlayScrollbarsOpacity();
-#if ENABLE(SMOOTH_SCROLLING)
- void ensureSmoothScrollingAnimation();
-
- std::unique_ptr<ScrollAnimation> m_smoothAnimation;
-#endif
std::unique_ptr<ScrollAnimationKinetic> m_kineticAnimation;
Scrollbar* m_horizontalOverlayScrollbar { nullptr };
Scrollbar* m_verticalOverlayScrollbar { nullptr };