Title: [259846] trunk/Source/WebCore
Revision
259846
Author
cathiec...@igalia.com
Date
2020-04-09 22:22:16 -0700 (Thu, 09 Apr 2020)

Log Message

Fix up code style for scroll animation
https://bugs.webkit.org/show_bug.cgi?id=210171

Reviewed by Simon Fraser.

1. Use AnimatedScroll instead of bool to indicate animated or not.
2. Remove parameter ScrollRectToVisibleOptions, the autoscroll status is available from EventHandler.
3. In order to keep consistent, use RenderLayer::setScrollPosition instead of RenderLayer::scrollToPosition.
4. Add AnimatedScroll parameter to ScrollView::setContentsScrollPosition, then the scroll animation
can be dealt in FrameView::setScrollPosition.
5. In ScrollView::setScrollPosition, the scroll animation should be cancled before return.

* dom/Element.cpp: Use AnimatedScroll instead of bool.
(WebCore::Element::scrollTo):
(WebCore::Element::setScrollLeft):
(WebCore::Element::setScrollTop):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::scrollTo const): No need to call scrollToOffsetWithAnimation here.
* page/FrameView.cpp:
(WebCore::FrameView::setScrollPosition):
* page/FrameView.h:
* platform/ScrollTypes.h: Add AnimatedScroll.
* platform/ScrollView.cpp:
(WebCore::ScrollView::setContentsScrollPosition): Add parameter AnimatedScroll.
(WebCore::ScrollView::setScrollPosition): Cancel the scroll animation before return.
* platform/ScrollView.h:
* rendering/RenderBox.cpp:
(WebCore::RenderBox::setScrollLeft):
(WebCore::RenderBox::setScrollTop):
(WebCore::RenderBox::setScrollPosition):
* rendering/RenderBox.h:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollToXPosition):
(WebCore::RenderLayer::scrollToYPosition):
(WebCore::RenderLayer::setScrollPosition):
(WebCore::RenderLayer::scrollRectToVisible): Remove AutoscrollStatus.
(WebCore::RenderLayer::autoscroll):
(WebCore::RenderLayer::scrollToPosition): Deleted. Use setScrollPosition instead.
* rendering/RenderLayer.h:
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::setScrollLeft):
(WebCore::RenderListBox::setScrollTop):
* rendering/RenderListBox.h:
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::setScrollLeft):
(WebCore::RenderTextControlSingleLine::setScrollTop):
* rendering/RenderTextControlSingleLine.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (259845 => 259846)


--- trunk/Source/WebCore/ChangeLog	2020-04-10 04:53:55 UTC (rev 259845)
+++ trunk/Source/WebCore/ChangeLog	2020-04-10 05:22:16 UTC (rev 259846)
@@ -1,3 +1,53 @@
+2020-04-09  Cathie Chen  <cathiec...@igalia.com>
+
+        Fix up code style for scroll animation
+        https://bugs.webkit.org/show_bug.cgi?id=210171
+
+        Reviewed by Simon Fraser.
+
+        1. Use AnimatedScroll instead of bool to indicate animated or not.
+        2. Remove parameter ScrollRectToVisibleOptions, the autoscroll status is available from EventHandler.
+        3. In order to keep consistent, use RenderLayer::setScrollPosition instead of RenderLayer::scrollToPosition.
+        4. Add AnimatedScroll parameter to ScrollView::setContentsScrollPosition, then the scroll animation
+        can be dealt in FrameView::setScrollPosition.
+        5. In ScrollView::setScrollPosition, the scroll animation should be cancled before return.
+
+        * dom/Element.cpp: Use AnimatedScroll instead of bool.
+        (WebCore::Element::scrollTo):
+        (WebCore::Element::setScrollLeft):
+        (WebCore::Element::setScrollTop):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::scrollTo const): No need to call scrollToOffsetWithAnimation here.
+        * page/FrameView.cpp:
+        (WebCore::FrameView::setScrollPosition):
+        * page/FrameView.h:
+        * platform/ScrollTypes.h: Add AnimatedScroll.
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::setContentsScrollPosition): Add parameter AnimatedScroll.
+        (WebCore::ScrollView::setScrollPosition): Cancel the scroll animation before return.
+        * platform/ScrollView.h:
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::setScrollLeft):
+        (WebCore::RenderBox::setScrollTop):
+        (WebCore::RenderBox::setScrollPosition):
+        * rendering/RenderBox.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollToXPosition):
+        (WebCore::RenderLayer::scrollToYPosition):
+        (WebCore::RenderLayer::setScrollPosition):
+        (WebCore::RenderLayer::scrollRectToVisible): Remove AutoscrollStatus.
+        (WebCore::RenderLayer::autoscroll):
+        (WebCore::RenderLayer::scrollToPosition): Deleted. Use setScrollPosition instead.
+        * rendering/RenderLayer.h:
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::setScrollLeft):
+        (WebCore::RenderListBox::setScrollTop):
+        * rendering/RenderListBox.h:
+        * rendering/RenderTextControlSingleLine.cpp:
+        (WebCore::RenderTextControlSingleLine::setScrollLeft):
+        (WebCore::RenderTextControlSingleLine::setScrollTop):
+        * rendering/RenderTextControlSingleLine.h:
+
 2020-04-09  Alex Christensen  <achristen...@webkit.org>
 
         IPC serialization of enums should serialize std::underlying_type instead of uint64_t

Modified: trunk/Source/WebCore/dom/Element.cpp (259845 => 259846)


--- trunk/Source/WebCore/dom/Element.cpp	2020-04-10 04:53:55 UTC (rev 259845)
+++ trunk/Source/WebCore/dom/Element.cpp	2020-04-10 05:22:16 UTC (rev 259846)
@@ -950,7 +950,7 @@
         clampToInteger(scrollToOptions.left.value() * renderer->style().effectiveZoom()),
         clampToInteger(scrollToOptions.top.value() * renderer->style().effectiveZoom())
     );
-    bool animated = useSmoothScrolling(scrollToOptions.behavior.valueOr(ScrollBehavior::Auto), this);
+    AnimatedScroll animated = useSmoothScrolling(scrollToOptions.behavior.valueOr(ScrollBehavior::Auto), this) ? AnimatedScroll::Yes : AnimatedScroll::No;
     renderer->setScrollPosition(scrollPosition, ScrollType::Programmatic, clamping, animated);
 }
 
@@ -1293,7 +1293,7 @@
         if (auto* frame = documentFrameWithNonNullView()) {
             // FIXME: Should we use document()->scrollingElement()?
             // See https://bugs.webkit.org/show_bug.cgi?id=205059
-            bool animated = useSmoothScrolling(ScrollBehavior::Auto, document().documentElement());
+            AnimatedScroll animated = useSmoothScrolling(ScrollBehavior::Auto, document().documentElement()) ? AnimatedScroll::Yes : AnimatedScroll::No;
             IntPoint position(static_cast<int>(newLeft * frame->pageZoomFactor() * frame->frameScaleFactor()), frame->view()->scrollY());
             frame->view()->setScrollPosition(position, ScrollClamping::Clamped, animated);
         }
@@ -1302,7 +1302,7 @@
 
     if (auto* renderer = renderBox()) {
         int clampedLeft = clampToInteger(newLeft * renderer->style().effectiveZoom());
-        bool animated = useSmoothScrolling(ScrollBehavior::Auto, this);
+        AnimatedScroll animated = useSmoothScrolling(ScrollBehavior::Auto, this) ? AnimatedScroll::Yes : AnimatedScroll::No;
         renderer->setScrollLeft(clampedLeft, ScrollType::Programmatic, ScrollClamping::Clamped, animated);
         if (auto* scrollableArea = renderer->layer())
             scrollableArea->setScrollShouldClearLatchedState(true);
@@ -1317,7 +1317,7 @@
         if (auto* frame = documentFrameWithNonNullView()) {
             // FIXME: Should we use document()->scrollingElement()?
             // See https://bugs.webkit.org/show_bug.cgi?id=205059
-            bool animated = useSmoothScrolling(ScrollBehavior::Auto, document().documentElement());
+            AnimatedScroll animated = useSmoothScrolling(ScrollBehavior::Auto, document().documentElement()) ? AnimatedScroll::Yes : AnimatedScroll::No;
             IntPoint position(frame->view()->scrollX(), static_cast<int>(newTop * frame->pageZoomFactor() * frame->frameScaleFactor()));
             frame->view()->setScrollPosition(position, ScrollClamping::Clamped, animated);
         }
@@ -1326,7 +1326,7 @@
 
     if (auto* renderer = renderBox()) {
         int clampedTop = clampToInteger(newTop * renderer->style().effectiveZoom());
-        bool animated = useSmoothScrolling(ScrollBehavior::Auto, this);
+        AnimatedScroll animated = useSmoothScrolling(ScrollBehavior::Auto, this) ? AnimatedScroll::Yes : AnimatedScroll::No;
         renderer->setScrollTop(clampedTop, ScrollType::Programmatic, ScrollClamping::Clamped, animated);
         if (auto* scrollableArea = renderer->layer())
             scrollableArea->setScrollShouldClearLatchedState(true);

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (259845 => 259846)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2020-04-10 04:53:55 UTC (rev 259845)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2020-04-10 05:22:16 UTC (rev 259846)
@@ -1688,12 +1688,9 @@
 
     // FIXME: Should we use document()->scrollingElement()?
     // See https://bugs.webkit.org/show_bug.cgi?id=205059
-    if (useSmoothScrolling(scrollToOptions.behavior.valueOr(ScrollBehavior::Auto), document()->documentElement())) {
-        view->scrollToOffsetWithAnimation(layoutPos, ScrollType::Programmatic, clamping);
-        return;
-    }
+    AnimatedScroll animated = useSmoothScrolling(scrollToOptions.behavior.valueOr(ScrollBehavior::Auto), document()->documentElement()) ? AnimatedScroll::Yes : AnimatedScroll::No;
 
-    view->setContentsScrollPosition(layoutPos, clamping);
+    view->setContentsScrollPosition(layoutPos, clamping, animated);
 }
 
 bool DOMWindow::allowedToChangeWindowGeometry() const

Modified: trunk/Source/WebCore/page/FrameView.cpp (259845 => 259846)


--- trunk/Source/WebCore/page/FrameView.cpp	2020-04-10 04:53:55 UTC (rev 259845)
+++ trunk/Source/WebCore/page/FrameView.cpp	2020-04-10 05:22:16 UTC (rev 259846)
@@ -2282,7 +2282,7 @@
     setScrollPosition(IntPoint(bounds.x() - centeringOffsetX - rect.x(), bounds.y() - centeringOffsetY - rect.y()));
 }
 
-void FrameView::setScrollPosition(const ScrollPosition& scrollPosition, ScrollClamping clamping, bool animated)
+void FrameView::setScrollPosition(const ScrollPosition& scrollPosition, ScrollClamping clamping, AnimatedScroll animated)
 {
     LOG_WITH_STREAM(Scrolling, stream << "FrameView::setScrollPosition " << scrollPosition << " , clearing anchor");
 
@@ -2295,7 +2295,7 @@
     Page* page = frame().page();
     if (page && page->isMonitoringWheelEvents())
         scrollAnimator().setWheelEventTestMonitor(page->wheelEventTestMonitor());
-    if (animated)
+    if (animated == AnimatedScroll::Yes)
         scrollToOffsetWithAnimation(scrollOffsetFromPosition(scrollPosition), currentScrollType(), clamping);
     else
         ScrollView::setScrollPosition(scrollPosition, clamping);

Modified: trunk/Source/WebCore/page/FrameView.h (259845 => 259846)


--- trunk/Source/WebCore/page/FrameView.h	2020-04-10 04:53:55 UTC (rev 259845)
+++ trunk/Source/WebCore/page/FrameView.h	2020-04-10 05:22:16 UTC (rev 259846)
@@ -230,7 +230,7 @@
 #if USE(COORDINATED_GRAPHICS)
     WEBCORE_EXPORT void setFixedVisibleContentRect(const IntRect&) final;
 #endif
-    WEBCORE_EXPORT void setScrollPosition(const ScrollPosition&, ScrollClamping = ScrollClamping::Clamped, bool animated = false) final;
+    WEBCORE_EXPORT void setScrollPosition(const ScrollPosition&, ScrollClamping = ScrollClamping::Clamped, AnimatedScroll = AnimatedScroll::No) final;
     void restoreScrollbar();
     void scheduleScrollToFocusedElement(SelectionRevealMode);
     void scrollToFocusedElementImmediatelyIfNeeded();

Modified: trunk/Source/WebCore/platform/ScrollTypes.h (259845 => 259846)


--- trunk/Source/WebCore/platform/ScrollTypes.h	2020-04-10 04:53:55 UTC (rev 259845)
+++ trunk/Source/WebCore/platform/ScrollTypes.h	2020-04-10 05:22:16 UTC (rev 259846)
@@ -60,6 +60,11 @@
     InNonNativeAnimation,
 };
 
+enum class AnimatedScroll : uint8_t {
+    No,
+    Yes
+};
+
 inline ScrollDirection logicalToPhysical(ScrollLogicalDirection direction, bool isVertical, bool isFlipped)
 {
     switch (direction) {

Modified: trunk/Source/WebCore/platform/ScrollView.cpp (259845 => 259846)


--- trunk/Source/WebCore/platform/ScrollView.cpp	2020-04-10 04:53:55 UTC (rev 259845)
+++ trunk/Source/WebCore/platform/ScrollView.cpp	2020-04-10 05:22:16 UTC (rev 259846)
@@ -207,13 +207,13 @@
     return scrollPosition();
 }
 
-void ScrollView::setContentsScrollPosition(const IntPoint& position, ScrollClamping clamping)
+void ScrollView::setContentsScrollPosition(const IntPoint& position, ScrollClamping clamping, AnimatedScroll animated)
 {
 #if PLATFORM(IOS_FAMILY)
     if (platformWidget())
         setActualScrollPosition(position);
 #endif
-    setScrollPosition(position, clamping);
+    setScrollPosition(position, clamping, animated);
 }
 
 FloatRect ScrollView::exposedContentRect() const
@@ -514,7 +514,7 @@
     updateCompositingLayersAfterScrolling();
 }
 
-void ScrollView::setScrollPosition(const ScrollPosition& scrollPosition, ScrollClamping clamping, bool/* animated*/)
+void ScrollView::setScrollPosition(const ScrollPosition& scrollPosition, ScrollClamping clamping, AnimatedScroll/* animated*/)
 {
     LOG_WITH_STREAM(Scrolling, stream << "ScrollView::setScrollPosition " << scrollPosition);
 
@@ -526,14 +526,13 @@
         return;
     }
 
+    if (currentScrollBehaviorStatus() == ScrollBehaviorStatus::InNonNativeAnimation)
+        scrollAnimator().cancelAnimations();
+
     ScrollPosition newScrollPosition = (!delegatesScrolling() && clamping == ScrollClamping::Clamped) ? adjustScrollPositionWithinRange(scrollPosition) : scrollPosition;
-
     if ((!delegatesScrolling() || currentScrollType() == ScrollType::User) && currentScrollBehaviorStatus() == ScrollBehaviorStatus::NotInAnimation && newScrollPosition == this->scrollPosition())
         return;
 
-    if (currentScrollBehaviorStatus() == ScrollBehaviorStatus::InNonNativeAnimation)
-        scrollAnimator().cancelAnimations();
-
     if (!requestScrollPositionUpdate(newScrollPosition, currentScrollType(), clamping))
         updateScrollbars(newScrollPosition);
 

Modified: trunk/Source/WebCore/platform/ScrollView.h (259845 => 259846)


--- trunk/Source/WebCore/platform/ScrollView.h	2020-04-10 04:53:55 UTC (rev 259845)
+++ trunk/Source/WebCore/platform/ScrollView.h	2020-04-10 05:22:16 UTC (rev 259846)
@@ -232,7 +232,7 @@
 
     // Scroll position used by web-exposed features (has legacy iOS behavior).
     WEBCORE_EXPORT IntPoint contentsScrollPosition() const;
-    void setContentsScrollPosition(const IntPoint&, ScrollClamping = ScrollClamping::Clamped);
+    void setContentsScrollPosition(const IntPoint&, ScrollClamping = ScrollClamping::Clamped, AnimatedScroll = AnimatedScroll::No);
 
 #if PLATFORM(IOS_FAMILY)
     int actualScrollX() const { return unobscuredContentRect().x(); }
@@ -262,7 +262,7 @@
     ScrollPosition cachedScrollPosition() const { return m_cachedScrollPosition; }
 
     // Functions for scrolling the view.
-    virtual void setScrollPosition(const ScrollPosition&, ScrollClamping = ScrollClamping::Clamped, bool animated = false);
+    virtual void setScrollPosition(const ScrollPosition&, ScrollClamping = ScrollClamping::Clamped, AnimatedScroll = AnimatedScroll::No);
 
     void scrollBy(const IntSize& s) { return setScrollPosition(scrollPosition() + s); }
 

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (259845 => 259846)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2020-04-10 04:53:55 UTC (rev 259845)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2020-04-10 05:22:16 UTC (rev 259846)
@@ -581,7 +581,7 @@
     layer.scrollAnimator().setWheelEventTestMonitor(page.wheelEventTestMonitor());
 }
 
-void RenderBox::setScrollLeft(int newLeft, ScrollType scrollType, ScrollClamping clamping, bool animated)
+void RenderBox::setScrollLeft(int newLeft, ScrollType scrollType, ScrollClamping clamping, AnimatedScroll animated)
 {
     if (!hasOverflowClip() || !layer())
         return;
@@ -589,7 +589,7 @@
     layer()->scrollToXPosition(newLeft, scrollType, clamping, animated);
 }
 
-void RenderBox::setScrollTop(int newTop, ScrollType scrollType, ScrollClamping clamping, bool animated)
+void RenderBox::setScrollTop(int newTop, ScrollType scrollType, ScrollClamping clamping, AnimatedScroll animated)
 {
     if (!hasOverflowClip() || !layer())
         return;
@@ -597,12 +597,12 @@
     layer()->scrollToYPosition(newTop, scrollType, clamping, animated);
 }
 
-void RenderBox::setScrollPosition(const ScrollPosition& position, ScrollType scrollType, ScrollClamping clamping, bool animated)
+void RenderBox::setScrollPosition(const ScrollPosition& position, ScrollType scrollType, ScrollClamping clamping, AnimatedScroll animated)
 {
     if (!hasOverflowClip() || !layer())
         return;
     setupWheelEventMonitor(*layer());
-    layer()->scrollToPosition(position, scrollType, clamping, animated);
+    layer()->setScrollPosition(position, scrollType, clamping, animated);
 }
 
 void RenderBox::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) const

Modified: trunk/Source/WebCore/rendering/RenderBox.h (259845 => 259846)


--- trunk/Source/WebCore/rendering/RenderBox.h	2020-04-10 04:53:55 UTC (rev 259845)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2020-04-10 05:22:16 UTC (rev 259846)
@@ -247,9 +247,9 @@
     virtual int scrollTop() const;
     virtual int scrollWidth() const;
     virtual int scrollHeight() const;
-    virtual void setScrollLeft(int, ScrollType, ScrollClamping = ScrollClamping::Clamped, bool animated = false);
-    virtual void setScrollTop(int, ScrollType, ScrollClamping = ScrollClamping::Clamped, bool animated = false);
-    void setScrollPosition(const ScrollPosition&, ScrollType, ScrollClamping = ScrollClamping::Clamped, bool animated = false);
+    virtual void setScrollLeft(int, ScrollType, ScrollClamping = ScrollClamping::Clamped, AnimatedScroll = AnimatedScroll::No);
+    virtual void setScrollTop(int, ScrollType, ScrollClamping = ScrollClamping::Clamped, AnimatedScroll = AnimatedScroll::No);
+    void setScrollPosition(const ScrollPosition&, ScrollType, ScrollClamping = ScrollClamping::Clamped, AnimatedScroll = AnimatedScroll::No);
 
     LayoutUnit marginTop() const override { return m_marginBox.top(); }
     LayoutUnit marginBottom() const override { return m_marginBox.bottom(); }

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (259845 => 259846)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2020-04-10 04:53:55 UTC (rev 259845)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2020-04-10 05:22:16 UTC (rev 259846)
@@ -2590,21 +2590,21 @@
     m_postLayoutScrollPosition = WTF::nullopt;
 }
 
-void RenderLayer::scrollToXPosition(int x, ScrollType scrollType, ScrollClamping clamping, bool animated)
+void RenderLayer::scrollToXPosition(int x, ScrollType scrollType, ScrollClamping clamping, AnimatedScroll animated)
 {
     ScrollPosition position(x, m_scrollPosition.y());
-    scrollToPosition(position, scrollType, clamping, animated);
+    setScrollPosition(position, scrollType, clamping, animated);
 }
 
-void RenderLayer::scrollToYPosition(int y, ScrollType scrollType, ScrollClamping clamping, bool animated)
+void RenderLayer::scrollToYPosition(int y, ScrollType scrollType, ScrollClamping clamping, AnimatedScroll animated)
 {
     ScrollPosition position(m_scrollPosition.x(), y);
-    scrollToPosition(position, scrollType, clamping, animated);
+    setScrollPosition(position, scrollType, clamping, animated);
 }
 
-void RenderLayer::scrollToPosition(const ScrollPosition& position, ScrollType scrollType, ScrollClamping clamping, bool animated)
+void RenderLayer::setScrollPosition(const ScrollPosition& position, ScrollType scrollType, ScrollClamping clamping, AnimatedScroll animated)
 {
-    if (animated)
+    if (animated == AnimatedScroll::Yes)
         scrollToOffsetWithAnimation(scrollOffsetFromPosition(position), scrollType, clamping);
     else
         scrollToOffset(scrollOffsetFromPosition(position), scrollType, clamping);
@@ -2805,7 +2805,7 @@
     return box->hasHorizontalOverflow() || box->hasVerticalOverflow();
 }
 
-void RenderLayer::scrollRectToVisible(const LayoutRect& absoluteRect, bool insideFixed, const ScrollRectToVisibleOptions& options, AutoscrollStatus autoscrollStatus)
+void RenderLayer::scrollRectToVisible(const LayoutRect& absoluteRect, bool insideFixed, const ScrollRectToVisibleOptions& options)
 {
     LOG_WITH_STREAM(Scrolling, stream << "Layer " << this << " scrollRectToVisible " << absoluteRect);
 
@@ -2812,6 +2812,7 @@
     LayoutRect newRect = absoluteRect;
     FrameView& frameView = renderer().view().frameView();
     auto* parentLayer = enclosingContainingBlockLayer(*this, CrossFrameBoundaries::No);
+    bool autoscrollNotInProgress = !renderer().frame().eventHandler().autoscrollInProgress();
 
     if (allowsCurrentScroll()) {
         // Don't scroll to reveal an overflow layer that is restricted by the -webkit-line-clamp property.
@@ -2830,8 +2831,10 @@
         ScrollOffset clampedScrollOffset = clampScrollOffset(scrollOffset() + toIntSize(roundedIntRect(revealRect).location()));
         if (clampedScrollOffset != scrollOffset() || currentScrollBehaviorStatus() != ScrollBehaviorStatus::NotInAnimation) {
             ScrollOffset oldScrollOffset = scrollOffset();
-            bool animated = autoscrollStatus == AutoscrollStatus::NotInProgress && useSmoothScrolling(options.behavior, box->element());
-            scrollToPosition(scrollPositionFromOffset(clampedScrollOffset), ScrollType::Programmatic, ScrollClamping::Clamped, animated);
+            AnimatedScroll animated = AnimatedScroll::No;
+            if (autoscrollNotInProgress && useSmoothScrolling(options.behavior, box->element()))
+                animated = AnimatedScroll::Yes;
+            setScrollPosition(scrollPositionFromOffset(clampedScrollOffset), ScrollType::Programmatic, ScrollClamping::Clamped, animated);
             IntSize scrollOffsetDifference = clampedScrollOffset - oldScrollOffset;
             localExposeRect.move(-scrollOffsetDifference);
             newRect = LayoutRect(box->localToAbsoluteQuad(FloatQuad(FloatRect(localExposeRect)), UseTransforms).boundingBox());
@@ -2857,7 +2860,11 @@
                 scrollPosition = scrollPosition.constrainedBetween(IntPoint(), IntPoint(frameView.contentsSize()));
                 // FIXME: Should we use contentDocument()->scrollingElement()?
                 // See https://bugs.webkit.org/show_bug.cgi?id=205059
-                bool animated = autoscrollStatus == AutoscrollStatus::NotInProgress && ownerElement->contentDocument() && useSmoothScrolling(options.behavior, ownerElement->contentDocument()->documentElement());
+                AnimatedScroll animated = AnimatedScroll::No;
+                if (autoscrollNotInProgress
+                    && ownerElement->contentDocument()
+                    && useSmoothScrolling(options.behavior, ownerElement->contentDocument()->documentElement()))
+                    animated = AnimatedScroll::Yes;
                 frameView.setScrollPosition(scrollPosition, ScrollClamping::Clamped, animated);
 
                 if (options.shouldAllowCrossOriginScrolling == ShouldAllowCrossOriginScrolling::Yes || frameView.safeToPropagateScrollToParent()) {
@@ -2900,7 +2907,9 @@
                 ScrollOffset clampedScrollPosition = roundedIntPoint(revealRect.location()).constrainedBetween(minScrollPosition, maxScrollPosition);
                 // FIXME: Should we use document()->scrollingElement()?
                 // See https://bugs.webkit.org/show_bug.cgi?id=205059
-                bool animated = autoscrollStatus == AutoscrollStatus::NotInProgress && useSmoothScrolling(options.behavior, renderer().document().documentElement());
+                AnimatedScroll animated = AnimatedScroll::No;
+                if (autoscrollNotInProgress && useSmoothScrolling(options.behavior, renderer().document().documentElement()))
+                    animated = AnimatedScroll::Yes;
                 frameView.setScrollPosition(clampedScrollPosition, ScrollClamping::Clamped, animated);
             }
 
@@ -3040,7 +3049,7 @@
 void RenderLayer::autoscroll(const IntPoint& positionInWindow)
 {
     IntPoint currentDocumentPosition = renderer().view().frameView().windowToContents(positionInWindow);
-    scrollRectToVisible(LayoutRect(currentDocumentPosition, LayoutSize(1, 1)), false, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::Yes }, AutoscrollStatus::InProgress);
+    scrollRectToVisible(LayoutRect(currentDocumentPosition, LayoutSize(1, 1)), false, { SelectionRevealMode::Reveal, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ShouldAllowCrossOriginScrolling::Yes });
 }
 
 bool RenderLayer::canResize() const

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (259845 => 259846)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2020-04-10 04:53:55 UTC (rev 259845)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2020-04-10 05:22:16 UTC (rev 259846)
@@ -450,9 +450,9 @@
     WEBCORE_EXPORT void scrollToOffset(const ScrollOffset&, ScrollType = ScrollType::Programmatic, ScrollClamping = ScrollClamping::Clamped);
     WEBCORE_EXPORT void scrollToOffsetWithAnimation(const ScrollOffset&, ScrollType = ScrollType::Programmatic, ScrollClamping = ScrollClamping::Clamped);
 
-    void scrollToXPosition(int x, ScrollType, ScrollClamping = ScrollClamping::Clamped, bool animated = false);
-    void scrollToYPosition(int y, ScrollType, ScrollClamping = ScrollClamping::Clamped, bool animated = false);
-    void scrollToPosition(const ScrollPosition&, ScrollType, ScrollClamping = ScrollClamping::Clamped, bool animated = false);
+    void scrollToXPosition(int x, ScrollType, ScrollClamping = ScrollClamping::Clamped, AnimatedScroll = AnimatedScroll::No);
+    void scrollToYPosition(int y, ScrollType, ScrollClamping = ScrollClamping::Clamped, AnimatedScroll = AnimatedScroll::No);
+    void setScrollPosition(const ScrollPosition&, ScrollType, ScrollClamping = ScrollClamping::Clamped, AnimatedScroll = AnimatedScroll::No);
 
     // These are only used by marquee.
     void scrollToXOffset(int x) { scrollToOffset(ScrollOffset(x, scrollOffset().y()), ScrollType::Programmatic, ScrollClamping::Unclamped); }
@@ -466,9 +466,8 @@
 
     void availableContentSizeChanged(AvailableSizeChangeReason) final;
 
-    enum AutoscrollStatus { NotInProgress, InProgress };
     // "absoluteRect" is in scaled document coordinates.
-    void scrollRectToVisible(const LayoutRect& absoluteRect, bool insideFixed, const ScrollRectToVisibleOptions&, AutoscrollStatus = AutoscrollStatus::NotInProgress);
+    void scrollRectToVisible(const LayoutRect& absoluteRect, bool insideFixed, const ScrollRectToVisibleOptions&);
 
     bool scrollsOverflow() const;
     bool hasScrollableHorizontalOverflow() const;

Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (259845 => 259846)


--- trunk/Source/WebCore/rendering/RenderListBox.cpp	2020-04-10 04:53:55 UTC (rev 259845)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp	2020-04-10 05:22:16 UTC (rev 259846)
@@ -743,7 +743,7 @@
     return 0;
 }
 
-void RenderListBox::setScrollLeft(int, ScrollType, ScrollClamping, bool)
+void RenderListBox::setScrollLeft(int, ScrollType, ScrollClamping, AnimatedScroll)
 {
 }
 
@@ -760,7 +760,7 @@
     renderer.scrollAnimator().setWheelEventTestMonitor(renderer.page().wheelEventTestMonitor());
 }
 
-void RenderListBox::setScrollTop(int newTop, ScrollType, ScrollClamping, bool)
+void RenderListBox::setScrollTop(int newTop, ScrollType, ScrollClamping, AnimatedScroll)
 {
     // Determine an index and scroll to it.    
     int index = newTop / itemHeight();

Modified: trunk/Source/WebCore/rendering/RenderListBox.h (259845 => 259846)


--- trunk/Source/WebCore/rendering/RenderListBox.h	2020-04-10 04:53:55 UTC (rev 259845)
+++ trunk/Source/WebCore/rendering/RenderListBox.h	2020-04-10 05:22:16 UTC (rev 259846)
@@ -106,8 +106,8 @@
     int scrollTop() const override;
     int scrollWidth() const override;
     int scrollHeight() const override;
-    void setScrollLeft(int, ScrollType, ScrollClamping, bool) override;
-    void setScrollTop(int, ScrollType, ScrollClamping, bool) override;
+    void setScrollLeft(int, ScrollType, ScrollClamping, AnimatedScroll) override;
+    void setScrollTop(int, ScrollType, ScrollClamping, AnimatedScroll) override;
 
     bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override;
 

Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp (259845 => 259846)


--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp	2020-04-10 04:53:55 UTC (rev 259845)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp	2020-04-10 05:22:16 UTC (rev 259846)
@@ -380,13 +380,13 @@
     return RenderBlockFlow::scrollTop();
 }
 
-void RenderTextControlSingleLine::setScrollLeft(int newLeft, ScrollType, ScrollClamping, bool)
+void RenderTextControlSingleLine::setScrollLeft(int newLeft, ScrollType, ScrollClamping, AnimatedScroll)
 {
     if (innerTextElement())
         innerTextElement()->setScrollLeft(newLeft);
 }
 
-void RenderTextControlSingleLine::setScrollTop(int newTop, ScrollType, ScrollClamping, bool)
+void RenderTextControlSingleLine::setScrollTop(int newTop, ScrollType, ScrollClamping, AnimatedScroll)
 {
     if (innerTextElement())
         innerTextElement()->setScrollTop(newTop);

Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h (259845 => 259846)


--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h	2020-04-10 04:53:55 UTC (rev 259845)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h	2020-04-10 05:22:16 UTC (rev 259846)
@@ -57,8 +57,8 @@
     int scrollTop() const override;
     int scrollWidth() const override;
     int scrollHeight() const override;
-    void setScrollLeft(int, ScrollType, ScrollClamping, bool) override;
-    void setScrollTop(int, ScrollType, ScrollClamping, bool) override;
+    void setScrollLeft(int, ScrollType, ScrollClamping, AnimatedScroll) override;
+    void setScrollTop(int, ScrollType, ScrollClamping, AnimatedScroll) override;
     bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint()) final;
     bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = 0) final;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to