WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-230720-20210923150241.patch (text/plain), 35.19 KB, created by
Simon Fraser (smfr)
on 2021-09-23 15:02:42 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Simon Fraser (smfr)
Created:
2021-09-23 15:02:42 PDT
Size:
35.19 KB
patch
obsolete
>Subversion Revision: 282973 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 95313e901f5927fc4f83261254c252749962f4ba..8539727d74251511416ea277206c03ef27c7c40b 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,79 @@ >+2021-09-23 Simon Fraser <simon.fraser@apple.com> >+ >+ Move the ScrollAnimationSmooth from ScrollAnimator into ScrollingEffectsController >+ https://bugs.webkit.org/show_bug.cgi?id=230720 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ ScrollingEffectsController is where all the ScrollAnimations will live. The first >+ step is to move ScrollAnimator's m_scrollAnimation there; this is used for >+ keyboard scrolling, and CSS smooth scrolling. >+ >+ ScrollingEffectsController becomes a ScrollAnimationClient (and ScrollAnimator stops >+ being one), so needs a little bit more glue code. >+ >+ Add type traits for ScrollAnimator subclasses because we need to downcast<> them >+ here and in future patches. >+ >+ Move some code from ScrollAnimatorMac into ScrollAnimator since it's not platform >+ specific. >+ >+ * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h: >+ * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm: >+ (WebCore::ScrollingTreeScrollingNodeDelegateMac::immediateScrollOnAxis): Deleted. >+ * platform/ScrollAnimation.h: >+ (WebCore::ScrollAnimation::ScrollAnimation): >+ (WebCore::ScrollAnimation::type const): >+ * platform/ScrollAnimationKinetic.cpp: >+ (WebCore::ScrollAnimationKinetic::ScrollAnimationKinetic): >+ * platform/ScrollAnimationKinetic.h: >+ * platform/ScrollAnimationMomentum.cpp: >+ (WebCore::ScrollAnimationMomentum::ScrollAnimationMomentum): >+ * platform/ScrollAnimationMomentum.h: >+ * platform/ScrollAnimationSmooth.cpp: >+ (WebCore::ScrollAnimationSmooth::ScrollAnimationSmooth): >+ * platform/ScrollAnimationSmooth.h: >+ * platform/ScrollAnimator.cpp: >+ (WebCore::ScrollAnimator::ScrollAnimator): >+ (WebCore::ScrollAnimator::scroll): >+ (WebCore::ScrollAnimator::scrollToPositionWithoutAnimation): >+ (WebCore::ScrollAnimator::scrollToPositionWithAnimation): >+ (WebCore::ScrollAnimator::retargetRunningAnimation): >+ (WebCore::ScrollAnimator::setScrollBehaviorStatus): >+ (WebCore::ScrollAnimator::scrollBehaviorStatus const): >+ (WebCore::ScrollAnimator::adjustScrollPositionToBoundsIfNecessary): >+ (WebCore::ScrollAnimator::adjustScrollPositionIfNecessary const): >+ (WebCore::ScrollAnimator::immediateScrollByWithoutContentEdgeConstraints): >+ (WebCore::ScrollAnimator::immediateScrollBy): >+ (WebCore::ScrollAnimator::cancelAnimations): >+ (WebCore::ScrollAnimator::contentsSizeChanged): >+ (WebCore::ScrollAnimator::immediateScrollOnAxis): Deleted. >+ (WebCore::ScrollAnimator::contentsSizeChanged const): Deleted. >+ (WebCore::ScrollAnimator::scrollAnimationDidUpdate): Deleted. >+ (WebCore::ScrollAnimator::scrollAnimationDidEnd): Deleted. >+ (WebCore::ScrollAnimator::scrollExtentsForAnimation): Deleted. >+ * platform/ScrollAnimator.h: >+ * platform/ScrollingEffectsController.cpp: >+ (WebCore::ScrollingEffectsController::startAnimatedScrollToDestination): >+ (WebCore::ScrollingEffectsController::regargetAnimatedScroll): >+ (WebCore::ScrollingEffectsController::stopAnimatedScroll): >+ (WebCore::ScrollingEffectsController::contentsSizeChanged): >+ (WebCore::ScrollingEffectsController::activeScrollSnapIndexForAxis const): >+ (WebCore::ScrollingEffectsController::scrollToOffsetForAnimation): >+ (WebCore::ScrollingEffectsController::scrollAnimationDidUpdate): >+ (WebCore::ScrollingEffectsController::scrollAnimationDidEnd): >+ (WebCore::ScrollingEffectsController::scrollExtentsForAnimation): >+ * platform/ScrollingEffectsController.h: >+ (WebCore::ScrollingEffectsControllerClient::rubberBandingStateChanged): >+ * platform/mac/ScrollAnimatorMac.h: >+ * platform/mac/ScrollAnimatorMac.mm: >+ (WebCore::ScrollAnimatorMac::adjustScrollPositionIfNecessary const): Deleted. >+ (WebCore::ScrollAnimatorMac::adjustScrollPositionToBoundsIfNecessary): Deleted. >+ (WebCore::ScrollAnimatorMac::immediateScrollByWithoutContentEdgeConstraints): Deleted. >+ (WebCore::ScrollAnimatorMac::immediateScrollBy): Deleted. >+ * platform/mac/ScrollingEffectsController.mm: >+ (WebCore::ScrollingEffectsController::updateScrollSnapAnimatingState): >+ > 2021-09-23 Simon Fraser <simon.fraser@apple.com> > > Unify more media-related WebCore source files >diff --git a/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h b/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h >index d86c9751b4fba89fa25c0e92063eed7233aa3e01..1b4fefce5a90bce938bf2abf12d83ea7c5bd732a 100644 >--- a/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h >+++ b/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h >@@ -82,6 +82,9 @@ private: > RectEdges<bool> edgePinnedState() const final; > bool allowsHorizontalScrolling() const final; > bool allowsVerticalScrolling() const final; >+ void setScrollBehaviorStatus(ScrollBehaviorStatus status) final { m_scrollBehaviorStatus = status; } >+ ScrollBehaviorStatus scrollBehaviorStatus() const final { return m_scrollBehaviorStatus; } >+ > bool shouldRubberBandInDirection(ScrollDirection) const final; > void immediateScrollBy(const FloatSize&) final; > void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) final; >@@ -93,7 +96,6 @@ private: > void scrollControllerAnimationTimerFired(); > > FloatPoint scrollOffset() const final; >- void immediateScrollOnAxis(ScrollEventAxis, float delta) final; > float pageScaleFactor() const final; > void willStartScrollSnapAnimation() final; > void didStopScrollSnapAnimation() final; >@@ -108,6 +110,7 @@ private: > > std::unique_ptr<RunLoop::Timer<ScrollingTreeScrollingNodeDelegateMac>> m_scrollControllerAnimationTimer; > >+ ScrollBehaviorStatus m_scrollBehaviorStatus { ScrollBehaviorStatus::NotInAnimation }; > bool m_inMomentumPhase { false }; > }; > >diff --git a/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm b/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm >index f71fd47d8c240b97b7911eb2cf3a1d32f52b148c..b8ffc734382870260698f8b796f65402489f4913 100644 >--- a/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm >+++ b/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm >@@ -379,18 +379,6 @@ FloatPoint ScrollingTreeScrollingNodeDelegateMac::scrollOffset() const > return ScrollableArea::scrollOffsetFromPosition(currentScrollPosition(), scrollOrigin()); > } > >-void ScrollingTreeScrollingNodeDelegateMac::immediateScrollOnAxis(ScrollEventAxis axis, float delta) >-{ >- const FloatPoint& scrollPosition = currentScrollPosition(); >- FloatPoint change; >- if (axis == ScrollEventAxis::Horizontal) >- change = FloatPoint(scrollPosition.x() + delta, scrollPosition.y()); >- else >- change = FloatPoint(scrollPosition.x(), scrollPosition.y() + delta); >- >- immediateScrollBy(change - scrollPosition); >-} >- > float ScrollingTreeScrollingNodeDelegateMac::pageScaleFactor() const > { > // FIXME: What should this return for non-root frames, and overflow? >diff --git a/Source/WebCore/platform/ScrollAnimation.h b/Source/WebCore/platform/ScrollAnimation.h >index 2137ed4b2916f9f5cc242e3329a1fc807a54723c..5c64ad7e27581a74060732be9da70f9c5947f36d 100644 >--- a/Source/WebCore/platform/ScrollAnimation.h >+++ b/Source/WebCore/platform/ScrollAnimation.h >@@ -47,10 +47,19 @@ public: > class ScrollAnimation { > WTF_MAKE_FAST_ALLOCATED; > public: >- ScrollAnimation(ScrollAnimationClient& client) >+ enum class Type { >+ Smooth, >+ Kinetic, >+ Momentum, >+ }; >+ >+ ScrollAnimation(Type animationType, ScrollAnimationClient& client) > : m_client(client) >+ , m_animationType(animationType) > { } > virtual ~ScrollAnimation() = default; >+ >+ Type type() const { return m_animationType; } > > virtual bool retargetActiveAnimation(const FloatPoint& newDestinationOffset) = 0; > virtual void stop() = 0; >@@ -62,6 +71,12 @@ public: > > protected: > ScrollAnimationClient& m_client; >+ const Type m_animationType; > }; > > } // namespace WebCore >+ >+#define SPECIALIZE_TYPE_TRAITS_SCROLL_ANIMATION(ToValueTypeName, predicate) \ >+SPECIALIZE_TYPE_TRAITS_BEGIN(ToValueTypeName) \ >+ static bool isType(const WebCore::ScrollAnimation& scrollAnimation) { return scrollAnimation.predicate; } \ >+SPECIALIZE_TYPE_TRAITS_END() >diff --git a/Source/WebCore/platform/ScrollAnimationKinetic.cpp b/Source/WebCore/platform/ScrollAnimationKinetic.cpp >index ba257da346808c43bb9c7595acd6133c82ea3d64..a9b6654a6bb66595d2e357630d544f4dbbb85ca3 100644 >--- a/Source/WebCore/platform/ScrollAnimationKinetic.cpp >+++ b/Source/WebCore/platform/ScrollAnimationKinetic.cpp >@@ -114,7 +114,7 @@ bool ScrollAnimationKinetic::PerAxisData::animateScroll(Seconds timeDelta) > } > > ScrollAnimationKinetic::ScrollAnimationKinetic(ScrollAnimationClient& client) >- : ScrollAnimation(client) >+ : ScrollAnimation(Type::Kinetic, client) > , m_animationTimer(RunLoop::current(), this, &ScrollAnimationKinetic::animationTimerFired) > { > #if USE(GLIB_EVENT_LOOP) >diff --git a/Source/WebCore/platform/ScrollAnimationKinetic.h b/Source/WebCore/platform/ScrollAnimationKinetic.h >index 62a7461aea5b046e0f61b840db132333a6c526b0..13ce32964bdaff69f445d17bf12811bc0e12fe7a 100644 >--- a/Source/WebCore/platform/ScrollAnimationKinetic.h >+++ b/Source/WebCore/platform/ScrollAnimationKinetic.h >@@ -86,3 +86,5 @@ private: > }; > > } // namespace WebCore >+ >+SPECIALIZE_TYPE_TRAITS_SCROLL_ANIMATION(WebCore::ScrollAnimationKinetic, type() == WebCore::ScrollAnimation::Type::Kinetic) >diff --git a/Source/WebCore/platform/ScrollAnimationMomentum.cpp b/Source/WebCore/platform/ScrollAnimationMomentum.cpp >index 4a479f8c811200049135ed77d3e70c21d2cce550..fa57369154a387942930d6f8355def1c7fed073e 100644 >--- a/Source/WebCore/platform/ScrollAnimationMomentum.cpp >+++ b/Source/WebCore/platform/ScrollAnimationMomentum.cpp >@@ -32,7 +32,7 @@ > namespace WebCore { > > ScrollAnimationMomentum::ScrollAnimationMomentum(ScrollAnimationClient& client) >- : ScrollAnimation(client) >+ : ScrollAnimation(Type::Momentum, client) > { > } > >diff --git a/Source/WebCore/platform/ScrollAnimationMomentum.h b/Source/WebCore/platform/ScrollAnimationMomentum.h >index 6e6a6616fcd95652e839b57c9fe064bdc1c7b3e6..6642dcb546efd90939b8ff52180fb039093db4ed 100644 >--- a/Source/WebCore/platform/ScrollAnimationMomentum.h >+++ b/Source/WebCore/platform/ScrollAnimationMomentum.h >@@ -51,3 +51,5 @@ private: > }; > > } // namespace WebCore >+ >+SPECIALIZE_TYPE_TRAITS_SCROLL_ANIMATION(WebCore::ScrollAnimationMomentum, type() == WebCore::ScrollAnimation::Type::Momentum) >diff --git a/Source/WebCore/platform/ScrollAnimationSmooth.cpp b/Source/WebCore/platform/ScrollAnimationSmooth.cpp >index 70e94a9c6f4cdb24efaa82e18c61aa09d5bce279..b06f2f24ea57512504f7221d0b9b22ba820932b5 100644 >--- a/Source/WebCore/platform/ScrollAnimationSmooth.cpp >+++ b/Source/WebCore/platform/ScrollAnimationSmooth.cpp >@@ -45,7 +45,7 @@ static constexpr Seconds minimumTimerInterval { 1_ms }; > static const Seconds maxAnimationDuration { 200_ms }; > > ScrollAnimationSmooth::ScrollAnimationSmooth(ScrollAnimationClient& client) >- : ScrollAnimation(client) >+ : ScrollAnimation(Type::Smooth, client) > , m_animationTimer(RunLoop::current(), this, &ScrollAnimationSmooth::animationTimerFired) > , m_easeInOutTimingFunction(CubicBezierTimingFunction::create(CubicBezierTimingFunction::TimingFunctionPreset::EaseInOut)) > { >diff --git a/Source/WebCore/platform/ScrollAnimationSmooth.h b/Source/WebCore/platform/ScrollAnimationSmooth.h >index 5afdc13d79cf87c39675063d72630316d3141c53..1d234a292d7766988317c180fa5495d655dbfa82 100644 >--- a/Source/WebCore/platform/ScrollAnimationSmooth.h >+++ b/Source/WebCore/platform/ScrollAnimationSmooth.h >@@ -73,3 +73,4 @@ private: > > } // namespace WebCore > >+SPECIALIZE_TYPE_TRAITS_SCROLL_ANIMATION(WebCore::ScrollAnimationSmooth, type() == WebCore::ScrollAnimation::Type::Smooth) >diff --git a/Source/WebCore/platform/ScrollAnimator.cpp b/Source/WebCore/platform/ScrollAnimator.cpp >index c904ce1aac7fe77dbc4cc916edb47e3e7ddf6028..0f83c82ecd0cace83df9102f5bab55d6ba0638c5 100644 >--- a/Source/WebCore/platform/ScrollAnimator.cpp >+++ b/Source/WebCore/platform/ScrollAnimator.cpp >@@ -36,7 +36,6 @@ > #include "KeyboardScrollingAnimator.h" > #include "LayoutSize.h" > #include "PlatformWheelEvent.h" >-#include "ScrollAnimationSmooth.h" > #include "ScrollableArea.h" > #include "ScrollbarsController.h" > #include "ScrollingEffectsController.h" >@@ -55,7 +54,6 @@ ScrollAnimator::ScrollAnimator(ScrollableArea& scrollableArea) > : m_scrollableArea(scrollableArea) > , m_scrollController(*this) > , m_scrollControllerAnimationTimer(*this, &ScrollAnimator::scrollControllerAnimationTimerFired) >- , m_scrollAnimation(makeUnique<ScrollAnimationSmooth>(*this)) > , m_keyboardScrollingAnimator(makeUnique<KeyboardScrollingAnimator>(*this, m_scrollController)) > { > } >@@ -93,7 +91,7 @@ bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity > auto startOffset = offsetFromPosition(m_currentPosition); > auto extents = scrollExtents(); > auto destinationOffset = (startOffset + delta).constrainedBetween(extents.minimumScrollOffset(), extents.maximumScrollOffset()); >- return m_scrollAnimation->startAnimatedScrollToDestination(startOffset, destinationOffset); >+ return m_scrollController.startAnimatedScrollToDestination(startOffset, destinationOffset); > } > > return scrollToPositionWithoutAnimation(currentPosition() + delta); >@@ -109,7 +107,7 @@ bool ScrollAnimator::scrollToPositionWithoutAnimation(const FloatPoint& position > if (adjustedPosition == currentPosition && adjustedPosition == scrollableArea().scrollPosition() && !scrollableArea().scrollOriginChanged()) > return false; > >- m_scrollAnimation->stop(); >+ m_scrollController.stopAnimatedScroll(); > > setCurrentPosition(adjustedPosition, NotifyScrollableArea::Yes); > return true; >@@ -121,16 +119,15 @@ bool ScrollAnimator::scrollToPositionWithAnimation(const FloatPoint& newPosition > if (!positionChanged && !scrollableArea().scrollOriginChanged()) > return false; > >- m_scrollAnimation->startAnimatedScrollToDestination(offsetFromPosition(m_currentPosition), offsetFromPosition(newPosition)); >- scrollableArea().setScrollBehaviorStatus(ScrollBehaviorStatus::InNonNativeAnimation); >+ m_scrollController.startAnimatedScrollToDestination(offsetFromPosition(m_currentPosition), offsetFromPosition(newPosition)); >+ setScrollBehaviorStatus(ScrollBehaviorStatus::InNonNativeAnimation); > return true; > } > > void ScrollAnimator::retargetRunningAnimation(const FloatPoint& newPosition) > { > ASSERT(scrollableArea().currentScrollBehaviorStatus() == ScrollBehaviorStatus::InNonNativeAnimation); >- ASSERT(m_scrollAnimation->isActive()); >- m_scrollAnimation->retargetActiveAnimation(newPosition); >+ m_scrollController.regargetAnimatedScroll(offsetFromPosition(newPosition)); > } > > FloatPoint ScrollAnimator::offsetFromPosition(const FloatPoint& position) const >@@ -290,6 +287,16 @@ bool ScrollAnimator::allowsVerticalScrolling() const > return m_scrollableArea.allowsVerticalScrolling(); > } > >+void ScrollAnimator::setScrollBehaviorStatus(ScrollBehaviorStatus status) >+{ >+ m_scrollableArea.setScrollBehaviorStatus(status); >+} >+ >+ScrollBehaviorStatus ScrollAnimator::scrollBehaviorStatus() const >+{ >+ return m_scrollableArea.currentScrollBehaviorStatus(); >+} >+ > #if HAVE(RUBBER_BANDING) > IntSize ScrollAnimator::stretchAmount() const > { >@@ -313,16 +320,41 @@ bool ScrollAnimator::isPinnedForScrollDelta(const FloatSize& delta) const > } > #endif > >-// FIXME: Unused. >-void ScrollAnimator::immediateScrollOnAxis(ScrollEventAxis axis, float delta) >+void ScrollAnimator::adjustScrollPositionToBoundsIfNecessary() > { >- FloatSize deltaSize; >- if (axis == ScrollEventAxis::Horizontal) >- deltaSize.setWidth(delta); >- else >- deltaSize.setHeight(delta); >+ bool currentlyConstrainsToContentEdge = m_scrollableArea.constrainsScrollingToContentEdge(); >+ m_scrollableArea.setConstrainsScrollingToContentEdge(true); >+ >+ auto currentScrollPosition = m_scrollableArea.scrollPosition(); >+ auto constrainedPosition = m_scrollableArea.constrainScrollPosition(currentScrollPosition); >+ immediateScrollBy(constrainedPosition - currentScrollPosition); > >- scrollToPositionWithoutAnimation(currentPosition() + deltaSize); >+ m_scrollableArea.setConstrainsScrollingToContentEdge(currentlyConstrainsToContentEdge); >+} >+ >+FloatPoint ScrollAnimator::adjustScrollPositionIfNecessary(const FloatPoint& position) const >+{ >+ if (!m_scrollableArea.constrainsScrollingToContentEdge()) >+ return position; >+ >+ return m_scrollableArea.constrainScrollPosition(ScrollPosition(position)); >+} >+ >+void ScrollAnimator::immediateScrollByWithoutContentEdgeConstraints(const FloatSize& delta) >+{ >+ m_scrollableArea.setConstrainsScrollingToContentEdge(false); >+ immediateScrollBy(delta); >+ m_scrollableArea.setConstrainsScrollingToContentEdge(true); >+} >+ >+void ScrollAnimator::immediateScrollBy(const FloatSize& delta) >+{ >+ FloatPoint currentPosition = this->currentPosition(); >+ FloatPoint newPosition = adjustScrollPositionIfNecessary(currentPosition + delta); >+ if (newPosition == currentPosition) >+ return; >+ >+ setCurrentPosition(newPosition, NotifyScrollableArea::Yes); > } > > ScrollExtents ScrollAnimator::scrollExtents() const >@@ -385,13 +417,13 @@ void ScrollAnimator::removeWheelEventTestCompletionDeferralForReason(WheelEventT > > void ScrollAnimator::cancelAnimations() > { >- m_scrollAnimation->stop(); >+ m_scrollController.stopAnimatedScroll(); > m_scrollableArea.scrollbarsController().cancelAnimations(); > } > >-void ScrollAnimator::contentsSizeChanged() const >+void ScrollAnimator::contentsSizeChanged() > { >- m_scrollAnimation->updateScrollExtents(); >+ m_scrollController.contentsSizeChanged(); > } > > FloatPoint ScrollAnimator::scrollOffsetAdjustedForSnapping(const FloatPoint& offset, ScrollSnapPointSelectionMethod method) const >@@ -423,20 +455,4 @@ float ScrollAnimator::scrollOffsetAdjustedForSnapping(ScrollEventAxis axis, cons > return m_scrollController.adjustedScrollDestination(axis, newOffset, velocityInScrollAxis, originalOffset); > } > >-void ScrollAnimator::scrollAnimationDidUpdate(ScrollAnimation&, const FloatPoint& currentOffset) >-{ >- setCurrentPosition(positionFromOffset(currentOffset), NotifyScrollableArea::Yes); >-} >- >-void ScrollAnimator::scrollAnimationDidEnd(ScrollAnimation&) >-{ >- m_scrollableArea.setScrollBehaviorStatus(ScrollBehaviorStatus::NotInAnimation); >-} >- >-ScrollExtents ScrollAnimator::scrollExtentsForAnimation(ScrollAnimation&) >-{ >- return scrollExtents(); >-} >- >- > } // namespace WebCore >diff --git a/Source/WebCore/platform/ScrollAnimator.h b/Source/WebCore/platform/ScrollAnimator.h >index b6a0bdebdc175d792c8e1ce0ca954ee35ae00e48..b3afaa85ebf89dccbc2566e6f2aee1c1ff1965ff 100644 >--- a/Source/WebCore/platform/ScrollAnimator.h >+++ b/Source/WebCore/platform/ScrollAnimator.h >@@ -33,7 +33,6 @@ > > #include "FloatPoint.h" > #include "PlatformWheelEvent.h" >-#include "ScrollAnimation.h" > #include "ScrollingEffectsController.h" > #include "Timer.h" > #include "WheelEventTestMonitor.h" >@@ -52,7 +51,7 @@ class WheelEventTestMonitor; > > class ScrollingEffectsControllerTimer; > >-class ScrollAnimator : private ScrollingEffectsControllerClient, public ScrollAnimationClient { >+class ScrollAnimator : private ScrollingEffectsControllerClient { > WTF_MAKE_FAST_ALLOCATED; > public: > static std::unique_ptr<ScrollAnimator> create(ScrollableArea&); >@@ -78,7 +77,7 @@ public: > virtual bool scrollToPositionWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped); > bool scrollToPositionWithAnimation(const FloatPoint&); > >- void retargetRunningAnimation(const FloatPoint&); >+ void retargetRunningAnimation(const FloatPoint& newPosition); > > virtual bool handleWheelEvent(const PlatformWheelEvent&); > >@@ -98,7 +97,7 @@ public: > virtual bool isRubberBandInProgress() const { return false; } > virtual bool isScrollSnapInProgress() const { return false; } > >- void contentsSizeChanged() const; >+ void contentsSizeChanged(); > > enum NotifyScrollableArea : bool { > No, Yes >@@ -122,9 +121,6 @@ public: > protected: > virtual bool platformAllowsScrollAnimation() const { return true; } > >- // ScrollAnimationClient >- void scrollAnimationDidUpdate(ScrollAnimation&, const FloatPoint& currentOffset) override; >- > private: > void notifyPositionChanged(const FloatSize& delta); > >@@ -134,6 +130,7 @@ private: > FloatPoint offsetFromPosition(const FloatPoint& position) const; > FloatPoint positionFromOffset(const FloatPoint& offset) const; > >+ FloatPoint adjustScrollPositionIfNecessary(const FloatPoint&) const; > > // ScrollingEffectsControllerClient. > std::unique_ptr<ScrollingEffectsControllerTimer> createTimer(Function<void()>&&) final; >@@ -141,13 +138,19 @@ private: > void stopAnimationCallback(ScrollingEffectsController&) final; > > FloatPoint scrollOffset() const final; >- void immediateScrollOnAxis(ScrollEventAxis, float delta) final; > float pageScaleFactor() const final; > ScrollExtents scrollExtents() const final; > > bool allowsHorizontalScrolling() const final; > bool allowsVerticalScrolling() const final; > >+ void setScrollBehaviorStatus(ScrollBehaviorStatus) final; >+ ScrollBehaviorStatus scrollBehaviorStatus() const final; >+ >+ void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) final; >+ void immediateScrollBy(const FloatSize&) final; >+ void adjustScrollPositionToBoundsIfNecessary() final; >+ > #if HAVE(RUBBER_BANDING) > IntSize stretchAmount() const final; > RectEdges<bool> edgePinnedState() const final; >@@ -159,10 +162,6 @@ private: > void removeWheelEventTestCompletionDeferralForReason(WheelEventTestMonitor::ScrollableAreaIdentifier, WheelEventTestMonitor::DeferReason) const final; > #endif > >- // ScrollAnimationClient >- void scrollAnimationDidEnd(ScrollAnimation&) final; >- ScrollExtents scrollExtentsForAnimation(ScrollAnimation&) final; >- > static FloatSize deltaFromStep(ScrollbarOrientation, float step, float multiplier); > > protected: >@@ -172,7 +171,6 @@ protected: > Timer m_scrollControllerAnimationTimer; > FloatPoint m_currentPosition; > >- std::unique_ptr<ScrollAnimationSmooth> m_scrollAnimation; > std::unique_ptr<KeyboardScrollingAnimator> m_keyboardScrollingAnimator; > }; > >diff --git a/Source/WebCore/platform/ScrollingEffectsController.cpp b/Source/WebCore/platform/ScrollingEffectsController.cpp >index fa24f227d5391f3d30c9c51fcff7f6c4fe0ab5fa..8e24d3b61b924f5546b261909bcd330efddf4f8b 100644 >--- a/Source/WebCore/platform/ScrollingEffectsController.cpp >+++ b/Source/WebCore/platform/ScrollingEffectsController.cpp >@@ -30,6 +30,7 @@ > #include "LayoutSize.h" > #include "Logging.h" > #include "PlatformWheelEvent.h" >+#include "ScrollAnimationSmooth.h" > #include "ScrollableArea.h" > #include "WheelEventTestMonitor.h" > #include <wtf/text/TextStream.h> >@@ -76,6 +77,30 @@ void ScrollingEffectsController::stopKeyboardScrolling() > setIsAnimatingKeyboardScrolling(false); > } > >+bool ScrollingEffectsController::startAnimatedScrollToDestination(FloatPoint startOffset, FloatPoint destinationOffset) >+{ >+ if (m_currentAnimation) >+ m_currentAnimation->stop(); >+ >+ m_currentAnimation = makeUnique<ScrollAnimationSmooth>(*this); >+ return downcast<ScrollAnimationSmooth>(*m_currentAnimation).startAnimatedScrollToDestination(startOffset, destinationOffset); >+} >+ >+bool ScrollingEffectsController::regargetAnimatedScroll(FloatPoint newDestinationOffset) >+{ >+ if (!is<ScrollAnimationSmooth>(m_currentAnimation.get())) >+ return false; >+ >+ ASSERT(m_currentAnimation->isActive()); >+ return downcast<ScrollAnimationSmooth>(*m_currentAnimation).retargetActiveAnimation(newDestinationOffset); >+} >+ >+void ScrollingEffectsController::stopAnimatedScroll() >+{ >+ if (m_currentAnimation) >+ m_currentAnimation->stop(); >+} >+ > void ScrollingEffectsController::setIsAnimatingRubberBand(bool isAnimatingRubberBand) > { > if (isAnimatingRubberBand == m_isAnimatingRubberBand) >@@ -103,6 +128,12 @@ void ScrollingEffectsController::setIsAnimatingKeyboardScrolling(bool isAnimatin > startOrStopAnimationCallbacks(); > } > >+void ScrollingEffectsController::contentsSizeChanged() >+{ >+ if (m_currentAnimation) >+ m_currentAnimation->updateScrollExtents(); >+} >+ > bool ScrollingEffectsController::usesScrollSnap() const > { > return !!m_scrollSnapState; >@@ -136,6 +167,7 @@ std::optional<unsigned> ScrollingEffectsController::activeScrollSnapIndexForAxis > { > if (!usesScrollSnap()) > return std::nullopt; >+ > return m_scrollSnapState->activeSnapIndexForAxis(axis); > } > >@@ -184,6 +216,28 @@ void ScrollingEffectsController::updateKeyboardScrollingAnimatingState(Monotonic > m_client.keyboardScrollingAnimator()->updateKeyboardScrollPosition(currentTime); > } > >+void ScrollingEffectsController::scrollToOffsetForAnimation(const FloatPoint& scrollOffset) >+{ >+ auto currentOffset = m_client.scrollOffset(); >+ auto scrollDelta = scrollOffset - currentOffset; >+ m_client.immediateScrollBy(scrollDelta); >+} >+ >+void ScrollingEffectsController::scrollAnimationDidUpdate(ScrollAnimation&, const FloatPoint& currentOffset) >+{ >+ scrollToOffsetForAnimation(currentOffset); >+} >+ >+void ScrollingEffectsController::scrollAnimationDidEnd(ScrollAnimation&) >+{ >+ m_client.setScrollBehaviorStatus(ScrollBehaviorStatus::NotInAnimation); >+} >+ >+ScrollExtents ScrollingEffectsController::scrollExtentsForAnimation(ScrollAnimation&) >+{ >+ return m_client.scrollExtents(); >+} >+ > // Currently, only Mac supports momentum srolling-based scrollsnapping and rubber banding > // so all of these methods are a noop on non-Mac platforms. > #if !PLATFORM(MAC) >diff --git a/Source/WebCore/platform/ScrollingEffectsController.h b/Source/WebCore/platform/ScrollingEffectsController.h >index a7146dbbbcfa11a1ea866665796005ee031b5556..7d1e4e8fe765cb66b473a59f90cc2741d35c28cd 100644 >--- a/Source/WebCore/platform/ScrollingEffectsController.h >+++ b/Source/WebCore/platform/ScrollingEffectsController.h >@@ -29,6 +29,7 @@ > #include "FloatSize.h" > > #include "RectEdges.h" >+#include "ScrollAnimation.h" > #include "ScrollSnapAnimatorState.h" > #include "ScrollSnapOffsetsInfo.h" > #include "ScrollTypes.h" >@@ -80,6 +81,17 @@ public: > virtual bool allowsHorizontalScrolling() const = 0; > virtual bool allowsVerticalScrolling() const = 0; > >+ // FIXME: Maybe ScrollBehaviorStatus should be stored on ScrollingEffectsController. >+ virtual void setScrollBehaviorStatus(ScrollBehaviorStatus) = 0; >+ virtual ScrollBehaviorStatus scrollBehaviorStatus() const = 0; >+ >+ virtual void immediateScrollBy(const FloatSize&) = 0; >+ virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) = 0; >+ >+ // If the current scroll position is within the overhang area, this function will cause >+ // the page to scroll to the nearest boundary point. >+ virtual void adjustScrollPositionToBoundsIfNecessary() = 0; >+ > #if HAVE(RUBBER_BANDING) > virtual bool allowsHorizontalStretching(const PlatformWheelEvent&) const = 0; > virtual bool allowsVerticalStretching(const PlatformWheelEvent&) const = 0; >@@ -92,41 +104,37 @@ public: > virtual bool shouldRubberBandInDirection(ScrollDirection) const = 0; > > // FIXME: use ScrollClamping to collapse these to one. >- virtual void immediateScrollBy(const FloatSize&) = 0; >- virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) = 0; >- > virtual void willStartRubberBandSnapAnimation() { } > virtual void didStopRubberbandSnapAnimation() { } > > virtual void rubberBandingStateChanged(bool) { } >- >- // If the current scroll position is within the overhang area, this function will cause >- // the page to scroll to the nearest boundary point. >- virtual void adjustScrollPositionToBoundsIfNecessary() = 0; > #endif > > virtual void deferWheelEventTestCompletionForReason(WheelEventTestMonitor::ScrollableAreaIdentifier, WheelEventTestMonitor::DeferReason) const { /* Do nothing */ } > virtual void removeWheelEventTestCompletionDeferralForReason(WheelEventTestMonitor::ScrollableAreaIdentifier, WheelEventTestMonitor::DeferReason) const { /* Do nothing */ } > > virtual FloatPoint scrollOffset() const = 0; >- virtual void immediateScrollOnAxis(ScrollEventAxis, float delta) = 0; > virtual void willStartScrollSnapAnimation() { } > virtual void didStopScrollSnapAnimation() { } > virtual float pageScaleFactor() const = 0; > virtual ScrollExtents scrollExtents() const = 0; > }; > >-class ScrollingEffectsController { >+class ScrollingEffectsController : public ScrollAnimationClient { > WTF_MAKE_NONCOPYABLE(ScrollingEffectsController); > > public: > explicit ScrollingEffectsController(ScrollingEffectsControllerClient&); >- ~ScrollingEffectsController(); >+ virtual ~ScrollingEffectsController(); > > bool usesScrollSnap() const; > void stopAllTimers(); > void scrollPositionChanged(); > >+ bool startAnimatedScrollToDestination(FloatPoint startOffset, FloatPoint destinationOffset); >+ bool regargetAnimatedScroll(FloatPoint newDestinationOffset); >+ void stopAnimatedScroll(); >+ > void beginKeyboardScrolling(); > void stopKeyboardScrolling(); > >@@ -134,6 +142,8 @@ public: > void animationCallback(MonotonicTime); > > void updateGestureInProgressState(const PlatformWheelEvent&); >+ >+ void contentsSizeChanged(); > > void setSnapOffsetsInfo(const LayoutScrollSnapOffsetsInfo&); > const LayoutScrollSnapOffsetsInfo* snapOffsetsInfo() const; >@@ -202,8 +212,17 @@ private: > #endif > > void startOrStopAnimationCallbacks(); >+ void scrollToOffsetForAnimation(const FloatPoint& scrollOffset); >+ >+ // ScrollAnimationClient >+ void scrollAnimationDidUpdate(ScrollAnimation&, const FloatPoint& /* currentOffset */) final; >+ void scrollAnimationDidEnd(ScrollAnimation&) final; >+ ScrollExtents scrollExtentsForAnimation(ScrollAnimation&) final; > > ScrollingEffectsControllerClient& m_client; >+ >+ std::unique_ptr<ScrollAnimation> m_currentAnimation; >+ > std::unique_ptr<ScrollSnapAnimatorState> m_scrollSnapState; > bool m_activeScrollSnapIndexDidChange { false }; > >diff --git a/Source/WebCore/platform/mac/ScrollAnimatorMac.h b/Source/WebCore/platform/mac/ScrollAnimatorMac.h >index cbfa682c56f7468281846ef1312a9f5ea5b6969d..3e517613a80d13c397982f924975dd27c977bacb 100644 >--- a/Source/WebCore/platform/mac/ScrollAnimatorMac.h >+++ b/Source/WebCore/platform/mac/ScrollAnimatorMac.h >@@ -50,8 +50,6 @@ private: > > void handleWheelEventPhase(PlatformWheelEventPhase) final; > >- FloatPoint adjustScrollPositionIfNecessary(const FloatPoint&) const; >- > bool isUserScrollInProgress() const final; > bool isRubberBandInProgress() const final; > bool isScrollSnapInProgress() const final; >@@ -62,9 +60,6 @@ private: > bool allowsHorizontalStretching(const PlatformWheelEvent&) const final; > bool allowsVerticalStretching(const PlatformWheelEvent&) const final; > bool shouldRubberBandInDirection(ScrollDirection) const final; >- void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) final; >- void immediateScrollBy(const FloatSize&) final; >- void adjustScrollPositionToBoundsIfNecessary() final; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/platform/mac/ScrollAnimatorMac.mm b/Source/WebCore/platform/mac/ScrollAnimatorMac.mm >index 6e3771ede464db7bc3450b34b219646a6b51eed5..f1908c4fa6d2e2a7573ff1a8011cc5124556c94d 100644 >--- a/Source/WebCore/platform/mac/ScrollAnimatorMac.mm >+++ b/Source/WebCore/platform/mac/ScrollAnimatorMac.mm >@@ -73,26 +73,6 @@ static bool rubberBandingEnabledForSystem() > return enabled; > } > >-FloatPoint ScrollAnimatorMac::adjustScrollPositionIfNecessary(const FloatPoint& position) const >-{ >- if (!m_scrollableArea.constrainsScrollingToContentEdge()) >- return position; >- >- return m_scrollableArea.constrainScrollPosition(ScrollPosition(position)); >-} >- >-void ScrollAnimatorMac::adjustScrollPositionToBoundsIfNecessary() >-{ >- bool currentlyConstrainsToContentEdge = m_scrollableArea.constrainsScrollingToContentEdge(); >- m_scrollableArea.setConstrainsScrollingToContentEdge(true); >- >- ScrollPosition currentScrollPosition = m_scrollableArea.scrollPosition(); >- ScrollPosition constrainedPosition = m_scrollableArea.constrainScrollPosition(currentScrollPosition); >- immediateScrollBy(constrainedPosition - currentScrollPosition); >- >- m_scrollableArea.setConstrainsScrollingToContentEdge(currentlyConstrainsToContentEdge); >-} >- > bool ScrollAnimatorMac::isUserScrollInProgress() const > { > return m_scrollController.isUserScrollInProgress(); >@@ -220,23 +200,6 @@ bool ScrollAnimatorMac::shouldRubberBandInDirection(ScrollDirection) const > return false; > } > >-void ScrollAnimatorMac::immediateScrollByWithoutContentEdgeConstraints(const FloatSize& delta) >-{ >- m_scrollableArea.setConstrainsScrollingToContentEdge(false); >- immediateScrollBy(delta); >- m_scrollableArea.setConstrainsScrollingToContentEdge(true); >-} >- >-void ScrollAnimatorMac::immediateScrollBy(const FloatSize& delta) >-{ >- FloatPoint currentPosition = this->currentPosition(); >- FloatPoint newPosition = adjustScrollPositionIfNecessary(currentPosition + delta); >- if (newPosition == currentPosition) >- return; >- >- setCurrentPosition(newPosition, NotifyScrollableArea::Yes); >-} >- > bool ScrollAnimatorMac::processWheelEventForScrollSnap(const PlatformWheelEvent& wheelEvent) > { > return m_scrollController.processWheelEventForScrollSnap(wheelEvent); >diff --git a/Source/WebCore/platform/mac/ScrollingEffectsController.mm b/Source/WebCore/platform/mac/ScrollingEffectsController.mm >index 29490d8aec83c3a227d3be569facad24198dd017..ac277464523866d8beb9d307b2dc014a7fa72c67 100644 >--- a/Source/WebCore/platform/mac/ScrollingEffectsController.mm >+++ b/Source/WebCore/platform/mac/ScrollingEffectsController.mm >@@ -757,11 +757,10 @@ void ScrollingEffectsController::updateScrollSnapAnimatingState(MonotonicTime cu > > bool isAnimationComplete; > auto animationOffset = m_scrollSnapState->currentAnimatedScrollOffset(currentTime, isAnimationComplete); >- auto currentOffset = m_client.scrollOffset(); >+ LOG_WITH_STREAM(ScrollSnap, stream << "ScrollingEffectsController " << this << " updateScrollSnapAnimatingState - isAnimationComplete " << isAnimationComplete << " animationOffset " << animationOffset << " (main thread " << isMainThread() << ")"); > >- LOG_WITH_STREAM(ScrollSnap, stream << "ScrollingEffectsController " << this << " updateScrollSnapAnimatingState - isAnimationComplete " << isAnimationComplete << " currentOffset " << currentOffset << " (main thread " << isMainThread() << ")"); >+ scrollToOffsetForAnimation(animationOffset); > >- m_client.immediateScrollByWithoutContentEdgeConstraints(FloatSize(animationOffset.x() - currentOffset.x(), animationOffset.y() - currentOffset.y())); > if (isAnimationComplete) { > m_scrollSnapState->transitionToDestinationReachedState(); > stopScrollSnapAnimation();
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
Flags:
ews-feeder
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 230720
:
439092
|
439097
|
439101