Changeset 96663 in webkit


Ignore:
Timestamp:
Oct 4, 2011 4:48:39 PM (12 years ago)
Author:
andersca@apple.com
Message:

Move code into ScrollElasticityController::beginScrollGesture()
https://bugs.webkit.org/show_bug.cgi?id=69383

Reviewed by John Sullivan.

  • platform/mac/ScrollAnimatorMac.h:

Add new ScrollElasticityControllerClient member functions.

  • platform/mac/ScrollAnimatorMac.mm:

(WebCore::ScrollAnimatorMac::isHorizontalScrollerPinnedToMinimumPosition):
(WebCore::ScrollAnimatorMac::isHorizontalScrollerPinnedToMaximumPosition):
(WebCore::ScrollAnimatorMac::stretchAmount):
(WebCore::ScrollAnimatorMac::startSnapRubberbandTimer):
(WebCore::ScrollAnimatorMac::stopSnapRubberbandTimer):
Implement the new ScrollElasticityControllerClient member functions.

(WebCore::ScrollAnimatorMac::beginScrollGesture):
Move code into ScrollElasticityController::beginScrollGesture and call it directly.

  • platform/mac/ScrollElasticityController.h:

Add new ScrollElasticityControllerClient member functions.

  • platform/mac/ScrollElasticityController.mm:

(WebCore::reboundDeltaForElasticDelta):
(WebCore::ScrollElasticityController::beginScrollGesture):
Set up the scroll gesture state.

(WebCore::ScrollElasticityController::stopSnapRubberbandTimer):
New helper function.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r96662 r96663  
     12011-10-04  Anders Carlsson  <andersca@apple.com>
     2
     3        Move code into ScrollElasticityController::beginScrollGesture()
     4        https://bugs.webkit.org/show_bug.cgi?id=69383
     5
     6        Reviewed by John Sullivan.
     7
     8        * platform/mac/ScrollAnimatorMac.h:
     9        Add new ScrollElasticityControllerClient member functions.
     10
     11        * platform/mac/ScrollAnimatorMac.mm:
     12        (WebCore::ScrollAnimatorMac::isHorizontalScrollerPinnedToMinimumPosition):
     13        (WebCore::ScrollAnimatorMac::isHorizontalScrollerPinnedToMaximumPosition):
     14        (WebCore::ScrollAnimatorMac::stretchAmount):
     15        (WebCore::ScrollAnimatorMac::startSnapRubberbandTimer):
     16        (WebCore::ScrollAnimatorMac::stopSnapRubberbandTimer):
     17        Implement the new ScrollElasticityControllerClient member functions.
     18
     19        (WebCore::ScrollAnimatorMac::beginScrollGesture):
     20        Move code into ScrollElasticityController::beginScrollGesture and call it directly.
     21
     22        * platform/mac/ScrollElasticityController.h:
     23        Add new ScrollElasticityControllerClient member functions.
     24
     25        * platform/mac/ScrollElasticityController.mm:
     26        (WebCore::reboundDeltaForElasticDelta):
     27        (WebCore::ScrollElasticityController::beginScrollGesture):
     28        Set up the scroll gesture state.
     29
     30        (WebCore::ScrollElasticityController::stopSnapRubberbandTimer):
     31        New helper function.
     32
    1332011-10-04  Scott Graham  <scottmg@chromium.org>
    234
  • trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h

    r96651 r96663  
    139139
    140140#if ENABLE(RUBBER_BANDING)
     141    /// ScrollElasticityControllerClient member functions.
     142    virtual bool isHorizontalScrollerPinnedToMinimumPosition() OVERRIDE;
     143    virtual bool isHorizontalScrollerPinnedToMaximumPosition() OVERRIDE;
     144    virtual IntSize stretchAmount() OVERRIDE;
     145    virtual void startSnapRubberbandTimer() OVERRIDE;
     146    virtual void stopSnapRubberbandTimer() OVERRIDE;
     147
    141148    bool allowsVerticalStretching() const;
    142149    bool allowsHorizontalStretching() const;
  • trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm

    r96652 r96663  
    881881        return true;
    882882    return false;
     883}
     884
     885bool ScrollAnimatorMac::isHorizontalScrollerPinnedToMinimumPosition()
     886{
     887    return m_scrollableArea->isHorizontalScrollerPinnedToMinimumPosition();
     888}
     889
     890bool ScrollAnimatorMac::isHorizontalScrollerPinnedToMaximumPosition()
     891{
     892    return m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition();
     893}
     894
     895IntSize ScrollAnimatorMac::stretchAmount()
     896{
     897    return m_scrollableArea->overhangAmount();
     898}
     899
     900void ScrollAnimatorMac::startSnapRubberbandTimer()
     901{
     902    m_snapRubberBandTimer.startRepeating(1.0 / 60.0);
     903}
     904
     905void ScrollAnimatorMac::stopSnapRubberbandTimer()
     906{
     907    m_snapRubberBandTimer.stop();
    883908}
    884909
     
    10761101{
    10771102    didBeginScrollGesture();
    1078 
    10791103    m_haveScrolledSincePageLoad = true;
    1080     m_scrollElasticityController.m_inScrollGesture = true;
    1081     m_scrollElasticityController.m_momentumScrollInProgress = false;
    1082     m_scrollElasticityController.m_ignoreMomentumScrolls = false;
    1083     m_scrollElasticityController.m_lastMomentumScrollTimestamp = 0;
    1084     m_scrollElasticityController.m_momentumVelocity = FloatSize();
    1085     m_scrollElasticityController.m_scrollerInitiallyPinnedOnLeft = m_scrollableArea->isHorizontalScrollerPinnedToMinimumPosition();
    1086     m_scrollElasticityController.m_scrollerInitiallyPinnedOnRight = m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition();
    1087     m_scrollElasticityController.m_cumulativeHorizontalScroll = 0;
    1088     m_scrollElasticityController.m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = false;
    1089    
    1090     IntSize stretchAmount = m_scrollableArea->overhangAmount();
    1091     m_scrollElasticityController.m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(stretchAmount.width()));
    1092     m_scrollElasticityController.m_stretchScrollForce.setHeight(reboundDeltaForElasticDelta(stretchAmount.height()));
    1093 
    1094     m_scrollElasticityController.m_overflowScrollDelta = FloatSize();
    1095    
    1096     m_snapRubberBandTimer.stop();
    1097     m_scrollElasticityController.m_snapRubberbandTimerIsActive = false;
     1104
     1105    m_scrollElasticityController.beginScrollGesture();
    10981106}
    10991107
  • trunk/Source/WebCore/platform/mac/ScrollElasticityController.h

    r96652 r96663  
    3636
    3737class ScrollElasticityControllerClient {
     38protected:
     39    virtual ~ScrollElasticityControllerClient() { }
     40
    3841public:
    39     virtual ~ScrollElasticityControllerClient() { }
     42    virtual bool isHorizontalScrollerPinnedToMinimumPosition() = 0;
     43    virtual bool isHorizontalScrollerPinnedToMaximumPosition() = 0;
     44
     45    virtual IntSize stretchAmount() = 0;
     46
     47    virtual void startSnapRubberbandTimer() = 0;
     48    virtual void stopSnapRubberbandTimer() = 0;
    4049};
    4150
     
    4655    explicit ScrollElasticityController(ScrollElasticityControllerClient*);
    4756
     57    void beginScrollGesture();
     58
    4859private:
    4960    ScrollElasticityControllerClient* m_client;
     61
     62    void stopSnapRubberbandTimer();
    5063
    5164    // FIXME: These member variables should be private. They are currently public as a stop-gap measure, while
  • trunk/Source/WebCore/platform/mac/ScrollElasticityController.mm

    r96652 r96663  
    3131namespace WebCore {
    3232
     33static const float rubberbandStiffness = 20;
     34
     35static float reboundDeltaForElasticDelta(float delta)
     36{
     37    return delta * rubberbandStiffness;
     38}
     39
    3340ScrollElasticityController::ScrollElasticityController(ScrollElasticityControllerClient* client)
    3441    : m_client(client)
     
    4653}
    4754
     55void ScrollElasticityController::beginScrollGesture()
     56{
     57    m_inScrollGesture = true;
     58    m_momentumScrollInProgress = false;
     59    m_ignoreMomentumScrolls = false;
     60    m_lastMomentumScrollTimestamp = 0;
     61    m_momentumVelocity = FloatSize();
     62    m_scrollerInitiallyPinnedOnLeft = m_client->isHorizontalScrollerPinnedToMinimumPosition();
     63    m_scrollerInitiallyPinnedOnRight = m_client->isHorizontalScrollerPinnedToMaximumPosition();
     64    m_cumulativeHorizontalScroll = 0;
     65    m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = false;
     66   
     67    IntSize stretchAmount = m_client->stretchAmount();
     68    m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(stretchAmount.width()));
     69    m_stretchScrollForce.setHeight(reboundDeltaForElasticDelta(stretchAmount.height()));
     70   
     71    m_overflowScrollDelta = FloatSize();
     72
     73    stopSnapRubberbandTimer();
     74}
     75
     76void ScrollElasticityController::stopSnapRubberbandTimer()
     77{
     78    m_client->stopSnapRubberbandTimer();
     79    m_snapRubberbandTimerIsActive = false;
     80}
     81
    4882} // namespace WebCore
    4983
Note: See TracChangeset for help on using the changeset viewer.