Diff
Modified: trunk/Source/WebCore/ChangeLog (282886 => 282887)
--- trunk/Source/WebCore/ChangeLog 2021-09-22 22:10:56 UTC (rev 282886)
+++ trunk/Source/WebCore/ChangeLog 2021-09-22 22:15:54 UTC (rev 282887)
@@ -1,3 +1,39 @@
+2021-09-22 Simon Fraser <simon.fra...@apple.com>
+
+ Push ScrollAnimatorMac code into the base class and clean up the ScrollAnimator interface
+ https://bugs.webkit.org/show_bug.cgi?id=230633
+
+ Reviewed by Martin Robinson.
+
+ Reduce the brainprint of ScrollAnimatorMac by pushing platform-agnostic code into
+ the base class.
+
+ Clean up ScrollAnimator, making more functions protected or private.
+
+ * platform/ScrollAnimator.cpp:
+ (WebCore::ScrollAnimator::scroll):
+ (WebCore::ScrollAnimator::notifyPositionChanged):
+ (WebCore::ScrollAnimator::allowsHorizontalScrolling const):
+ (WebCore::ScrollAnimator::allowsVerticalScrolling const):
+ (WebCore::ScrollAnimator::stretchAmount const):
+ (WebCore::ScrollAnimator::edgePinnedState const):
+ (WebCore::ScrollAnimator::isPinnedForScrollDelta const):
+ * platform/ScrollAnimator.h:
+ * platform/ScrollingEffectsController.h:
+ * platform/generic/ScrollAnimatorGeneric.cpp:
+ (WebCore::ScrollAnimatorGeneric::scrollAnimationDidUpdate):
+ (WebCore::ScrollAnimatorGeneric::updatePosition): Deleted.
+ * platform/generic/ScrollAnimatorGeneric.h:
+ * platform/mac/ScrollAnimatorMac.h:
+ * platform/mac/ScrollAnimatorMac.mm:
+ (WebCore::ScrollAnimatorMac::scroll): Deleted.
+ (WebCore::ScrollAnimatorMac::notifyPositionChanged): Deleted.
+ (WebCore::ScrollAnimatorMac::edgePinnedState const): Deleted.
+ (WebCore::ScrollAnimatorMac::isPinnedForScrollDelta const): Deleted.
+ (WebCore::ScrollAnimatorMac::stretchAmount const): Deleted.
+ (WebCore::ScrollAnimatorMac::allowsHorizontalScrolling const): Deleted.
+ (WebCore::ScrollAnimatorMac::allowsVerticalScrolling const): Deleted.
+
2021-09-22 Alex Christensen <achristen...@webkit.org>
PCM should include the bundle ID of the app from which it originated
Modified: trunk/Source/WebCore/platform/ScrollAnimator.cpp (282886 => 282887)
--- trunk/Source/WebCore/platform/ScrollAnimator.cpp 2021-09-22 22:10:56 UTC (rev 282886)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp 2021-09-22 22:15:54 UTC (rev 282887)
@@ -67,6 +67,8 @@
bool ScrollAnimator::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier, OptionSet<ScrollBehavior> behavior)
{
+ m_scrollableArea.scrollbarsController().setScrollbarAnimationsUnsuspendedByUserInteraction(true);
+
auto delta = deltaFromStep(orientation, step, multiplier);
if (behavior.contains(ScrollBehavior::DoDirectionalSnapping)) {
behavior.remove(ScrollBehavior::DoDirectionalSnapping);
@@ -257,8 +259,7 @@
void ScrollAnimator::notifyPositionChanged(const FloatSize& delta)
{
- UNUSED_PARAM(delta);
-
+ m_scrollableArea.scrollbarsController().notifyContentAreaScrolled(delta);
m_scrollableArea.setScrollPositionFromAnimation(roundedIntPoint(m_currentPosition));
m_scrollController.scrollPositionChanged();
}
@@ -278,6 +279,39 @@
return m_scrollableArea.scrollOffsetFromPosition(roundedIntPoint(currentPosition()));
}
+bool ScrollAnimator::allowsHorizontalScrolling() const
+{
+ return m_scrollableArea.allowsHorizontalScrolling();
+}
+
+bool ScrollAnimator::allowsVerticalScrolling() const
+{
+ return m_scrollableArea.allowsVerticalScrolling();
+}
+
+#if HAVE(RUBBER_BANDING)
+IntSize ScrollAnimator::stretchAmount() const
+{
+ return m_scrollableArea.overhangAmount();
+}
+
+RectEdges<bool> ScrollAnimator::edgePinnedState() const
+{
+ return m_scrollableArea.edgePinnedState();
+}
+
+bool ScrollAnimator::isPinnedForScrollDelta(const FloatSize& delta) const
+{
+ if (fabsf(delta.height()) >= fabsf(delta.width()))
+ return m_scrollableArea.isPinnedForScrollDeltaOnAxis(delta.height(), ScrollEventAxis::Vertical);
+
+ if (delta.width())
+ return m_scrollableArea.isPinnedForScrollDeltaOnAxis(delta.width(), ScrollEventAxis::Horizontal);
+
+ return false;
+}
+#endif
+
// FIXME: Unused.
void ScrollAnimator::immediateScrollOnAxis(ScrollEventAxis axis, float delta)
{
Modified: trunk/Source/WebCore/platform/ScrollAnimator.h (282886 => 282887)
--- trunk/Source/WebCore/platform/ScrollAnimator.h 2021-09-22 22:10:56 UTC (rev 282886)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h 2021-09-22 22:15:54 UTC (rev 282887)
@@ -62,6 +62,8 @@
ScrollableArea& scrollableArea() const { return m_scrollableArea; }
+ KeyboardScrollingAnimator *keyboardScrollingAnimator() const final { return m_keyboardScrollingAnimator.get(); }
+
enum ScrollBehavior {
DoDirectionalSnapping = 1 << 0,
NeverAnimate = 1 << 1,
@@ -71,12 +73,12 @@
// already at the destination. Otherwise, starts scrolling towards the
// destination and returns true. Scrolling may be immediate or animated.
// The base class implementation always scrolls immediately, never animates.
- virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier, OptionSet<ScrollBehavior>);
+ bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier, OptionSet<ScrollBehavior>);
virtual bool scrollToPositionWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped);
- virtual bool scrollToPositionWithAnimation(const FloatPoint&);
+ bool scrollToPositionWithAnimation(const FloatPoint&);
- virtual void retargetRunningAnimation(const FloatPoint&);
+ void retargetRunningAnimation(const FloatPoint&);
virtual bool handleWheelEvent(const PlatformWheelEvent&);
@@ -96,11 +98,6 @@
virtual bool isRubberBandInProgress() const { return false; }
virtual bool isScrollSnapInProgress() const { return false; }
- // ScrollAnimationClient
- void scrollAnimationDidUpdate(ScrollAnimation&, const FloatPoint& currentOffset) override;
- void scrollAnimationDidEnd(ScrollAnimation&) override;
- ScrollExtents scrollExtentsForAnimation(ScrollAnimation&) override;
-
void contentsSizeChanged() const;
enum NotifyScrollableArea : bool {
@@ -109,8 +106,6 @@
void setCurrentPosition(const FloatPoint&, NotifyScrollableArea = NotifyScrollableArea::No);
const FloatPoint& currentPosition() const { return m_currentPosition; }
- KeyboardScrollingAnimator *keyboardScrollingAnimator() const override { return m_keyboardScrollingAnimator.get(); }
-
void setWheelEventTestMonitor(RefPtr<WheelEventTestMonitor>&& testMonitor) { m_wheelEventTestMonitor = testMonitor; }
WheelEventTestMonitor* wheelEventTestMonitor() const { return m_wheelEventTestMonitor.get(); }
@@ -117,13 +112,6 @@
FloatPoint adjustScrollOffsetForSnappingIfNeeded(const FloatPoint& offset, ScrollSnapPointSelectionMethod);
float adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis, const FloatPoint& newOffset, ScrollSnapPointSelectionMethod);
- std::unique_ptr<ScrollingEffectsControllerTimer> createTimer(Function<void()>&&) final;
-
- void startAnimationCallback(ScrollingEffectsController&) final;
- void stopAnimationCallback(ScrollingEffectsController&) final;
-
- void scrollControllerAnimationTimerFired();
-
bool activeScrollSnapIndexDidChange() const;
std::optional<unsigned> activeScrollSnapIndexForAxis(ScrollEventAxis) const;
void setActiveScrollSnapIndexForAxis(ScrollEventAxis, std::optional<unsigned> index);
@@ -131,27 +119,53 @@
const LayoutScrollSnapOffsetsInfo* snapOffsetsInfo() const;
void resnapAfterLayout();
- // ScrollingEffectsControllerClient.
- FloatPoint scrollOffset() const override;
- void immediateScrollOnAxis(ScrollEventAxis, float delta) override;
- float pageScaleFactor() const override;
- ScrollExtents scrollExtents() const override;
-#if PLATFORM(MAC)
- void deferWheelEventTestCompletionForReason(WheelEventTestMonitor::ScrollableAreaIdentifier, WheelEventTestMonitor::DeferReason) const override;
- void removeWheelEventTestCompletionDeferralForReason(WheelEventTestMonitor::ScrollableAreaIdentifier, WheelEventTestMonitor::DeferReason) const override;
-#endif
-
protected:
- virtual void notifyPositionChanged(const FloatSize& delta);
virtual bool platformAllowsScrollAnimation() const { return true; }
+ // ScrollAnimationClient
+ void scrollAnimationDidUpdate(ScrollAnimation&, const FloatPoint& currentOffset) override;
+
+private:
+ void notifyPositionChanged(const FloatSize& delta);
+
+ void scrollControllerAnimationTimerFired();
void updateActiveScrollSnapIndexForOffset();
FloatPoint offsetFromPosition(const FloatPoint& position) const;
FloatPoint positionFromOffset(const FloatPoint& offset) const;
+
+ // ScrollingEffectsControllerClient.
+ std::unique_ptr<ScrollingEffectsControllerTimer> createTimer(Function<void()>&&) final;
+ void startAnimationCallback(ScrollingEffectsController&) final;
+ 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;
+
+#if HAVE(RUBBER_BANDING)
+ IntSize stretchAmount() const final;
+ RectEdges<bool> edgePinnedState() const final;
+ bool isPinnedForScrollDelta(const FloatSize&) const final;
+#endif
+
+#if PLATFORM(MAC)
+ void deferWheelEventTestCompletionForReason(WheelEventTestMonitor::ScrollableAreaIdentifier, WheelEventTestMonitor::DeferReason) const final;
+ 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:
ScrollableArea& m_scrollableArea;
RefPtr<WheelEventTestMonitor> m_wheelEventTestMonitor;
ScrollingEffectsController m_scrollController;
Modified: trunk/Source/WebCore/platform/ScrollingEffectsController.h (282886 => 282887)
--- trunk/Source/WebCore/platform/ScrollingEffectsController.h 2021-09-22 22:10:56 UTC (rev 282886)
+++ trunk/Source/WebCore/platform/ScrollingEffectsController.h 2021-09-22 22:15:54 UTC (rev 282887)
@@ -77,6 +77,9 @@
virtual void updateKeyboardScrollPosition(MonotonicTime) { }
virtual KeyboardScrollingAnimator *keyboardScrollingAnimator() const { return nullptr; }
+ virtual bool allowsHorizontalScrolling() const = 0;
+ virtual bool allowsVerticalScrolling() const = 0;
+
#if HAVE(RUBBER_BANDING)
virtual bool allowsHorizontalStretching(const PlatformWheelEvent&) const = 0;
virtual bool allowsVerticalStretching(const PlatformWheelEvent&) const = 0;
@@ -86,8 +89,6 @@
virtual RectEdges<bool> edgePinnedState() const = 0;
- virtual bool allowsHorizontalScrolling() const = 0;
- virtual bool allowsVerticalScrolling() const = 0;
virtual bool shouldRubberBandInDirection(ScrollDirection) const = 0;
// FIXME: use ScrollClamping to collapse these to one.
Modified: trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp (282886 => 282887)
--- trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp 2021-09-22 22:10:56 UTC (rev 282886)
+++ trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp 2021-09-22 22:15:54 UTC (rev 282887)
@@ -78,14 +78,6 @@
return ScrollAnimator::handleWheelEvent(event);
}
-void ScrollAnimatorGeneric::updatePosition(const FloatPoint& position)
-{
- FloatSize delta = position - m_currentPosition;
- m_currentPosition = position;
- notifyPositionChanged(delta);
- updateActiveScrollSnapIndexForOffset();
-}
-
// FIXME: Can we just use the base class implementation?
void ScrollAnimatorGeneric::scrollAnimationDidUpdate(ScrollAnimation& animation, const FloatPoint& position)
{
@@ -92,7 +84,7 @@
if (&animation == m_kineticAnimation.get()) {
// FIXME: Clarify how animations interact. There should never be more than one active at a time.
m_scrollAnimation->stop();
- updatePosition(position);
+ setCurrentPosition(position, NotifyScrollableArea::Yes);
return;
}
Modified: trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.h (282886 => 282887)
--- trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.h 2021-09-22 22:10:56 UTC (rev 282886)
+++ trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.h 2021-09-22 22:15:54 UTC (rev 282887)
@@ -50,13 +50,6 @@
// ScrollAnimationClient
void scrollAnimationDidUpdate(ScrollAnimation&, const FloatPoint& currentPosition) final;
- void updatePosition(const FloatPoint&);
-
- void overlayScrollbarAnimationTimerFired();
- void showOverlayScrollbars();
- void hideOverlayScrollbars();
- void updateOverlayScrollbarsOpacity();
-
std::unique_ptr<ScrollAnimationKinetic> m_kineticAnimation;
};
Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h (282886 => 282887)
--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h 2021-09-22 22:10:56 UTC (rev 282886)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h 2021-09-22 22:15:54 UTC (rev 282887)
@@ -43,8 +43,6 @@
virtual ~ScrollAnimatorMac();
private:
- bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier, OptionSet<ScrollBehavior>) final;
-
bool shouldForwardWheelEventsToParent(const PlatformWheelEvent&) const;
bool handleWheelEvent(const PlatformWheelEvent&) final;
@@ -52,8 +50,6 @@
void handleWheelEventPhase(PlatformWheelEventPhase) final;
- void notifyPositionChanged(const FloatSize& delta) final;
-
FloatPoint adjustScrollPositionIfNecessary(const FloatPoint&) const;
bool isUserScrollInProgress() const final;
@@ -63,13 +59,8 @@
bool processWheelEventForScrollSnap(const PlatformWheelEvent&) final;
// ScrollingEffectsControllerClient.
- IntSize stretchAmount() const final;
bool allowsHorizontalStretching(const PlatformWheelEvent&) const final;
bool allowsVerticalStretching(const PlatformWheelEvent&) const final;
- bool isPinnedForScrollDelta(const FloatSize&) const final;
- RectEdges<bool> edgePinnedState() const final;
- bool allowsHorizontalScrolling() const final;
- bool allowsVerticalScrolling() const final;
bool shouldRubberBandInDirection(ScrollDirection) const final;
void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) final;
void immediateScrollBy(const FloatSize&) final;
Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (282886 => 282887)
--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm 2021-09-22 22:10:56 UTC (rev 282886)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm 2021-09-22 22:15:54 UTC (rev 282887)
@@ -73,13 +73,6 @@
return enabled;
}
-bool ScrollAnimatorMac::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier, OptionSet<ScrollBehavior> behavior)
-{
- m_scrollableArea.scrollbarsController().setScrollbarAnimationsUnsuspendedByUserInteraction(true);
-
- return ScrollAnimator::scroll(orientation, granularity, step, multiplier, behavior);
-}
-
FloatPoint ScrollAnimatorMac::adjustScrollPositionIfNecessary(const FloatPoint& position) const
{
if (!m_scrollableArea.constrainsScrollingToContentEdge())
@@ -115,12 +108,6 @@
return m_scrollController.isScrollSnapInProgress();
}
-void ScrollAnimatorMac::notifyPositionChanged(const FloatSize& delta)
-{
- m_scrollableArea.scrollbarsController().notifyContentAreaScrolled(delta);
- ScrollAnimator::notifyPositionChanged(delta);
-}
-
void ScrollAnimatorMac::handleWheelEventPhase(PlatformWheelEventPhase phase)
{
LOG_WITH_STREAM(OverlayScrollbars, stream << "ScrollAnimatorMac " << this << " scrollableArea " << m_scrollableArea << " handleWheelEventPhase " << phase);
@@ -170,22 +157,6 @@
return didHandleEvent;
}
-RectEdges<bool> ScrollAnimatorMac::edgePinnedState() const
-{
- return m_scrollableArea.edgePinnedState();
-}
-
-bool ScrollAnimatorMac::isPinnedForScrollDelta(const FloatSize& delta) const
-{
- if (fabsf(delta.height()) >= fabsf(delta.width()))
- return m_scrollableArea.isPinnedForScrollDeltaOnAxis(delta.height(), ScrollEventAxis::Vertical);
-
- if (delta.width())
- return m_scrollableArea.isPinnedForScrollDeltaOnAxis(delta.width(), ScrollEventAxis::Horizontal);
-
- return false;
-}
-
static bool gestureShouldBeginSnap(const PlatformWheelEvent& wheelEvent, ScrollEventAxis axis, const LayoutScrollSnapOffsetsInfo* offsetInfo)
{
if (!offsetInfo)
@@ -244,21 +215,6 @@
return false;
}
-IntSize ScrollAnimatorMac::stretchAmount() const
-{
- return m_scrollableArea.overhangAmount();
-}
-
-bool ScrollAnimatorMac::allowsHorizontalScrolling() const
-{
- return m_scrollableArea.allowsHorizontalScrolling();
-}
-
-bool ScrollAnimatorMac::allowsVerticalScrolling() const
-{
- return m_scrollableArea.allowsVerticalScrolling();
-}
-
bool ScrollAnimatorMac::shouldRubberBandInDirection(ScrollDirection) const
{
return false;