Commit e382441e authored by andersca@apple.com's avatar andersca@apple.com

ScrollElasticityController should keep track of the rubberband timer state

https://bugs.webkit.org/show_bug.cgi?id=69381

Reviewed by Sam Weinig.

Add a m_snapRubberbandTimerIsActive member variable to ScrollElasticityController
and use it instead of checking whether the m_snapRubberbandTimer is active.

Eventually, ScrollElasticityControllerClient will have two member functions for starting
and stopping the timer, and the ScrollElasticityController will call them at the appropriate times.

* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::handleWheelEvent):
(WebCore::ScrollAnimatorMac::beginScrollGesture):
It's OK to stop the timer unconditionally.

(WebCore::ScrollAnimatorMac::snapRubberBand):
(WebCore::ScrollAnimatorMac::snapRubberBandTimerFired):
* platform/mac/ScrollElasticityController.h:
* platform/mac/ScrollElasticityController.mm:
(WebCore::ScrollElasticityController::ScrollElasticityController):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96652 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5f59a1e6
2011-10-04 Anders Carlsson <andersca@apple.com>
ScrollElasticityController should keep track of the rubberband timer state
https://bugs.webkit.org/show_bug.cgi?id=69381
Reviewed by Sam Weinig.
Add a m_snapRubberbandTimerIsActive member variable to ScrollElasticityController
and use it instead of checking whether the m_snapRubberbandTimer is active.
Eventually, ScrollElasticityControllerClient will have two member functions for starting
and stopping the timer, and the ScrollElasticityController will call them at the appropriate times.
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::handleWheelEvent):
(WebCore::ScrollAnimatorMac::beginScrollGesture):
It's OK to stop the timer unconditionally.
(WebCore::ScrollAnimatorMac::snapRubberBand):
(WebCore::ScrollAnimatorMac::snapRubberBandTimerFired):
* platform/mac/ScrollElasticityController.h:
* platform/mac/ScrollElasticityController.mm:
(WebCore::ScrollElasticityController::ScrollElasticityController):
2011-10-04 Anders Carlsson <andersca@apple.com>
Move all rubber-banding related member variables to ScrollElasticityController
......@@ -836,7 +836,7 @@ bool ScrollAnimatorMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
}
bool isMomentumScrollEvent = (wheelEvent.momentumPhase() != PlatformWheelEventPhaseNone);
if (m_scrollElasticityController.m_ignoreMomentumScrolls && (isMomentumScrollEvent || m_snapRubberBandTimer.isActive())) {
if (m_scrollElasticityController.m_ignoreMomentumScrolls && (isMomentumScrollEvent || m_scrollElasticityController.m_snapRubberbandTimerIsActive)) {
if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded) {
m_scrollElasticityController.m_ignoreMomentumScrolls = false;
return true;
......@@ -1093,8 +1093,8 @@ void ScrollAnimatorMac::beginScrollGesture()
m_scrollElasticityController.m_overflowScrollDelta = FloatSize();
if (m_snapRubberBandTimer.isActive())
m_snapRubberBandTimer.stop();
m_snapRubberBandTimer.stop();
m_scrollElasticityController.m_snapRubberbandTimerIsActive = false;
}
void ScrollAnimatorMac::endScrollGesture()
......@@ -1112,7 +1112,7 @@ void ScrollAnimatorMac::snapRubberBand()
m_scrollElasticityController.m_inScrollGesture = false;
if (m_snapRubberBandTimer.isActive())
if (m_scrollElasticityController.m_snapRubberbandTimerIsActive)
return;
m_scrollElasticityController.m_startTime = [NSDate timeIntervalSinceReferenceDate];
......@@ -1121,6 +1121,7 @@ void ScrollAnimatorMac::snapRubberBand()
m_scrollElasticityController.m_origVelocity = FloatSize();
m_snapRubberBandTimer.startRepeating(1.0/60.0);
m_scrollElasticityController.m_snapRubberbandTimerIsActive = true;
}
static inline float roundTowardZero(float num)
......@@ -1146,11 +1147,13 @@ void ScrollAnimatorMac::snapRubberBandTimerFired(Timer<ScrollAnimatorMac>*)
m_scrollElasticityController.m_startStretch = m_scrollableArea->overhangAmount();
if (m_scrollElasticityController.m_startStretch == FloatSize()) {
m_snapRubberBandTimer.stop();
m_scrollElasticityController.m_stretchScrollForce = FloatSize();
m_scrollElasticityController.m_startTime = 0;
m_scrollElasticityController.m_startStretch = FloatSize();
m_scrollElasticityController.m_origOrigin = FloatPoint();
m_scrollElasticityController.m_origVelocity = FloatSize();
m_scrollElasticityController.m_snapRubberbandTimerIsActive = false;
return;
}
......@@ -1195,12 +1198,13 @@ void ScrollAnimatorMac::snapRubberBandTimerFired(Timer<ScrollAnimatorMac>*)
m_scrollableArea->didCompleteRubberBand(roundedIntSize(m_scrollElasticityController.m_startStretch));
m_snapRubberBandTimer.stop();
m_scrollElasticityController.m_stretchScrollForce = FloatSize();
m_scrollElasticityController.m_startTime = 0;
m_scrollElasticityController.m_startStretch = FloatSize();
m_scrollElasticityController.m_origOrigin = FloatPoint();
m_scrollElasticityController.m_origVelocity = FloatSize();
m_scrollElasticityController.m_snapRubberbandTimerIsActive = false;
}
} else {
m_scrollElasticityController.m_startTime = [NSDate timeIntervalSinceReferenceDate];
......
......@@ -70,6 +70,8 @@ public:
FloatSize m_startStretch;
FloatPoint m_origOrigin;
FloatSize m_origVelocity;
bool m_snapRubberbandTimerIsActive;
};
} // namespace WebCore
......
......@@ -41,6 +41,7 @@ ScrollElasticityController::ScrollElasticityController(ScrollElasticityControlle
, m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin(false)
, m_lastMomentumScrollTimestamp(0)
, m_startTime(0)
, m_snapRubberbandTimerIsActive(false)
{
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment