<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>230310</bug_id>
          
          <creation_ts>2021-09-15 10:49:47 -0700</creation_ts>
          <short_desc>Unify the code paths for smooth scrolling, and scrolling to snap points</short_desc>
          <delta_ts>2021-10-10 10:22:01 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Scrolling</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=218857</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>230385</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Simon Fraser (smfr)">simon.fraser</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>cathiechen</cc>
    
    <cc>mrobinson</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1793753</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2021-09-15 10:49:47 -0700</bug_when>
    <thetext>Smooth scrolling uses ScrollAnimator&apos;s ScrollAnimationSmooth. Snap point animations use ScrollingMomentumCalculator stuff. They should be the same.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1793754</commentid>
    <comment_count>1</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2021-09-15 10:50:09 -0700</bug_when>
    <thetext>We have way too many scroll animators.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1793878</commentid>
    <comment_count>2</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2021-09-15 15:42:20 -0700</bug_when>
    <thetext>Maybe bug 218857 addresses this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1793992</commentid>
    <comment_count>3</comment_count>
    <who name="Martin Robinson">mrobinson</who>
    <bug_when>2021-09-16 03:10:02 -0700</bug_when>
    <thetext>I&apos;ve done a quick inventory of all of the scroll animation classes and here&apos;s a summary:

ScrollAnimator: WebProcess-only class providing operations that can scroll from one point to another and manages scroll snap / rubber banding via ScollingEffectsController. This is only used by ScrollableArea. I think it exists to avoid a layering violation, since it depends on platform-specific behavior.
  * ScrollAnimatorMac uses NSScrollAnimationHelper (private API) to scroll WebProcess-side scroll areas with animations.
  * ScrollAnimationSmooth: Generic implementation of smooth scrolling animation. This is used by ScrollAnimator for operations like &quot;scroll to point with animation&quot; on non-Mac platforms. On Mac this is used for CSSOM smooth scrolling (fixed by https://bugs.webkit.org/show_bug.cgi?id=218857). In addition, it&apos;s used in the UIProcess by the Nicosia scrolling tree.

ScrollingEffectsCoordinator: Manages rubber banding and scroll snapping in both the WebProcess and UIProcess (scrolling tree).
  * ScrollSnapAnimatorState: Manages state for scroll snapping. Only used by ScrollingEffectsCoordinator.
    * ScrollingMomentumCalculator - Abstract base class that calculates movement for animations involving scrolling momentum. ScrollSnapAnimatorState uses this when ScrollingEffectsCoordinater sets up a momentum animation based on kinetic scrolling / scroll snap. Only Mac does this currently.
   * ScrollingMomentumCalculatorMac: Mac implementation of ScrollingMomentumCalculator which uses NSScrollingMomentumCalculatorSPI to calculate the momentum values.
   * BasicScrollingMomentumCalculator: Platform-independent implementation of ScrollingMomentumCalculator. I think this is unused, but could one day be used for kinetic scrolling on other ports.

* ScrollAnimationKinetic: Kinetic scroll animation class that&apos;s only used for Nicosia Scrolling Tree kinetic animations. I&apos;m unsure how much of this could be replaced by ScrollingEffectsCoordinator and BasicScrollingMomentumCalculator.

I think there&apos;s lots of opportunities for simplification here. In particular it seems like ScrollingEffectsCoordinator / ScrollSnapAnimatorState / ScrollingMomentumCalculator could be collapsed down into a single class and greatly simplified. 

Another thing that could happen is that a lot of ScrollAnimator could move into ScrollableArea and the platform-dependent parts could be implemented as a delegate that only does the actual animation.

These are just some initial ideas, but there&apos;s lots of room for improvement. The code is a bit convoluted, because we have to send information down to all of these helpers whenever scroll snap points change.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1794332</commentid>
    <comment_count>4</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2021-09-16 21:09:30 -0700</bug_when>
    <thetext>&gt; a lot of ScrollAnimator could move into ScrollableArea

Maybe, although it would be nice to think of snap points as a &quot;scroll destination modifier&quot;, perhaps a ScrollableArea helper but not in the same class. We should see if there&apos;s scrolling tree code related to snap points that duplicates logic in ScrollAnimator.

&gt; ScrollAnimatorMac
I intend to remove its m_scrollAnimationHelper and the delegate, and replace it with a ScrollAnimation subclass. After doing that, macOS just uses the m_scrollAnimation in the base class, and maybe ScrollAnimatorMac can mostly go away.

I&apos;ve love to avoid both ScrollAnimator and ScrollController having platform subclasses/implementations. That&apos;s a source of a lot of brain hurt.

&gt; ScrollAnimationKinetic
See https://bugs.webkit.org/show_bug.cgi?id=230385. I want to add a macOS specific ScrollAnimationKinetic variant that uses ScrollingMomentumCalculator. Maybe ScrollAnimationKinetic can just use BasicScrollingMomentumCalculator (or move the BasicScrollingMomentumCalculator code into ScrollAnimationKinetic).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1796128</commentid>
    <comment_count>5</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-09-22 10:50:17 -0700</bug_when>
    <thetext>&lt;rdar://problem/83407810&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1802464</commentid>
    <comment_count>6</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2021-10-10 10:22:01 -0700</bug_when>
    <thetext>These are both ScrollAnimation subclasses now. I think we can call this done.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>