Title: [283524] trunk/Source/WebCore
Revision
283524
Author
[email protected]
Date
2021-10-04 16:37:24 -0700 (Mon, 04 Oct 2021)

Log Message

Use ScrollClamping in more places in scrolling code
https://bugs.webkit.org/show_bug.cgi?id=231140

Reviewed by Antti Koivisto.

Fold together two functions in ScrollingEffectsControllerClient with a ScrollClamping argument.
Also use ScrollClamping to replace bool constrainsScrollingToContentEdge() on ScrollableArea.

It's slightly annoying that ScrollClamping is a ScrollableArea state, but RenderMarquee has
no clamping by default.

* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::reconcileScrollingState):
* page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h:
* page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm:
(WebCore::ScrollingTreeScrollingNodeDelegateMac::immediateScrollBy):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::immediateScrollByWithoutContentEdgeConstraints): Deleted.
* platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::adjustScrollPositionToBoundsIfNecessary):
(WebCore::ScrollAnimator::adjustScrollPositionIfNecessary const):
(WebCore::ScrollAnimator::immediateScrollBy):
(WebCore::ScrollAnimator::immediateScrollByWithoutContentEdgeConstraints): Deleted.
* platform/ScrollAnimator.h:
* platform/ScrollView.cpp:
(WebCore::ScrollView::adjustScrollPositionWithinRange const):
(WebCore::ScrollView::setScrollOffset):
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::ScrollableArea): Deleted.
* platform/ScrollableArea.h: Undo the use of bitfields here because the memory saving
is not worth the code complexity.
(WebCore::ScrollableArea::currentScrollBehaviorStatus):
(WebCore::ScrollableArea::setScrollBehaviorStatus):
(WebCore::ScrollableArea::scrollClamping const):
(WebCore::ScrollableArea::setScrollClamping):
(WebCore::ScrollableArea::verticalScrollElasticity const):
(WebCore::ScrollableArea::horizontalScrollElasticity const):
(WebCore::ScrollableArea::scrollbarOverlayStyle const):
(WebCore::ScrollableArea::currentScrollType const):
(WebCore::ScrollableArea::setCurrentScrollType):
(WebCore::ScrollableArea::constrainsScrollingToContentEdge const): Deleted.
(WebCore::ScrollableArea::setConstrainsScrollingToContentEdge): Deleted.
* platform/ScrollingEffectsController.cpp:
(WebCore::ScrollingEffectsController::scrollAnimationDidUpdate):
(WebCore::ScrollingEffectsController::scrollToOffsetForAnimation): Deleted.
* platform/ScrollingEffectsController.h:
* platform/mac/ScrollingEffectsController.mm:
(WebCore::ScrollingEffectsController::applyScrollDeltaWithStretching):
(WebCore::ScrollingEffectsController::updateRubberBandAnimatingState):
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::RenderListBox):
* rendering/RenderListBox.h: Minor rearrangement to optimize padding now that ScrollableArea is a little larger.
* rendering/RenderMarquee.cpp:
(WebCore::RenderMarquee::RenderMarquee):
* testing/Internals.cpp:
(WebCore::Internals::setScrollViewPosition):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (283523 => 283524)


--- trunk/Source/WebCore/ChangeLog	2021-10-04 23:23:27 UTC (rev 283523)
+++ trunk/Source/WebCore/ChangeLog	2021-10-04 23:37:24 UTC (rev 283524)
@@ -1,3 +1,61 @@
+2021-10-04  Simon Fraser  <[email protected]>
+
+        Use ScrollClamping in more places in scrolling code
+        https://bugs.webkit.org/show_bug.cgi?id=231140
+
+        Reviewed by Antti Koivisto.
+
+        Fold together two functions in ScrollingEffectsControllerClient with a ScrollClamping argument.
+        Also use ScrollClamping to replace bool constrainsScrollingToContentEdge() on ScrollableArea.
+
+        It's slightly annoying that ScrollClamping is a ScrollableArea state, but RenderMarquee has
+        no clamping by default.
+
+        * page/scrolling/AsyncScrollingCoordinator.cpp:
+        (WebCore::AsyncScrollingCoordinator::reconcileScrollingState):
+        * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h:
+        * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm:
+        (WebCore::ScrollingTreeScrollingNodeDelegateMac::immediateScrollBy):
+        (WebCore::ScrollingTreeScrollingNodeDelegateMac::immediateScrollByWithoutContentEdgeConstraints): Deleted.
+        * platform/ScrollAnimator.cpp:
+        (WebCore::ScrollAnimator::adjustScrollPositionToBoundsIfNecessary):
+        (WebCore::ScrollAnimator::adjustScrollPositionIfNecessary const):
+        (WebCore::ScrollAnimator::immediateScrollBy):
+        (WebCore::ScrollAnimator::immediateScrollByWithoutContentEdgeConstraints): Deleted.
+        * platform/ScrollAnimator.h:
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::adjustScrollPositionWithinRange const):
+        (WebCore::ScrollView::setScrollOffset):
+        * platform/ScrollableArea.cpp:
+        (WebCore::ScrollableArea::ScrollableArea): Deleted.
+        * platform/ScrollableArea.h: Undo the use of bitfields here because the memory saving
+        is not worth the code complexity.
+        (WebCore::ScrollableArea::currentScrollBehaviorStatus):
+        (WebCore::ScrollableArea::setScrollBehaviorStatus):
+        (WebCore::ScrollableArea::scrollClamping const):
+        (WebCore::ScrollableArea::setScrollClamping):
+        (WebCore::ScrollableArea::verticalScrollElasticity const):
+        (WebCore::ScrollableArea::horizontalScrollElasticity const):
+        (WebCore::ScrollableArea::scrollbarOverlayStyle const):
+        (WebCore::ScrollableArea::currentScrollType const):
+        (WebCore::ScrollableArea::setCurrentScrollType):
+        (WebCore::ScrollableArea::constrainsScrollingToContentEdge const): Deleted.
+        (WebCore::ScrollableArea::setConstrainsScrollingToContentEdge): Deleted.
+        * platform/ScrollingEffectsController.cpp:
+        (WebCore::ScrollingEffectsController::scrollAnimationDidUpdate):
+        (WebCore::ScrollingEffectsController::scrollToOffsetForAnimation): Deleted.
+        * platform/ScrollingEffectsController.h:
+        * platform/mac/ScrollingEffectsController.mm:
+        (WebCore::ScrollingEffectsController::applyScrollDeltaWithStretching):
+        (WebCore::ScrollingEffectsController::updateRubberBandAnimatingState):
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::RenderListBox):
+        * rendering/RenderListBox.h: Minor rearrangement to optimize padding now that ScrollableArea is a little larger.
+        * rendering/RenderMarquee.cpp:
+        (WebCore::RenderMarquee::RenderMarquee):
+        * testing/Internals.cpp:
+        (WebCore::Internals::setScrollViewPosition):
+
 2021-10-04  Chris Dumez  <[email protected]>
 
         Add SPI to launch a service service worker in a WKWebView and expose service worker to injected bundle

Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (283523 => 283524)


--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2021-10-04 23:23:27 UTC (rev 283523)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2021-10-04 23:37:24 UTC (rev 283524)
@@ -411,9 +411,9 @@
         }
     );
 
-    frameView.setConstrainsScrollingToContentEdge(false);
+    frameView.setScrollClamping(ScrollClamping::Unclamped);
     frameView.notifyScrollPositionChanged(roundedIntPoint(scrollPosition));
-    frameView.setConstrainsScrollingToContentEdge(true);
+    frameView.setScrollClamping(ScrollClamping::Clamped);
 
     frameView.setCurrentScrollType(previousScrollType);
 

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h (283523 => 283524)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h	2021-10-04 23:23:27 UTC (rev 283523)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h	2021-10-04 23:37:24 UTC (rev 283524)
@@ -85,8 +85,7 @@
     ScrollBehaviorStatus scrollBehaviorStatus() const final { return m_scrollBehaviorStatus; }
 
     bool shouldRubberBandOnSide(BoxSide) const final;
-    void immediateScrollBy(const FloatSize&) final;
-    void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) final;
+    void immediateScrollBy(const FloatSize&, ScrollClamping = ScrollClamping::Clamped) final;
     void didStopRubberbandSnapAnimation() final;
     void rubberBandingStateChanged(bool) final;
     void adjustScrollPositionToBoundsIfNecessary() final;

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm (283523 => 283524)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm	2021-10-04 23:23:27 UTC (rev 283523)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm	2021-10-04 23:37:24 UTC (rev 283524)
@@ -320,16 +320,11 @@
     return true;
 }
 
-void ScrollingTreeScrollingNodeDelegateMac::immediateScrollBy(const FloatSize& delta)
+void ScrollingTreeScrollingNodeDelegateMac::immediateScrollBy(const FloatSize& delta, ScrollClamping clamping)
 {
-    scrollingNode().scrollBy(delta);
+    scrollingNode().scrollBy(delta, clamping);
 }
 
-void ScrollingTreeScrollingNodeDelegateMac::immediateScrollByWithoutContentEdgeConstraints(const FloatSize& offset)
-{
-    scrollingNode().scrollBy(offset, ScrollClamping::Unclamped);
-}
-
 void ScrollingTreeScrollingNodeDelegateMac::didStopRubberbandSnapAnimation()
 {
     // Since the rubberband timer has stopped, totalContentsSizeForRubberBand can be synchronized with totalContentsSize.

Modified: trunk/Source/WebCore/platform/ScrollAnimator.cpp (283523 => 283524)


--- trunk/Source/WebCore/platform/ScrollAnimator.cpp	2021-10-04 23:23:27 UTC (rev 283523)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp	2021-10-04 23:37:24 UTC (rev 283524)
@@ -317,39 +317,35 @@
 
 void ScrollAnimator::adjustScrollPositionToBoundsIfNecessary()
 {
-    bool currentlyConstrainsToContentEdge = m_scrollableArea.constrainsScrollingToContentEdge();
-    m_scrollableArea.setConstrainsScrollingToContentEdge(true);
+    auto previousClamping = m_scrollableArea.scrollClamping();
+    m_scrollableArea.setScrollClamping(ScrollClamping::Clamped);
 
     auto currentScrollPosition = m_scrollableArea.scrollPosition();
     auto constrainedPosition = m_scrollableArea.constrainScrollPosition(currentScrollPosition);
     immediateScrollBy(constrainedPosition - currentScrollPosition);
 
-    m_scrollableArea.setConstrainsScrollingToContentEdge(currentlyConstrainsToContentEdge);
+    m_scrollableArea.setScrollClamping(previousClamping);
 }
 
 FloatPoint ScrollAnimator::adjustScrollPositionIfNecessary(const FloatPoint& position) const
 {
-    if (!m_scrollableArea.constrainsScrollingToContentEdge())
+    if (m_scrollableArea.scrollClamping() == ScrollClamping::Unclamped)
         return position;
 
     return m_scrollableArea.constrainScrollPosition(ScrollPosition(position));
 }
 
-void ScrollAnimator::immediateScrollByWithoutContentEdgeConstraints(const FloatSize& delta)
+void ScrollAnimator::immediateScrollBy(const FloatSize& delta, ScrollClamping clamping)
 {
-    m_scrollableArea.setConstrainsScrollingToContentEdge(false);
-    immediateScrollBy(delta);
-    m_scrollableArea.setConstrainsScrollingToContentEdge(true);
-}
+    auto previousClamping = m_scrollableArea.scrollClamping();
+    m_scrollableArea.setScrollClamping(clamping);
 
-void ScrollAnimator::immediateScrollBy(const FloatSize& delta)
-{
-    FloatPoint currentPosition = this->currentPosition();
-    FloatPoint newPosition = adjustScrollPositionIfNecessary(currentPosition + delta);
-    if (newPosition == currentPosition)
-        return;
+    auto currentPosition = this->currentPosition();
+    auto newPosition = adjustScrollPositionIfNecessary(currentPosition + delta);
+    if (newPosition != currentPosition)
+        setCurrentPosition(newPosition, NotifyScrollableArea::Yes);
 
-    setCurrentPosition(newPosition, NotifyScrollableArea::Yes);
+    m_scrollableArea.setScrollClamping(previousClamping);
 }
 
 ScrollExtents ScrollAnimator::scrollExtents() const

Modified: trunk/Source/WebCore/platform/ScrollAnimator.h (283523 => 283524)


--- trunk/Source/WebCore/platform/ScrollAnimator.h	2021-10-04 23:23:27 UTC (rev 283523)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h	2021-10-04 23:37:24 UTC (rev 283524)
@@ -147,8 +147,7 @@
     void setScrollBehaviorStatus(ScrollBehaviorStatus) final;
     ScrollBehaviorStatus scrollBehaviorStatus() const final;
 
-    void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) final;
-    void immediateScrollBy(const FloatSize&) final;
+    void immediateScrollBy(const FloatSize&, ScrollClamping = ScrollClamping::Clamped) final;
     void adjustScrollPositionToBoundsIfNecessary() final;
 
 #if HAVE(RUBBER_BANDING)

Modified: trunk/Source/WebCore/platform/ScrollView.cpp (283523 => 283524)


--- trunk/Source/WebCore/platform/ScrollView.cpp	2021-10-04 23:23:27 UTC (rev 283523)
+++ trunk/Source/WebCore/platform/ScrollView.cpp	2021-10-04 23:37:24 UTC (rev 283524)
@@ -412,12 +412,12 @@
     return maximumPosition;
 }
 
-ScrollPosition ScrollView::adjustScrollPositionWithinRange(const ScrollPosition& scrollPoint) const
+ScrollPosition ScrollView::adjustScrollPositionWithinRange(const ScrollPosition& scrollPosition) const
 {
-    if (!constrainsScrollingToContentEdge() || m_allowsUnclampedScrollPosition)
-        return scrollPoint;
+    if (scrollClamping() == ScrollClamping::Unclamped || m_allowsUnclampedScrollPosition)
+        return scrollPosition;
 
-    return scrollPoint.constrainedBetween(minimumScrollPosition(), maximumScrollPosition());
+    return scrollPosition.constrainedBetween(minimumScrollPosition(), maximumScrollPosition());
 }
 
 ScrollPosition ScrollView::documentScrollPositionRelativeToViewOrigin() const
@@ -434,10 +434,10 @@
 
 void ScrollView::setScrollOffset(const ScrollOffset& offset)
 {
-    LOG_WITH_STREAM(Scrolling, stream << "\nScrollView::setScrollOffset " << offset << " constrains " << constrainsScrollingToContentEdge());
+    LOG_WITH_STREAM(Scrolling, stream << "\nScrollView::setScrollOffset " << offset << " clamping " << scrollClamping());
 
-    IntPoint constrainedOffset = offset;
-    if (constrainsScrollingToContentEdge())
+    auto constrainedOffset = offset;
+    if (scrollClamping() == ScrollClamping::Clamped)
         constrainedOffset = constrainedOffset.constrainedBetween(minimumScrollOffset(), maximumScrollOffset());
 
     scrollTo(scrollPositionFromOffset(constrainedOffset));

Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (283523 => 283524)


--- trunk/Source/WebCore/platform/ScrollableArea.cpp	2021-10-04 23:23:27 UTC (rev 283523)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp	2021-10-04 23:37:24 UTC (rev 283524)
@@ -52,24 +52,12 @@
 #endif
     void* pointer[3];
     IntPoint origin;
-    unsigned bitfields : 16;
+    bool bytes[9];
 };
 
 COMPILE_ASSERT(sizeof(ScrollableArea) == sizeof(SameSizeAsScrollableArea), ScrollableArea_should_stay_small);
 
-ScrollableArea::ScrollableArea()
-    : m_constrainsScrollingToContentEdge(true)
-    , m_inLiveResize(false)
-    , m_verticalScrollElasticity(ScrollElasticityNone)
-    , m_horizontalScrollElasticity(ScrollElasticityNone)
-    , m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault)
-    , m_scrollOriginChanged(false)
-    , m_currentScrollType(static_cast<unsigned>(ScrollType::User))
-    , m_scrollShouldClearLatchedState(false)
-    , m_currentScrollBehaviorStatus(static_cast<unsigned>(ScrollBehaviorStatus::NotInAnimation))
-{
-}
-
+ScrollableArea::ScrollableArea() = default;
 ScrollableArea::~ScrollableArea() = default;
 
 ScrollAnimator& ScrollableArea::scrollAnimator() const

Modified: trunk/Source/WebCore/platform/ScrollableArea.h (283523 => 283524)


--- trunk/Source/WebCore/platform/ScrollableArea.h	2021-10-04 23:23:27 UTC (rev 283523)
+++ trunk/Source/WebCore/platform/ScrollableArea.h	2021-10-04 23:37:24 UTC (rev 283524)
@@ -68,8 +68,8 @@
     virtual bool isListBox() const { return false; }
     virtual bool isPDFPlugin() const { return false; }
 
-    ScrollBehaviorStatus currentScrollBehaviorStatus() { return static_cast<ScrollBehaviorStatus>(m_currentScrollBehaviorStatus); }
-    void setScrollBehaviorStatus(ScrollBehaviorStatus status) { m_currentScrollBehaviorStatus = static_cast<unsigned>(status); }
+    ScrollBehaviorStatus currentScrollBehaviorStatus() { return m_currentScrollBehaviorStatus; }
+    void setScrollBehaviorStatus(ScrollBehaviorStatus status) { m_currentScrollBehaviorStatus = status; }
 
     WEBCORE_EXPORT bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1);
     WEBCORE_EXPORT void scrollToPositionWithAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped);
@@ -111,15 +111,14 @@
     virtual void didUpdateScroll() { }
 #endif
 
-    // Functions for controlling if you can scroll past the end of the document.
-    bool constrainsScrollingToContentEdge() const { return m_constrainsScrollingToContentEdge; }
-    void setConstrainsScrollingToContentEdge(bool constrainsScrollingToContentEdge) { m_constrainsScrollingToContentEdge = constrainsScrollingToContentEdge; }
+    ScrollClamping scrollClamping() const { return m_scrollClamping; }
+    void setScrollClamping(ScrollClamping clamping) { m_scrollClamping = clamping; }
 
     void setVerticalScrollElasticity(ScrollElasticity scrollElasticity) { m_verticalScrollElasticity = scrollElasticity; }
-    ScrollElasticity verticalScrollElasticity() const { return static_cast<ScrollElasticity>(m_verticalScrollElasticity); }
+    ScrollElasticity verticalScrollElasticity() const { return m_verticalScrollElasticity; }
 
     void setHorizontalScrollElasticity(ScrollElasticity scrollElasticity) { m_horizontalScrollElasticity = scrollElasticity; }
-    ScrollElasticity horizontalScrollElasticity() const { return static_cast<ScrollElasticity>(m_horizontalScrollElasticity); }
+    ScrollElasticity horizontalScrollElasticity() const { return m_horizontalScrollElasticity; }
 
     virtual ScrollbarMode horizontalScrollbarMode() const { return ScrollbarAuto; }
     virtual ScrollbarMode verticalScrollbarMode() const { return ScrollbarAuto; }
@@ -167,7 +166,7 @@
 
     bool hasOverlayScrollbars() const;
     WEBCORE_EXPORT virtual void setScrollbarOverlayStyle(ScrollbarOverlayStyle);
-    ScrollbarOverlayStyle scrollbarOverlayStyle() const { return static_cast<ScrollbarOverlayStyle>(m_scrollbarOverlayStyle); }
+    ScrollbarOverlayStyle scrollbarOverlayStyle() const { return m_scrollbarOverlayStyle; }
     void invalidateScrollbars();
     bool useDarkAppearanceForScrollbars() const;
 
@@ -250,8 +249,8 @@
     WEBCORE_EXPORT virtual bool scrolledToLeft() const;
     WEBCORE_EXPORT virtual bool scrolledToRight() const;
 
-    ScrollType currentScrollType() const { return static_cast<ScrollType>(m_currentScrollType); }
-    void setCurrentScrollType(ScrollType scrollType) { m_currentScrollType = static_cast<unsigned>(scrollType); }
+    ScrollType currentScrollType() const { return m_currentScrollType; }
+    void setCurrentScrollType(ScrollType scrollType) { m_currentScrollType = scrollType; }
 
     bool scrollShouldClearLatchedState() const { return m_scrollShouldClearLatchedState; }
     void setScrollShouldClearLatchedState(bool shouldClear) { m_scrollShouldClearLatchedState = shouldClear; }
@@ -396,19 +395,19 @@
     // vertical-rl / rtl            YES                     YES
     IntPoint m_scrollOrigin;
 
-    unsigned m_constrainsScrollingToContentEdge : 1;
+    ScrollClamping m_scrollClamping { ScrollClamping::Clamped };
 
-    unsigned m_inLiveResize : 1;
+    ScrollElasticity m_verticalScrollElasticity { ScrollElasticityNone };
+    ScrollElasticity m_horizontalScrollElasticity { ScrollElasticityNone };
 
-    unsigned m_verticalScrollElasticity : 2; // ScrollElasticity
-    unsigned m_horizontalScrollElasticity : 2; // ScrollElasticity
+    ScrollbarOverlayStyle m_scrollbarOverlayStyle { ScrollbarOverlayStyle::ScrollbarOverlayStyleDefault };
 
-    unsigned m_scrollbarOverlayStyle : 2; // ScrollbarOverlayStyle
+    ScrollType m_currentScrollType { ScrollType::User };
+    ScrollBehaviorStatus m_currentScrollBehaviorStatus { ScrollBehaviorStatus::NotInAnimation };
 
-    unsigned m_scrollOriginChanged : 1;
-    unsigned m_currentScrollType : 1; // ScrollType
-    unsigned m_scrollShouldClearLatchedState : 1;
-    unsigned m_currentScrollBehaviorStatus : 1;
+    bool m_inLiveResize { false };
+    bool m_scrollOriginChanged { false };
+    bool m_scrollShouldClearLatchedState { false };
 };
 
 WTF::TextStream& operator<<(WTF::TextStream&, const ScrollableArea&);

Modified: trunk/Source/WebCore/platform/ScrollingEffectsController.cpp (283523 => 283524)


--- trunk/Source/WebCore/platform/ScrollingEffectsController.cpp	2021-10-04 23:23:27 UTC (rev 283523)
+++ trunk/Source/WebCore/platform/ScrollingEffectsController.cpp	2021-10-04 23:37:24 UTC (rev 283524)
@@ -307,19 +307,14 @@
     m_client.keyboardScrollingAnimator()->updateKeyboardScrollPosition(currentTime);
 }
 
-void ScrollingEffectsController::scrollToOffsetForAnimation(const FloatPoint& scrollOffset)
+void ScrollingEffectsController::scrollAnimationDidUpdate(ScrollAnimation& animation, const FloatPoint& currentOffset)
 {
-    auto currentOffset = m_client.scrollOffset();
-    auto scrollDelta = scrollOffset - currentOffset;
-    m_client.immediateScrollBy(scrollDelta);
-}
+    auto scrollDelta = currentOffset - m_client.scrollOffset();
 
-void ScrollingEffectsController::scrollAnimationDidUpdate(ScrollAnimation& animation, const FloatPoint& currentOffset)
-{
-    LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController " << this << " scrollAnimationDidUpdate " << animation << " (main thread " << isMainThread() << ")");
+    LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController " << this << " scrollAnimationDidUpdate " << animation << " (main thread " << isMainThread() << ") scrolling by " << scrollDelta);
     UNUSED_PARAM(animation);
 
-    scrollToOffsetForAnimation(currentOffset);
+    m_client.immediateScrollBy(scrollDelta);
 }
 
 void ScrollingEffectsController::scrollAnimationWillStart(ScrollAnimation& animation)

Modified: trunk/Source/WebCore/platform/ScrollingEffectsController.h (283523 => 283524)


--- trunk/Source/WebCore/platform/ScrollingEffectsController.h	2021-10-04 23:23:27 UTC (rev 283523)
+++ trunk/Source/WebCore/platform/ScrollingEffectsController.h	2021-10-04 23:37:24 UTC (rev 283524)
@@ -85,9 +85,7 @@
     virtual void setScrollBehaviorStatus(ScrollBehaviorStatus) = 0;
     virtual ScrollBehaviorStatus scrollBehaviorStatus() const = 0;
 
-    // FIXME: use ScrollClamping to collapse these to one.
-    virtual void immediateScrollBy(const FloatSize&) = 0;
-    virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) = 0;
+    virtual void immediateScrollBy(const FloatSize&, ScrollClamping = ScrollClamping::Clamped) = 0;
 
     // If the current scroll position is within the overhang area, this function will cause
     // the page to scroll to the nearest boundary point.
@@ -212,7 +210,6 @@
 #endif
 
     void startOrStopAnimationCallbacks();
-    void scrollToOffsetForAnimation(const FloatPoint& scrollOffset);
 
     // ScrollAnimationClient
     void scrollAnimationDidUpdate(ScrollAnimation&, const FloatPoint& /* currentOffset */) final;

Modified: trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm (283523 => 283524)


--- trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm	2021-10-04 23:23:27 UTC (rev 283523)
+++ trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm	2021-10-04 23:37:24 UTC (rev 283524)
@@ -315,7 +315,7 @@
     }
 
     if (!deltaToScroll.isZero())
-        m_client.immediateScrollByWithoutContentEdgeConstraints(deltaToScroll);
+        m_client.immediateScrollBy(deltaToScroll, ScrollClamping::Unclamped);
 
     bool canStartAnimation = false;
     if (m_momentumScrollInProgress) {
@@ -333,7 +333,7 @@
     LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController::applyScrollDeltaWithStretching() - stretchScrollForce " << m_stretchScrollForce << " move delta " << delta << " dampedDelta " << dampedDelta);
 
     auto stretchAmount = m_client.stretchAmount();
-    m_client.immediateScrollByWithoutContentEdgeConstraints(dampedDelta - stretchAmount);
+    m_client.immediateScrollBy(dampedDelta - stretchAmount, ScrollClamping::Unclamped);
 
     return canStartAnimation;
 }
@@ -402,7 +402,7 @@
 
             LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController::updateRubberBandAnimatingState() - rubberBandDelta " << rubberBandDelta << " stretched " << m_client.stretchAmount() << " moving by " << stretchDelta);
 
-            m_client.immediateScrollByWithoutContentEdgeConstraints(stretchDelta);
+            m_client.immediateScrollBy(stretchDelta, ScrollClamping::Unclamped);
 
             FloatSize newStretch = m_client.stretchAmount();
 

Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (283523 => 283524)


--- trunk/Source/WebCore/rendering/RenderListBox.cpp	2021-10-04 23:23:27 UTC (rev 283523)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp	2021-10-04 23:37:24 UTC (rev 283524)
@@ -90,11 +90,6 @@
 
 RenderListBox::RenderListBox(HTMLSelectElement& element, RenderStyle&& style)
     : RenderBlockFlow(element, WTFMove(style))
-    , m_optionsChanged(true)
-    , m_scrollToRevealSelectionAfterLayout(false)
-    , m_inAutoscroll(false)
-    , m_optionsWidth(0)
-    , m_indexOffset(0)
 {
     view().frameView().addScrollableArea(this);
 }

Modified: trunk/Source/WebCore/rendering/RenderListBox.h (283523 => 283524)


--- trunk/Source/WebCore/rendering/RenderListBox.h	2021-10-04 23:23:27 UTC (rev 283523)
+++ trunk/Source/WebCore/rendering/RenderListBox.h	2021-10-04 23:37:24 UTC (rev 283524)
@@ -173,16 +173,18 @@
 
     bool shouldPlaceVerticalScrollbarOnLeft() const final { return RenderBlockFlow::shouldPlaceVerticalScrollbarOnLeft(); }
 
-    bool m_optionsChanged;
-    bool m_scrollToRevealSelectionAfterLayout;
-    bool m_inAutoscroll;
-    int m_optionsWidth;
-    int m_indexOffset;
+    bool m_optionsChanged { true };
+    bool m_scrollToRevealSelectionAfterLayout { false };
+    bool m_inAutoscroll { false };
+    int m_optionsWidth { 0 };
 
+    RefPtr<Scrollbar> m_vBar;
+
+    int m_indexOffset { 0 };
+
     std::optional<int> m_indexOfFirstVisibleItemInsidePaddingTopArea;
     std::optional<int> m_indexOfFirstVisibleItemInsidePaddingBottomArea;
 
-    RefPtr<Scrollbar> m_vBar;
 };
 
 } // namepace WebCore

Modified: trunk/Source/WebCore/rendering/RenderMarquee.cpp (283523 => 283524)


--- trunk/Source/WebCore/rendering/RenderMarquee.cpp	2021-10-04 23:23:27 UTC (rev 283523)
+++ trunk/Source/WebCore/rendering/RenderMarquee.cpp	2021-10-04 23:37:24 UTC (rev 283524)
@@ -63,7 +63,7 @@
 {
     ASSERT(layer);
     ASSERT(layer->scrollableArea());
-    layer->scrollableArea()->setConstrainsScrollingToContentEdge(false);
+    layer->scrollableArea()->setScrollClamping(ScrollClamping::Unclamped);
 }
 
 RenderMarquee::~RenderMarquee() = default;

Modified: trunk/Source/WebCore/testing/Internals.cpp (283523 => 283524)


--- trunk/Source/WebCore/testing/Internals.cpp	2021-10-04 23:23:27 UTC (rev 283523)
+++ trunk/Source/WebCore/testing/Internals.cpp	2021-10-04 23:37:24 UTC (rev 283524)
@@ -1849,14 +1849,14 @@
         return Exception { InvalidAccessError };
 
     auto& frameView = *document->view();
-    bool constrainsScrollingToContentEdgeOldValue = frameView.constrainsScrollingToContentEdge();
+    auto oldClamping = frameView.scrollClamping();
     bool scrollbarsSuppressedOldValue = frameView.scrollbarsSuppressed();
 
-    frameView.setConstrainsScrollingToContentEdge(false);
+    frameView.setScrollClamping(ScrollClamping::Unclamped);
     frameView.setScrollbarsSuppressed(false);
     frameView.setScrollOffsetFromInternals({ x, y });
     frameView.setScrollbarsSuppressed(scrollbarsSuppressedOldValue);
-    frameView.setConstrainsScrollingToContentEdge(constrainsScrollingToContentEdgeOldValue);
+    frameView.setScrollClamping(oldClamping);
 
     return { };
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to