Title: [264151] trunk/Source/WebCore
Revision
264151
Author
[email protected]
Date
2020-07-08 23:11:20 -0700 (Wed, 08 Jul 2020)

Log Message

Allow ScrollableArea to ask if a user scroll is in progress
https://bugs.webkit.org/show_bug.cgi?id=214121

Reviewed by Wenson Hsieh.

Work towards fixing scrolling stutters on layouting pages using scroll snap, like tesla.com.

ScrollableArea::updateScrollSnapState(), which happens as a result of layout, should not set a new
scroll position if a user scroll is in progress. ScrollController already tracks m_inScrollGesture,
so in the first instance just refactor the code to return that. Future changes will check
for scrolling thread activity.

* page/FrameView.cpp:
(WebCore::FrameView::isUserScrollInProgress const):
(WebCore::FrameView::isRubberBandInProgress const):
* page/FrameView.h:
* platform/ScrollAnimator.h:
(WebCore::ScrollAnimator::ScrollAnimator::isUserScrollInProgress const):
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::updateScrollSnapState):
* platform/ScrollableArea.h:
(WebCore::ScrollableArea::isUserScrollInProgress const):
* platform/cocoa/ScrollController.h:
* platform/cocoa/ScrollController.mm:
(WebCore::ScrollController::isUserScrollInProgress const):
* platform/mac/ScrollAnimatorMac.h:
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::isUserScrollInProgress const):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::isUserScrollInProgress const):
(WebCore::RenderLayer::isRubberBandInProgress const):
* rendering/RenderLayer.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (264150 => 264151)


--- trunk/Source/WebCore/ChangeLog	2020-07-09 06:10:46 UTC (rev 264150)
+++ trunk/Source/WebCore/ChangeLog	2020-07-09 06:11:20 UTC (rev 264151)
@@ -1,3 +1,38 @@
+2020-07-08  Simon Fraser  <[email protected]>
+
+        Allow ScrollableArea to ask if a user scroll is in progress
+        https://bugs.webkit.org/show_bug.cgi?id=214121
+
+        Reviewed by Wenson Hsieh.
+
+        Work towards fixing scrolling stutters on layouting pages using scroll snap, like tesla.com.
+
+        ScrollableArea::updateScrollSnapState(), which happens as a result of layout, should not set a new
+        scroll position if a user scroll is in progress. ScrollController already tracks m_inScrollGesture,
+        so in the first instance just refactor the code to return that. Future changes will check
+        for scrolling thread activity.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::isUserScrollInProgress const):
+        (WebCore::FrameView::isRubberBandInProgress const):
+        * page/FrameView.h:
+        * platform/ScrollAnimator.h:
+        (WebCore::ScrollAnimator::ScrollAnimator::isUserScrollInProgress const):
+        * platform/ScrollableArea.cpp:
+        (WebCore::ScrollableArea::updateScrollSnapState):
+        * platform/ScrollableArea.h:
+        (WebCore::ScrollableArea::isUserScrollInProgress const):
+        * platform/cocoa/ScrollController.h:
+        * platform/cocoa/ScrollController.mm:
+        (WebCore::ScrollController::isUserScrollInProgress const):
+        * platform/mac/ScrollAnimatorMac.h:
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::ScrollAnimatorMac::isUserScrollInProgress const):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::isUserScrollInProgress const):
+        (WebCore::RenderLayer::isRubberBandInProgress const):
+        * rendering/RenderLayer.h:
+
 2020-07-08  Andres Gonzalez  <[email protected]>
 
         Implementation of AXIsolatedObject::setSelectedVisiblePositionRange.

Modified: trunk/Source/WebCore/page/FrameView.cpp (264150 => 264151)


--- trunk/Source/WebCore/page/FrameView.cpp	2020-07-09 06:10:46 UTC (rev 264150)
+++ trunk/Source/WebCore/page/FrameView.cpp	2020-07-09 06:11:20 UTC (rev 264151)
@@ -2605,21 +2605,25 @@
     }
 }
 
+bool FrameView::isUserScrollInProgress() const
+{
+    if (auto scrollAnimator = existingScrollAnimator())
+        return scrollAnimator->isUserScrollInProgress();
+
+    return false;
+}
+
 bool FrameView::isRubberBandInProgress() const
 {
     if (scrollbarsSuppressed())
         return false;
 
-    // If the scrolling thread updates the scroll position for this FrameView, then we should return
-    // ScrollingCoordinator::isRubberBandInProgress().
     if (auto scrollingCoordinator = this->scrollingCoordinator()) {
         if (!scrollingCoordinator->shouldUpdateScrollLayerPositionSynchronously(*this))
             return scrollingCoordinator->isRubberBandInProgress();
     }
 
-    // If the main thread updates the scroll position for this FrameView, we should return
-    // ScrollAnimator::isRubberBandInProgress().
-    if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
+    if (auto scrollAnimator = existingScrollAnimator())
         return scrollAnimator->isRubberBandInProgress();
 
     return false;

Modified: trunk/Source/WebCore/page/FrameView.h (264150 => 264151)


--- trunk/Source/WebCore/page/FrameView.h	2020-07-09 06:10:46 UTC (rev 264150)
+++ trunk/Source/WebCore/page/FrameView.h	2020-07-09 06:11:20 UTC (rev 264151)
@@ -238,6 +238,7 @@
     void updateLayerPositionsAfterScrolling() final;
     void updateCompositingLayersAfterScrolling() final;
     bool requestScrollPositionUpdate(const ScrollPosition&, ScrollType = ScrollType::User, ScrollClamping = ScrollClamping::Clamped) final;
+    bool isUserScrollInProgress() const final;
     bool isRubberBandInProgress() const final;
     WEBCORE_EXPORT ScrollPosition minimumScrollPosition() const final;
     WEBCORE_EXPORT ScrollPosition maximumScrollPosition() const final;

Modified: trunk/Source/WebCore/platform/ScrollAnimator.h (264150 => 264151)


--- trunk/Source/WebCore/platform/ScrollAnimator.h	2020-07-09 06:10:46 UTC (rev 264150)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h	2020-07-09 06:11:20 UTC (rev 264151)
@@ -124,6 +124,7 @@
 
     virtual void notifyContentAreaScrolled(const FloatSize& delta) { UNUSED_PARAM(delta); }
 
+    virtual bool isUserScrollInProgress() const { return false; }
     virtual bool isRubberBandInProgress() const { return false; }
     virtual bool isScrollSnapInProgress() const { return false; }
 

Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (264150 => 264151)


--- trunk/Source/WebCore/platform/ScrollableArea.cpp	2020-07-09 06:10:46 UTC (rev 264150)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp	2020-07-09 06:11:20 UTC (rev 264151)
@@ -570,9 +570,9 @@
     if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
         scrollAnimator->updateScrollSnapState();
 
-    LOG_WITH_STREAM(ScrollSnap, stream << *this << " updateScrollSnapState: isScrollSnapInProgress " << isScrollSnapInProgress());
+    LOG_WITH_STREAM(ScrollSnap, stream << *this << " updateScrollSnapState: isScrollSnapInProgress " << isScrollSnapInProgress() << " isUserScrollInProgress " << isUserScrollInProgress());
 
-    if (isScrollSnapInProgress())
+    if (isScrollSnapInProgress() || isUserScrollInProgress())
         return;
 
     IntPoint currentPosition = scrollPosition();

Modified: trunk/Source/WebCore/platform/ScrollableArea.h (264150 => 264151)


--- trunk/Source/WebCore/platform/ScrollableArea.h	2020-07-09 06:10:46 UTC (rev 264150)
+++ trunk/Source/WebCore/platform/ScrollableArea.h	2020-07-09 06:11:20 UTC (rev 264151)
@@ -305,6 +305,7 @@
     // Returns the bounding box of this scrollable area, in the coordinate system of the enclosing scroll view.
     virtual IntRect scrollableAreaBoundingBox(bool* = nullptr) const = 0;
 
+    virtual bool isUserScrollInProgress() const { return false; }
     virtual bool isRubberBandInProgress() const { return false; }
     virtual bool isScrollSnapInProgress() const { return false; }
 

Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.h (264150 => 264151)


--- trunk/Source/WebCore/platform/cocoa/ScrollController.h	2020-07-09 06:10:46 UTC (rev 264150)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.h	2020-07-09 06:11:20 UTC (rev 264151)
@@ -137,6 +137,7 @@
     bool handleWheelEvent(const PlatformWheelEvent&);
 #endif
 
+    bool isUserScrollInProgress() const;
     bool isRubberBandInProgress() const;
     bool isScrollSnapInProgress() const;
 

Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.mm (264150 => 264151)


--- trunk/Source/WebCore/platform/cocoa/ScrollController.mm	2020-07-09 06:10:46 UTC (rev 264150)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.mm	2020-07-09 06:11:20 UTC (rev 264151)
@@ -455,6 +455,15 @@
 }
 #endif
 
+bool ScrollController::isUserScrollInProgress() const
+{
+#if PLATFORM(MAC)
+    return m_inScrollGesture;
+#else
+    return false;
+#endif
+}
+
 bool ScrollController::isRubberBandInProgress() const
 {
 #if ENABLE(RUBBER_BANDING) && PLATFORM(MAC)

Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h (264150 => 264151)


--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h	2020-07-09 06:10:46 UTC (rev 264150)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h	2020-07-09 06:11:20 UTC (rev 264151)
@@ -134,6 +134,7 @@
 
     void immediateScrollToPosition(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped);
 
+    bool isUserScrollInProgress() const override;
     bool isRubberBandInProgress() const override;
     bool isScrollSnapInProgress() const override;
 

Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (264150 => 264151)


--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2020-07-09 06:10:46 UTC (rev 264150)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2020-07-09 06:11:20 UTC (rev 264151)
@@ -855,6 +855,11 @@
     updateActiveScrollSnapIndexForOffset();
 }
 
+bool ScrollAnimatorMac::isUserScrollInProgress() const
+{
+    return m_scrollController.isUserScrollInProgress();
+}
+
 bool ScrollAnimatorMac::isRubberBandInProgress() const
 {
 #if !ENABLE(RUBBER_BANDING)

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (264150 => 264151)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2020-07-09 06:10:46 UTC (rev 264150)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2020-07-09 06:11:20 UTC (rev 264151)
@@ -1871,6 +1871,17 @@
     return renderer().absoluteBoundingBoxRect(/* useTransforms */ true, isInsideFixed);
 }
 
+bool RenderLayer::isUserScrollInProgress() const
+{
+    if (!scrollsOverflow())
+        return false;
+
+    if (auto scrollAnimator = existingScrollAnimator())
+        return scrollAnimator->isUserScrollInProgress();
+    
+    return false;
+}
+
 bool RenderLayer::isRubberBandInProgress() const
 {
 #if ENABLE(RUBBER_BANDING)
@@ -1877,7 +1888,7 @@
     if (!scrollsOverflow())
         return false;
 
-    if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
+    if (auto scrollAnimator = existingScrollAnimator())
         return scrollAnimator->isRubberBandInProgress();
 #endif
 

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (264150 => 264151)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2020-07-09 06:10:46 UTC (rev 264150)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2020-07-09 06:11:20 UTC (rev 264151)
@@ -1133,6 +1133,7 @@
     bool isHandlingWheelEvent() const final;
     bool shouldSuspendScrollAnimations() const final;
     IntRect scrollableAreaBoundingBox(bool* isInsideFixed = nullptr) const final;
+    bool isUserScrollInProgress() const final;
     bool isRubberBandInProgress() const final;
     bool forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const final;
 #if ENABLE(CSS_SCROLL_SNAP)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to