#ifndef ScrollElasticityController_h
#define ScrollElasticityController_h
#if USE(RUBBER_BANDING)
#include "platform/geometry/FloatPoint.h"
#include "platform/geometry/FloatSize.h"
#include "platform/scroll/ScrollTypes.h"
#include "wtf/Noncopyable.h"
namespace WebCore {
class PlatformWheelEvent;
class ScrollElasticityControllerClient {
protected:
virtual ~ScrollElasticityControllerClient() { }
public:
virtual bool allowsHorizontalStretching() = 0;
virtual bool allowsVerticalStretching() = 0;
virtual IntSize stretchAmount() = 0;
virtual bool pinnedInDirection(const FloatSize&) = 0;
virtual bool canScrollHorizontally() = 0;
virtual bool canScrollVertically() = 0;
virtual bool shouldRubberBandInDirection(ScrollDirection) = 0;
virtual WebCore::IntPoint absoluteScrollPosition() = 0;
virtual void immediateScrollBy(const FloatSize&) = 0;
virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) = 0;
virtual void startSnapRubberbandTimer() = 0;
virtual void stopSnapRubberbandTimer() = 0;
};
class ScrollElasticityController {
WTF_MAKE_NONCOPYABLE(ScrollElasticityController);
public:
explicit ScrollElasticityController(ScrollElasticityControllerClient*);
bool handleWheelEvent(const PlatformWheelEvent&);
void snapRubberBandTimerFired();
bool isRubberBandInProgress() const;
private:
void stopSnapRubberbandTimer();
void snapRubberBand();
bool shouldRubberBandInHorizontalDirection(const PlatformWheelEvent&);
ScrollElasticityControllerClient* m_client;
bool m_inScrollGesture;
bool m_momentumScrollInProgress;
bool m_ignoreMomentumScrolls;
CFTimeInterval m_lastMomentumScrollTimestamp;
FloatSize m_overflowScrollDelta;
FloatSize m_stretchScrollForce;
FloatSize m_momentumVelocity;
CFTimeInterval m_startTime;
FloatSize m_startStretch;
FloatPoint m_origOrigin;
FloatSize m_origVelocity;
bool m_snapRubberbandTimerIsActive;
};
}
#endif
#endif