Commit 40542f9b authored by andersca@apple.com's avatar andersca@apple.com

Make ScrollAnimatorMac::snapRubberBandTimerFired use m_scrollElasticityController in more places

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

Reviewed by Sam Weinig.

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

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@104321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6119f4bd
2012-01-06 Anders Carlsson <andersca@apple.com>
Make ScrollAnimatorMac::snapRubberBandTimerFired use m_scrollElasticityController in more places
https://bugs.webkit.org/show_bug.cgi?id=75726
Reviewed by Sam Weinig.
* platform/mac/ScrollAnimatorMac.h:
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::canScrollHorizontally):
(WebCore::ScrollAnimatorMac::canScrollVertically):
(WebCore::ScrollAnimatorMac::snapRubberBandTimerFired):
* platform/mac/ScrollElasticityController.h:
2012-01-06 Pratik Solanki <psolanki@apple.com>
WebKit1 fails to compile with USE(CFNETWORK) and HAVE(NETWORK_CFDATA_ARRAY_CALLBACK)
......@@ -128,6 +128,8 @@ private:
/// ScrollElasticityControllerClient member functions.
virtual IntSize stretchAmount() OVERRIDE;
virtual bool pinnedInDirection(const FloatSize&) OVERRIDE;
virtual bool canScrollHorizontally() OVERRIDE;
virtual bool canScrollVertically() OVERRIDE;
virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) OVERRIDE;
virtual void immediateScrollBy(const FloatSize&) OVERRIDE;
virtual void startSnapRubberbandTimer() OVERRIDE;
......
......@@ -1065,6 +1065,22 @@ bool ScrollAnimatorMac::pinnedInDirection(const FloatSize& direction)
return pinnedInDirection(direction.width(), direction.height());
}
bool ScrollAnimatorMac::canScrollHorizontally()
{
Scrollbar* scrollbar = m_scrollableArea->horizontalScrollbar();
if (!scrollbar)
return false;
return scrollbar->enabled();
}
bool ScrollAnimatorMac::canScrollVertically()
{
Scrollbar* scrollbar = m_scrollableArea->verticalScrollbar();
if (!scrollbar)
return false;
return scrollbar->enabled();
}
void ScrollAnimatorMac::immediateScrollByWithoutContentEdgeConstraints(const FloatSize& delta)
{
m_scrollableArea->setConstrainsScrollingToContentEdge(false);
......@@ -1320,9 +1336,9 @@ void ScrollAnimatorMac::snapRubberBandTimerFired(Timer<ScrollAnimatorMac>*)
CFTimeInterval timeDelta = [NSDate timeIntervalSinceReferenceDate] - m_scrollElasticityController.m_startTime;
if (m_scrollElasticityController.m_startStretch == FloatSize()) {
m_scrollElasticityController.m_startStretch = m_scrollableArea->overhangAmount();
if (m_scrollElasticityController.m_startStretch == FloatSize()) {
m_snapRubberBandTimer.stop();
m_scrollElasticityController.m_startStretch = m_scrollElasticityController.m_client->stretchAmount();
if (m_scrollElasticityController.m_startStretch == FloatSize()) {
m_scrollElasticityController.m_client->stopSnapRubberbandTimer();
m_scrollElasticityController.m_stretchScrollForce = FloatSize();
m_scrollElasticityController.m_startTime = 0;
......@@ -1342,13 +1358,11 @@ void ScrollAnimatorMac::snapRubberBandTimerFired(Timer<ScrollAnimatorMac>*)
m_scrollElasticityController.m_origVelocity.setWidth(0);
// Don't rubber-band horizontally if it's not possible to scroll horizontally
Scrollbar* hScroller = m_scrollableArea->horizontalScrollbar();
if (!hScroller || !hScroller->enabled())
if (!m_scrollElasticityController.m_client->canScrollHorizontally())
m_scrollElasticityController.m_origVelocity.setWidth(0);
// Don't rubber-band vertically if it's not possible to scroll horizontally
Scrollbar* vScroller = m_scrollableArea->verticalScrollbar();
if (!vScroller || !vScroller->enabled())
// Don't rubber-band vertically if it's not possible to scroll vertically
if (!m_scrollElasticityController.m_client->canScrollVertically())
m_scrollElasticityController.m_origVelocity.setHeight(0);
}
......@@ -1358,16 +1372,16 @@ void ScrollAnimatorMac::snapRubberBandTimerFired(Timer<ScrollAnimatorMac>*)
if (fabs(delta.x()) >= 1 || fabs(delta.y()) >= 1) {
FloatPoint newOrigin = m_scrollElasticityController.m_origOrigin + delta;
immediateScrollByWithoutContentEdgeConstraints(FloatSize(delta.x(), delta.y()) - m_scrollableArea->overhangAmount());
immediateScrollByWithoutContentEdgeConstraints(FloatSize(delta.x(), delta.y()) - m_scrollElasticityController.m_client->stretchAmount());
FloatSize newStretch = m_scrollableArea->overhangAmount();
FloatSize newStretch = m_scrollElasticityController.m_client->stretchAmount();
m_scrollElasticityController.m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(newStretch.width()));
m_scrollElasticityController.m_stretchScrollForce.setHeight(reboundDeltaForElasticDelta(newStretch.height()));
} else {
immediateScrollTo(m_scrollElasticityController.m_origOrigin);
m_snapRubberBandTimer.stop();
m_scrollElasticityController.m_client->stopSnapRubberbandTimer();
m_scrollElasticityController.m_stretchScrollForce = FloatSize();
m_scrollElasticityController.m_startTime = 0;
......
......@@ -41,6 +41,8 @@ protected:
public:
virtual IntSize stretchAmount() = 0;
virtual bool pinnedInDirection(const FloatSize&) = 0;
virtual bool canScrollHorizontally() = 0;
virtual bool canScrollVertically() = 0;
virtual void immediateScrollBy(const FloatSize&) = 0;
virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) = 0;
virtual void startSnapRubberbandTimer() = 0;
......
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