Title: [282729] trunk/Source/WebCore
Revision
282729
Author
[email protected]
Date
2021-09-18 13:41:26 -0700 (Sat, 18 Sep 2021)

Log Message

Rename haveScrolledSincePageLoad() and push the state to ScrollbarsController
https://bugs.webkit.org/show_bug.cgi?id=230444

Reviewed by Myles C. Maxfield.

r81159 added logic to suppress scrollbar animations during page load (delayed using a 100ms
timer in ScrollbarsControllerMac), but to unsuppress the animations when receiving user
events or scrolling. This state using the confusingly named "haveScrolledSincePageLoad",
which is really "a wheel evnet or scroll requires that we stop suppressing scrollbar
animations". So name it scrollbarAnimationsUnsuspendedByUserInteraction", and have
ScrollbarsController maintain the state, rather than ScrollAnimator.

Add some OverlayScrollbars logging to show this working (although it reveals that the
100ms timer can fire multiple times).

* platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::cancelAnimations):
* platform/ScrollAnimator.h:
(WebCore::ScrollAnimator::haveScrolledSincePageLoad const): Deleted.
(WebCore::ScrollAnimator::setHaveScrolledSincePageLoad): Deleted.
* platform/ScrollbarsController.cpp:
(WebCore::ScrollbarsController::shouldSuspendScrollbarAnimations const):
(WebCore::ScrollbarsController::cancelAnimations):
(WebCore::ScrollbarsController::didBeginScrollGesture):
(WebCore::ScrollbarsController::didEndScrollGesture):
(WebCore::ScrollbarsController::mayBeginScrollGesture):
* platform/ScrollbarsController.h:
(WebCore::ScrollbarsController::scrollbarAnimationsUnsuspendedByUserInteraction const):
(WebCore::ScrollbarsController::setScrollbarAnimationsUnsuspendedByUserInteraction):
(WebCore::ScrollbarsController::cancelAnimations): Deleted.
(WebCore::ScrollbarsController::didBeginScrollGesture const): Deleted.
(WebCore::ScrollbarsController::didEndScrollGesture const): Deleted.
(WebCore::ScrollbarsController::mayBeginScrollGesture const): Deleted.
* platform/mac/ScrollAnimatorMac.h:
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::scroll):
(WebCore::ScrollAnimatorMac::handleWheelEventPhase):
(WebCore::ScrollAnimatorMac::handleWheelEvent):
(WebCore::ScrollAnimatorMac::cancelAnimations): Deleted.
* platform/mac/ScrollbarsControllerMac.h:
* platform/mac/ScrollbarsControllerMac.mm:
(-[WebScrollbarPartAnimation setCurrentProgress:]):
(-[WebScrollerImpDelegate setUpAlphaAnimation:scrollerPainter:part:animateAlphaTo:duration:]):
(WebCore::ScrollbarsControllerMac::cancelAnimations):
(WebCore::ScrollbarsControllerMac::didBeginScrollGesture):
(WebCore::ScrollbarsControllerMac::didEndScrollGesture):
(WebCore::ScrollbarsControllerMac::mayBeginScrollGesture):
(WebCore::ScrollbarsControllerMac::initialScrollbarPaintTimerFired):
(WebCore::ScrollbarsControllerMac::haveScrolledSincePageLoad const): Deleted.
(WebCore::ScrollbarsControllerMac::didBeginScrollGesture const): Deleted.
(WebCore::ScrollbarsControllerMac::didEndScrollGesture const): Deleted.
(WebCore::ScrollbarsControllerMac::mayBeginScrollGesture const): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (282728 => 282729)


--- trunk/Source/WebCore/ChangeLog	2021-09-18 19:05:28 UTC (rev 282728)
+++ trunk/Source/WebCore/ChangeLog	2021-09-18 20:41:26 UTC (rev 282729)
@@ -1,5 +1,60 @@
 2021-09-18  Simon Fraser  <[email protected]>
 
+        Rename haveScrolledSincePageLoad() and push the state to ScrollbarsController
+        https://bugs.webkit.org/show_bug.cgi?id=230444
+
+        Reviewed by Myles C. Maxfield.
+        
+        r81159 added logic to suppress scrollbar animations during page load (delayed using a 100ms
+        timer in ScrollbarsControllerMac), but to unsuppress the animations when receiving user
+        events or scrolling. This state using the confusingly named "haveScrolledSincePageLoad",
+        which is really "a wheel evnet or scroll requires that we stop suppressing scrollbar
+        animations". So name it scrollbarAnimationsUnsuspendedByUserInteraction", and have
+        ScrollbarsController maintain the state, rather than ScrollAnimator.
+
+        Add some OverlayScrollbars logging to show this working (although it reveals that the
+        100ms timer can fire multiple times).
+
+        * platform/ScrollAnimator.cpp:
+        (WebCore::ScrollAnimator::cancelAnimations):
+        * platform/ScrollAnimator.h:
+        (WebCore::ScrollAnimator::haveScrolledSincePageLoad const): Deleted.
+        (WebCore::ScrollAnimator::setHaveScrolledSincePageLoad): Deleted.
+        * platform/ScrollbarsController.cpp:
+        (WebCore::ScrollbarsController::shouldSuspendScrollbarAnimations const):
+        (WebCore::ScrollbarsController::cancelAnimations):
+        (WebCore::ScrollbarsController::didBeginScrollGesture):
+        (WebCore::ScrollbarsController::didEndScrollGesture):
+        (WebCore::ScrollbarsController::mayBeginScrollGesture):
+        * platform/ScrollbarsController.h:
+        (WebCore::ScrollbarsController::scrollbarAnimationsUnsuspendedByUserInteraction const):
+        (WebCore::ScrollbarsController::setScrollbarAnimationsUnsuspendedByUserInteraction):
+        (WebCore::ScrollbarsController::cancelAnimations): Deleted.
+        (WebCore::ScrollbarsController::didBeginScrollGesture const): Deleted.
+        (WebCore::ScrollbarsController::didEndScrollGesture const): Deleted.
+        (WebCore::ScrollbarsController::mayBeginScrollGesture const): Deleted.
+        * platform/mac/ScrollAnimatorMac.h:
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::ScrollAnimatorMac::scroll):
+        (WebCore::ScrollAnimatorMac::handleWheelEventPhase):
+        (WebCore::ScrollAnimatorMac::handleWheelEvent):
+        (WebCore::ScrollAnimatorMac::cancelAnimations): Deleted.
+        * platform/mac/ScrollbarsControllerMac.h:
+        * platform/mac/ScrollbarsControllerMac.mm:
+        (-[WebScrollbarPartAnimation setCurrentProgress:]):
+        (-[WebScrollerImpDelegate setUpAlphaAnimation:scrollerPainter:part:animateAlphaTo:duration:]):
+        (WebCore::ScrollbarsControllerMac::cancelAnimations):
+        (WebCore::ScrollbarsControllerMac::didBeginScrollGesture):
+        (WebCore::ScrollbarsControllerMac::didEndScrollGesture):
+        (WebCore::ScrollbarsControllerMac::mayBeginScrollGesture):
+        (WebCore::ScrollbarsControllerMac::initialScrollbarPaintTimerFired):
+        (WebCore::ScrollbarsControllerMac::haveScrolledSincePageLoad const): Deleted.
+        (WebCore::ScrollbarsControllerMac::didBeginScrollGesture const): Deleted.
+        (WebCore::ScrollbarsControllerMac::didEndScrollGesture const): Deleted.
+        (WebCore::ScrollbarsControllerMac::mayBeginScrollGesture const): Deleted.
+
+2021-09-18  Simon Fraser  <[email protected]>
+
         Clean up the ScrollAnimator interface a little
         https://bugs.webkit.org/show_bug.cgi?id=230324
 

Modified: trunk/Source/WebCore/platform/ScrollAnimator.cpp (282728 => 282729)


--- trunk/Source/WebCore/platform/ScrollAnimator.cpp	2021-09-18 19:05:28 UTC (rev 282728)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp	2021-09-18 20:41:26 UTC (rev 282729)
@@ -38,6 +38,7 @@
 #include "PlatformWheelEvent.h"
 #include "ScrollAnimationSmooth.h"
 #include "ScrollableArea.h"
+#include "ScrollbarsController.h"
 #include "ScrollingEffectsController.h"
 #include <algorithm>
 
@@ -341,9 +342,8 @@
 
 void ScrollAnimator::cancelAnimations()
 {
-#if !USE(REQUEST_ANIMATION_FRAME_TIMER)
     m_scrollAnimation->stop();
-#endif
+    m_scrollableArea.scrollbarsController().cancelAnimations();
 }
 
 void ScrollAnimator::contentsSizeChanged() const

Modified: trunk/Source/WebCore/platform/ScrollAnimator.h (282728 => 282729)


--- trunk/Source/WebCore/platform/ScrollAnimator.h	2021-09-18 19:05:28 UTC (rev 282728)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h	2021-09-18 20:41:26 UTC (rev 282729)
@@ -106,9 +106,6 @@
     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; }
@@ -155,7 +152,6 @@
     ScrollingEffectsController m_scrollController;
     Timer m_scrollControllerAnimationTimer;
     FloatPoint m_currentPosition;
-    bool m_haveScrolledSincePageLoad { false };
 
     std::unique_ptr<ScrollAnimationSmooth> m_scrollAnimation;
     std::unique_ptr<KeyboardScrollingAnimator> m_keyboardScrollingAnimator;

Modified: trunk/Source/WebCore/platform/ScrollbarsController.cpp (282728 => 282729)


--- trunk/Source/WebCore/platform/ScrollbarsController.cpp	2021-09-18 19:05:28 UTC (rev 282728)
+++ trunk/Source/WebCore/platform/ScrollbarsController.cpp	2021-09-18 20:41:26 UTC (rev 282729)
@@ -42,4 +42,29 @@
 {
 }
 
+bool ScrollbarsController::shouldSuspendScrollbarAnimations() const
+{
+    return scrollableArea().shouldSuspendScrollAnimations();
+}
+
+void ScrollbarsController::cancelAnimations()
+{
+    setScrollbarAnimationsUnsuspendedByUserInteraction(false);
+}
+
+void ScrollbarsController::didBeginScrollGesture()
+{
+    setScrollbarAnimationsUnsuspendedByUserInteraction(true);
+}
+
+void ScrollbarsController::didEndScrollGesture()
+{
+    setScrollbarAnimationsUnsuspendedByUserInteraction(true);
+}
+
+void ScrollbarsController::mayBeginScrollGesture()
+{
+    setScrollbarAnimationsUnsuspendedByUserInteraction(true);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/ScrollbarsController.h (282728 => 282729)


--- trunk/Source/WebCore/platform/ScrollbarsController.h	2021-09-18 19:05:28 UTC (rev 282728)
+++ trunk/Source/WebCore/platform/ScrollbarsController.h	2021-09-18 20:41:26 UTC (rev 282729)
@@ -46,13 +46,18 @@
     
     ScrollableArea& scrollableArea() const { return m_scrollableArea; }
 
+    bool scrollbarAnimationsUnsuspendedByUserInteraction() const { return m_scrollbarAnimationsUnsuspendedByUserInteraction; }
+    void setScrollbarAnimationsUnsuspendedByUserInteraction(bool unsuspended) { m_scrollbarAnimationsUnsuspendedByUserInteraction = unsuspended; }
+    
+    bool shouldSuspendScrollbarAnimations() const;
+
     virtual void notifyContentAreaScrolled(const FloatSize&) { }
 
-    virtual void cancelAnimations() { }
+    virtual void cancelAnimations();
 
-    virtual void didBeginScrollGesture() const { }
-    virtual void didEndScrollGesture() const { }
-    virtual void mayBeginScrollGesture() const { }
+    virtual void didBeginScrollGesture();
+    virtual void didEndScrollGesture();
+    virtual void mayBeginScrollGesture();
 
     virtual void contentAreaWillPaint() const { }
     virtual void mouseEnteredContentArea() { }
@@ -87,6 +92,7 @@
 
 private:
     ScrollableArea& m_scrollableArea;
+    bool m_scrollbarAnimationsUnsuspendedByUserInteraction { true };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h (282728 => 282729)


--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h	2021-09-18 19:05:28 UTC (rev 282728)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h	2021-09-18 20:41:26 UTC (rev 282729)
@@ -57,8 +57,6 @@
 #endif
 
     void handleWheelEventPhase(PlatformWheelEventPhase) final;
-
-    void cancelAnimations() final;
     
     void notifyPositionChanged(const FloatSize& delta) final;
 

Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (282728 => 282729)


--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2021-09-18 19:05:28 UTC (rev 282728)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2021-09-18 20:41:26 UTC (rev 282729)
@@ -194,7 +194,7 @@
 
 bool ScrollAnimatorMac::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier, OptionSet<ScrollBehavior> behavior)
 {
-    setHaveScrolledSincePageLoad(true);
+    m_scrollableArea.scrollbarsController().setScrollbarAnimationsUnsuspendedByUserInteraction(true);
 
     // This method doesn't do directional snapping, but our base class does. It will call into
     // ScrollAnimatorMac::scroll again with the snapped positions and ScrollBehavior::Default.
@@ -293,21 +293,10 @@
     ScrollAnimator::notifyPositionChanged(delta);
 }
 
-void ScrollAnimatorMac::cancelAnimations()
-{
-    ScrollAnimator::cancelAnimations();
-    setHaveScrolledSincePageLoad(false);
-    m_scrollableArea.scrollbarsController().cancelAnimations();
-}
-
 void ScrollAnimatorMac::handleWheelEventPhase(PlatformWheelEventPhase phase)
 {
     LOG_WITH_STREAM(OverlayScrollbars, stream << "ScrollAnimatorMac " << this << " scrollableArea " << m_scrollableArea << " handleWheelEventPhase " << phase);
 
-    // This may not have been set to true yet if the wheel event was handled by the ScrollingTree,
-    // So set it to true here.
-    setHaveScrolledSincePageLoad(true);
-
     // FIXME: Need to ensure we get PlatformWheelEventPhase::Ended.
     if (phase == PlatformWheelEventPhase::Began)
         m_scrollableArea.scrollbarsController().didBeginScrollGesture();
@@ -329,7 +318,7 @@
     
 bool ScrollAnimatorMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
 {
-    setHaveScrolledSincePageLoad(true);
+    m_scrollableArea.scrollbarsController().setScrollbarAnimationsUnsuspendedByUserInteraction(true);
 
     if (!wheelEvent.hasPreciseScrollingDeltas() || !rubberBandingEnabledForSystem())
         return ScrollAnimator::handleWheelEvent(wheelEvent);

Modified: trunk/Source/WebCore/platform/mac/ScrollbarsControllerMac.h (282728 => 282729)


--- trunk/Source/WebCore/platform/mac/ScrollbarsControllerMac.h	2021-09-18 19:05:28 UTC (rev 282728)
+++ trunk/Source/WebCore/platform/mac/ScrollbarsControllerMac.h	2021-09-18 20:41:26 UTC (rev 282729)
@@ -54,9 +54,9 @@
 
     void cancelAnimations() final;
 
-    void didBeginScrollGesture() const final;
-    void didEndScrollGesture() const final;
-    void mayBeginScrollGesture() const final;
+    void didBeginScrollGesture() final;
+    void didEndScrollGesture() final;
+    void mayBeginScrollGesture() final;
 
     void contentAreaWillPaint() const final;
     void mouseEnteredContentArea() final;
@@ -96,7 +96,6 @@
     void startScrollbarPaintTimer();
     void stopScrollbarPaintTimer();
     void setVisibleScrollerThumbRect(const IntRect&);
-    bool haveScrolledSincePageLoad() const;
 
 private:
 

Modified: trunk/Source/WebCore/platform/mac/ScrollbarsControllerMac.mm (282728 => 282729)


--- trunk/Source/WebCore/platform/mac/ScrollbarsControllerMac.mm	2021-09-18 19:05:28 UTC (rev 282728)
+++ trunk/Source/WebCore/platform/mac/ScrollbarsControllerMac.mm	2021-09-18 20:41:26 UTC (rev 282729)
@@ -265,7 +265,7 @@
     }
     ASSERT(_scrollbar);
 
-    LOG_WITH_STREAM(OverlayScrollbars, stream << "-[WebScrollbarPartAnimation " << self << "setCurrentProgress:" << progress <<"] for " << _featureToAnimate);
+    LOG_WITH_STREAM(OverlayScrollbars, stream << "-[" << self << " setCurrentProgress: " << progress << "] for " << _featureToAnimate);
 
     CGFloat currentValue;
     if (_startValue > _endValue)
@@ -431,12 +431,14 @@
 {
     // If the user has scrolled the page, then the scrollbars must be animated here.
     // This overrides the early returns.
-    bool mustAnimate = [self scrollbarsController]->haveScrolledSincePageLoad();
+    bool mustAnimate = ![self scrollbarsController]->scrollbarAnimationsUnsuspendedByUserInteraction();
 
+    LOG_WITH_STREAM(OverlayScrollbars, stream << "WebScrollerImpDelegate for [" << _scrollbar->scrollableArea() << "] setUpAlphaAnimation: scrollbarAnimationsUnsuspendedByUserInteraction " << [self scrollbarsController]->scrollbarAnimationsUnsuspendedByUserInteraction() << " shouldSuspendScrollAnimations " << _scrollbar->scrollableArea().shouldSuspendScrollAnimations());
+
     if ([self scrollbarsController]->scrollbarPaintTimerIsActive() && !mustAnimate)
         return;
 
-    if (_scrollbar->scrollableArea().shouldSuspendScrollAnimations() && !mustAnimate) {
+    if ([self scrollbarsController]->shouldSuspendScrollbarAnimations() && !mustAnimate) {
         [self scrollbarsController]->startScrollbarPaintTimer();
         return;
     }
@@ -606,10 +608,13 @@
 
 void ScrollbarsControllerMac::cancelAnimations()
 {
+    LOG_WITH_STREAM(OverlayScrollbars, stream << "ScrollbarsControllerMac for [" << scrollableArea() << "] cancelAnimations");
     if (scrollbarPaintTimerIsActive())
         stopScrollbarPaintTimer();
     [m_horizontalScrollerImpDelegate cancelAnimations];
     [m_verticalScrollerImpDelegate cancelAnimations];
+
+    ScrollbarsController::cancelAnimations();
 }
 
 void ScrollbarsControllerMac::setVisibleScrollerThumbRect(const IntRect& scrollerThumb)
@@ -626,11 +631,6 @@
 }
 
 
-bool ScrollbarsControllerMac::haveScrolledSincePageLoad() const
-{
-    return scrollableArea().scrollAnimator().haveScrolledSincePageLoad();
-}
-
 void ScrollbarsControllerMac::contentAreaWillPaint() const
 {
     if ([m_scrollerImpPair overlayScrollerStateIsLocked])
@@ -750,7 +750,7 @@
     [m_scrollerImpPair windowOrderedOut];
 }
 
-void ScrollbarsControllerMac::didBeginScrollGesture() const
+void ScrollbarsControllerMac::didBeginScrollGesture()
 {
     LOG_WITH_STREAM(OverlayScrollbars, stream << "ScrollbarsControllerMac for [" << scrollableArea() << "] didBeginScrollGesture");
 
@@ -761,9 +761,11 @@
 
     if (auto* monitor = wheelEventTestMonitor())
         monitor->deferForReason(reinterpret_cast<WheelEventTestMonitor::ScrollableAreaIdentifier>(this), WheelEventTestMonitor::ContentScrollInProgress);
+
+    ScrollbarsController::didBeginScrollGesture();
 }
 
-void ScrollbarsControllerMac::didEndScrollGesture() const
+void ScrollbarsControllerMac::didEndScrollGesture()
 {
     LOG_WITH_STREAM(OverlayScrollbars, stream << "ScrollbarsControllerMac for [" << scrollableArea() << "] didEndScrollGesture");
 
@@ -774,9 +776,11 @@
 
     if (auto* monitor = wheelEventTestMonitor())
         monitor->removeDeferralForReason(reinterpret_cast<WheelEventTestMonitor::ScrollableAreaIdentifier>(this), WheelEventTestMonitor::ContentScrollInProgress);
+
+    ScrollbarsController::didEndScrollGesture();
 }
 
-void ScrollbarsControllerMac::mayBeginScrollGesture() const
+void ScrollbarsControllerMac::mayBeginScrollGesture()
 {
     LOG_WITH_STREAM(OverlayScrollbars, stream << "ScrollbarsControllerMac for [" << scrollableArea() << "] mayBeginScrollGesture");
 
@@ -785,6 +789,8 @@
 
     [m_scrollerImpPair beginScrollGesture];
     [m_scrollerImpPair contentAreaScrolled];
+
+    ScrollbarsController::mayBeginScrollGesture();
 }
 
 void ScrollbarsControllerMac::lockOverlayScrollbarStateToHidden(bool shouldLockState)
@@ -1006,6 +1012,8 @@
 
 void ScrollbarsControllerMac::initialScrollbarPaintTimerFired()
 {
+    LOG_WITH_STREAM(OverlayScrollbars, stream << "WebScrollerImpDelegate for [" << scrollableArea() << "] initialScrollbarPaintTimerFired - flashing scrollers");
+
     // To force the scrollbars to flash, we have to call hide first. Otherwise, the ScrollerImpPair
     // might think that the scrollbars are already showing and bail early.
     [m_scrollerImpPair hideOverlayScrollers];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to