- Revision
- 282728
- Author
- [email protected]
- Date
- 2021-09-18 12:05:28 -0700 (Sat, 18 Sep 2021)
Log Message
Clean up the ScrollAnimator interface a little
https://bugs.webkit.org/show_bug.cgi?id=230324
Reviewed by Myles C. Maxfield.
Reduce brainprint by removing the "scroll to offset" variants; have the caller
do offset -> position conversion instead.
Move virtual functions close together. Remove updateScrollSnapState()
which was unimplemented.
* platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::immediateScrollOnAxis):
(WebCore::ScrollAnimator::scrollToOffsetWithoutAnimation): Deleted.
(WebCore::ScrollAnimator::scrollToOffsetWithAnimation): Deleted.
* platform/ScrollAnimator.h:
(WebCore::ScrollAnimator::scrollableArea const):
(WebCore::ScrollAnimator::processWheelEventForScrollSnap):
(WebCore::ScrollAnimator::currentPosition const):
(WebCore::ScrollAnimator::haveScrolledSincePageLoad const):
(WebCore::ScrollAnimator::setHaveScrolledSincePageLoad):
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::scrollToOffsetWithoutAnimation):
(WebCore::ScrollableArea::doPostThumbMoveSnapping):
* platform/mac/ScrollAnimatorMac.mm:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (282727 => 282728)
--- trunk/Source/WebCore/ChangeLog 2021-09-18 16:12:47 UTC (rev 282727)
+++ trunk/Source/WebCore/ChangeLog 2021-09-18 19:05:28 UTC (rev 282728)
@@ -1,3 +1,31 @@
+2021-09-18 Simon Fraser <[email protected]>
+
+ Clean up the ScrollAnimator interface a little
+ https://bugs.webkit.org/show_bug.cgi?id=230324
+
+ Reviewed by Myles C. Maxfield.
+
+ Reduce brainprint by removing the "scroll to offset" variants; have the caller
+ do offset -> position conversion instead.
+
+ Move virtual functions close together. Remove updateScrollSnapState()
+ which was unimplemented.
+
+ * platform/ScrollAnimator.cpp:
+ (WebCore::ScrollAnimator::immediateScrollOnAxis):
+ (WebCore::ScrollAnimator::scrollToOffsetWithoutAnimation): Deleted.
+ (WebCore::ScrollAnimator::scrollToOffsetWithAnimation): Deleted.
+ * platform/ScrollAnimator.h:
+ (WebCore::ScrollAnimator::scrollableArea const):
+ (WebCore::ScrollAnimator::processWheelEventForScrollSnap):
+ (WebCore::ScrollAnimator::currentPosition const):
+ (WebCore::ScrollAnimator::haveScrolledSincePageLoad const):
+ (WebCore::ScrollAnimator::setHaveScrolledSincePageLoad):
+ * platform/ScrollableArea.cpp:
+ (WebCore::ScrollableArea::scrollToOffsetWithoutAnimation):
+ (WebCore::ScrollableArea::doPostThumbMoveSnapping):
+ * platform/mac/ScrollAnimatorMac.mm:
+
2021-09-18 Patrick Griffis <[email protected]>
[GTK] Disable MediaSessionManagerGLib when MEDIA_SESSION disabled
Modified: trunk/Source/WebCore/platform/ScrollAnimator.cpp (282727 => 282728)
--- trunk/Source/WebCore/platform/ScrollAnimator.cpp 2021-09-18 16:12:47 UTC (rev 282727)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp 2021-09-18 19:05:28 UTC (rev 282728)
@@ -93,11 +93,6 @@
return scrollToPositionWithoutAnimation(currentPosition() + delta);
}
-bool ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset, ScrollClamping clamping)
-{
- return scrollToPositionWithoutAnimation(ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(scrollableArea().scrollOrigin())), clamping);
-}
-
bool ScrollAnimator::scrollToPositionWithoutAnimation(const FloatPoint& position, ScrollClamping clamping)
{
FloatPoint currentPosition = this->currentPosition();
@@ -115,11 +110,6 @@
return true;
}
-bool ScrollAnimator::scrollToOffsetWithAnimation(const FloatPoint& offset)
-{
- return scrollToPositionWithAnimation(ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(scrollableArea().scrollOrigin())));
-}
-
bool ScrollAnimator::scrollToPositionWithAnimation(const FloatPoint& newPosition)
{
bool positionChanged = newPosition != currentPosition();
@@ -286,7 +276,7 @@
else
deltaSize.setHeight(delta);
- scrollToOffsetWithoutAnimation(currentPosition() + deltaSize);
+ scrollToPositionWithoutAnimation(currentPosition() + deltaSize);
}
LayoutSize ScrollAnimator::scrollExtent() const
Modified: trunk/Source/WebCore/platform/ScrollAnimator.h (282727 => 282728)
--- trunk/Source/WebCore/platform/ScrollAnimator.h 2021-09-18 16:12:47 UTC (rev 282727)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h 2021-09-18 19:05:28 UTC (rev 282728)
@@ -60,6 +60,8 @@
explicit ScrollAnimator(ScrollableArea&);
virtual ~ScrollAnimator();
+ ScrollableArea& scrollableArea() const { return m_scrollableArea; }
+
enum ScrollBehavior {
DoDirectionalSnapping = 1 << 0,
NeverAnimate = 1 << 1,
@@ -71,34 +73,22 @@
// The base class implementation always scrolls immediately, never animates.
virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier, OptionSet<ScrollBehavior>);
- bool scrollToOffsetWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped);
- virtual bool scrollToPositionWithoutAnimation(const FloatPoint& position, ScrollClamping = ScrollClamping::Clamped);
- virtual void retargetRunningAnimation(const FloatPoint&);
-
- bool scrollToOffsetWithAnimation(const FloatPoint&);
+ virtual bool scrollToPositionWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped);
virtual bool scrollToPositionWithAnimation(const FloatPoint&);
- ScrollableArea& scrollableArea() const { return m_scrollableArea; }
+ virtual void retargetRunningAnimation(const FloatPoint&);
- void contentsSizeChanged() const;
-
- bool haveScrolledSincePageLoad() const { return m_haveScrolledSincePageLoad; }
- void setHaveScrolledSincePageLoad(bool haveScrolled) { m_haveScrolledSincePageLoad = haveScrolled; }
-
virtual bool handleWheelEvent(const PlatformWheelEvent&);
- KeyboardScrollingAnimator *keyboardScrollingAnimator() const override { return m_keyboardScrollingAnimator.get(); }
+ virtual bool processWheelEventForScrollSnap(const PlatformWheelEvent&) { return false; }
-#if ENABLE(TOUCH_EVENTS)
- virtual bool handleTouchEvent(const PlatformTouchEvent&);
-#endif
-
#if PLATFORM(COCOA)
virtual void handleWheelEventPhase(PlatformWheelEventPhase) { }
#endif
- void setCurrentPosition(const FloatPoint&);
- const FloatPoint& currentPosition() const { return m_currentPosition; }
+#if ENABLE(TOUCH_EVENTS)
+ virtual bool handleTouchEvent(const PlatformTouchEvent&);
+#endif
virtual void cancelAnimations();
@@ -111,6 +101,16 @@
void scrollAnimationDidEnd(ScrollAnimation&) override;
ScrollExtents scrollExtentsForAnimation(ScrollAnimation&) override;
+ void contentsSizeChanged() const;
+
+ void setCurrentPosition(const FloatPoint&);
+ const FloatPoint& currentPosition() const { return m_currentPosition; }
+
+ bool haveScrolledSincePageLoad() const { return m_haveScrolledSincePageLoad; }
+ void setHaveScrolledSincePageLoad(bool haveScrolled) { m_haveScrolledSincePageLoad = haveScrolled; }
+
+ KeyboardScrollingAnimator *keyboardScrollingAnimator() const override { return m_keyboardScrollingAnimator.get(); }
+
void setWheelEventTestMonitor(RefPtr<WheelEventTestMonitor>&& testMonitor) { m_wheelEventTestMonitor = testMonitor; }
WheelEventTestMonitor* wheelEventTestMonitor() const { return m_wheelEventTestMonitor.get(); }
@@ -124,8 +124,6 @@
void scrollControllerAnimationTimerFired();
- virtual bool processWheelEventForScrollSnap(const PlatformWheelEvent&) { return false; }
- void updateScrollSnapState();
bool activeScrollSnapIndexDidChange() const;
std::optional<unsigned> activeScrollSnapIndexForAxis(ScrollEventAxis) const;
void setActiveScrollSnapIndexForAxis(ScrollEventAxis, std::optional<unsigned> index);
Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (282727 => 282728)
--- trunk/Source/WebCore/platform/ScrollableArea.cpp 2021-09-18 16:12:47 UTC (rev 282727)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp 2021-09-18 19:05:28 UTC (rev 282728)
@@ -161,16 +161,18 @@
void ScrollableArea::scrollToOffsetWithoutAnimation(const FloatPoint& offset, ScrollClamping clamping)
{
LOG_WITH_STREAM(Scrolling, stream << "ScrollableArea " << this << " scrollToOffsetWithoutAnimation " << offset);
- scrollAnimator().scrollToOffsetWithoutAnimation(offset, clamping);
+
+ auto position = scrollPositionFromOffset(offset, toFloatSize(scrollOrigin()));
+ scrollAnimator().scrollToPositionWithoutAnimation(position, clamping);
}
void ScrollableArea::scrollToOffsetWithoutAnimation(ScrollbarOrientation orientation, float offset)
{
- auto currentOffset = scrollOffsetFromPosition(IntPoint(scrollAnimator().currentPosition()));
+ auto currentPosition = scrollAnimator().currentPosition();
if (orientation == HorizontalScrollbar)
- scrollAnimator().scrollToOffsetWithoutAnimation(FloatPoint(offset, currentOffset.y()));
+ scrollAnimator().scrollToPositionWithoutAnimation(FloatPoint(offset, currentPosition.y()));
else
- scrollAnimator().scrollToOffsetWithoutAnimation(FloatPoint(currentOffset.x(), offset));
+ scrollAnimator().scrollToPositionWithoutAnimation(FloatPoint(currentPosition.x(), offset));
}
void ScrollableArea::notifyScrollPositionChanged(const ScrollPosition& position)
@@ -567,10 +569,12 @@
newOffset.setX(scrollAnimator->adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis::Horizontal, currentOffset, ScrollSnapPointSelectionMethod::Closest));
else
newOffset.setY(scrollAnimator->adjustScrollOffsetForSnappingIfNeeded(ScrollEventAxis::Vertical, currentOffset, ScrollSnapPointSelectionMethod::Closest));
+
if (newOffset == currentOffset)
return;
- scrollAnimator->scrollToOffsetWithAnimation(newOffset);
+ auto position = scrollPositionFromOffset(newOffset);
+ scrollAnimator->scrollToPositionWithAnimation(position);
}
bool ScrollableArea::isPinnedForScrollDeltaOnAxis(float scrollDelta, ScrollEventAxis axis) const