Commit 57cfd40e authored by andersca@apple.com's avatar andersca@apple.com

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.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96663 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 33a67246
2011-10-04 Anders Carlsson <andersca@apple.com>
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.
2011-10-04 Scott Graham <scottmg@chromium.org>
Add GAMEPAD feature flag
......@@ -138,6 +138,13 @@ private:
FloatPoint adjustScrollPositionIfNecessary(const FloatPoint&) const;
#if ENABLE(RUBBER_BANDING)
/// ScrollElasticityControllerClient member functions.
virtual bool isHorizontalScrollerPinnedToMinimumPosition() OVERRIDE;
virtual bool isHorizontalScrollerPinnedToMaximumPosition() OVERRIDE;
virtual IntSize stretchAmount() OVERRIDE;
virtual void startSnapRubberbandTimer() OVERRIDE;
virtual void stopSnapRubberbandTimer() OVERRIDE;
bool allowsVerticalStretching() const;
bool allowsHorizontalStretching() const;
bool pinnedInDirection(float deltaX, float deltaY);
......
......@@ -882,6 +882,31 @@ bool ScrollAnimatorMac::pinnedInDirection(float deltaX, float deltaY)
return false;
}
bool ScrollAnimatorMac::isHorizontalScrollerPinnedToMinimumPosition()
{
return m_scrollableArea->isHorizontalScrollerPinnedToMinimumPosition();
}
bool ScrollAnimatorMac::isHorizontalScrollerPinnedToMaximumPosition()
{
return m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition();
}
IntSize ScrollAnimatorMac::stretchAmount()
{
return m_scrollableArea->overhangAmount();
}
void ScrollAnimatorMac::startSnapRubberbandTimer()
{
m_snapRubberBandTimer.startRepeating(1.0 / 60.0);
}
void ScrollAnimatorMac::stopSnapRubberbandTimer()
{
m_snapRubberBandTimer.stop();
}
bool ScrollAnimatorMac::allowsVerticalStretching() const
{
switch (m_scrollableArea->verticalScrollElasticity()) {
......@@ -1075,26 +1100,9 @@ void ScrollAnimatorMac::smoothScrollWithEvent(const PlatformWheelEvent& wheelEve
void ScrollAnimatorMac::beginScrollGesture()
{
didBeginScrollGesture();
m_haveScrolledSincePageLoad = true;
m_scrollElasticityController.m_inScrollGesture = true;
m_scrollElasticityController.m_momentumScrollInProgress = false;
m_scrollElasticityController.m_ignoreMomentumScrolls = false;
m_scrollElasticityController.m_lastMomentumScrollTimestamp = 0;
m_scrollElasticityController.m_momentumVelocity = FloatSize();
m_scrollElasticityController.m_scrollerInitiallyPinnedOnLeft = m_scrollableArea->isHorizontalScrollerPinnedToMinimumPosition();
m_scrollElasticityController.m_scrollerInitiallyPinnedOnRight = m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition();
m_scrollElasticityController.m_cumulativeHorizontalScroll = 0;
m_scrollElasticityController.m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = false;
IntSize stretchAmount = m_scrollableArea->overhangAmount();
m_scrollElasticityController.m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(stretchAmount.width()));
m_scrollElasticityController.m_stretchScrollForce.setHeight(reboundDeltaForElasticDelta(stretchAmount.height()));
m_scrollElasticityController.m_overflowScrollDelta = FloatSize();
m_snapRubberBandTimer.stop();
m_scrollElasticityController.m_snapRubberbandTimerIsActive = false;
m_scrollElasticityController.beginScrollGesture();
}
void ScrollAnimatorMac::endScrollGesture()
......
......@@ -35,8 +35,17 @@
namespace WebCore {
class ScrollElasticityControllerClient {
public:
protected:
virtual ~ScrollElasticityControllerClient() { }
public:
virtual bool isHorizontalScrollerPinnedToMinimumPosition() = 0;
virtual bool isHorizontalScrollerPinnedToMaximumPosition() = 0;
virtual IntSize stretchAmount() = 0;
virtual void startSnapRubberbandTimer() = 0;
virtual void stopSnapRubberbandTimer() = 0;
};
class ScrollElasticityController {
......@@ -45,9 +54,13 @@ class ScrollElasticityController {
public:
explicit ScrollElasticityController(ScrollElasticityControllerClient*);
void beginScrollGesture();
private:
ScrollElasticityControllerClient* m_client;
void stopSnapRubberbandTimer();
// FIXME: These member variables should be private. They are currently public as a stop-gap measure, while
// the rubber-band related code from ScrollAnimatorMac is being moved over.
public:
......
......@@ -30,6 +30,13 @@
namespace WebCore {
static const float rubberbandStiffness = 20;
static float reboundDeltaForElasticDelta(float delta)
{
return delta * rubberbandStiffness;
}
ScrollElasticityController::ScrollElasticityController(ScrollElasticityControllerClient* client)
: m_client(client)
, m_inScrollGesture(false)
......@@ -45,6 +52,33 @@ ScrollElasticityController::ScrollElasticityController(ScrollElasticityControlle
{
}
void ScrollElasticityController::beginScrollGesture()
{
m_inScrollGesture = true;
m_momentumScrollInProgress = false;
m_ignoreMomentumScrolls = false;
m_lastMomentumScrollTimestamp = 0;
m_momentumVelocity = FloatSize();
m_scrollerInitiallyPinnedOnLeft = m_client->isHorizontalScrollerPinnedToMinimumPosition();
m_scrollerInitiallyPinnedOnRight = m_client->isHorizontalScrollerPinnedToMaximumPosition();
m_cumulativeHorizontalScroll = 0;
m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = false;
IntSize stretchAmount = m_client->stretchAmount();
m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(stretchAmount.width()));
m_stretchScrollForce.setHeight(reboundDeltaForElasticDelta(stretchAmount.height()));
m_overflowScrollDelta = FloatSize();
stopSnapRubberbandTimer();
}
void ScrollElasticityController::stopSnapRubberbandTimer()
{
m_client->stopSnapRubberbandTimer();
m_snapRubberbandTimerIsActive = false;
}
} // namespace WebCore
#endif // ENABLE(RUBBER_BANDING)
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