2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef ScrollAnimatorMac_h
27 #define ScrollAnimatorMac_h
29 #if ENABLE(SMOOTH_SCROLLING)
31 #include "FloatPoint.h"
32 #include "FloatSize.h"
33 #include "ScrollAnimator.h"
35 #include "WebCoreSystemInterface.h"
36 #include <wtf/RetainPtr.h>
39 @class ScrollAnimationHelperDelegate;
40 @class ScrollbarPainterDelegate;
41 @class ScrollbarPainterControllerDelegate;
42 @class ScrollbarPainterDelegate;
44 class ScrollAnimationHelperDelegate;
45 class ScrollbarPainterDelegate;
46 class ScrollbarPainterControllerDelegate;
47 class ScrollbarPainterDelegate;
54 class ScrollAnimatorMac : public ScrollAnimator {
56 ScrollAnimatorMac(ScrollableArea*);
57 virtual ~ScrollAnimatorMac();
59 #if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
60 void setPainterForPainterController(WKScrollbarPainterRef, bool isHorizontal);
61 void removePainterFromPainterController(ScrollbarOrientation orientation);
64 virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier);
65 virtual void scrollToOffsetWithoutAnimation(const FloatPoint&);
67 #if ENABLE(RUBBER_BANDING)
68 virtual void handleWheelEvent(PlatformWheelEvent&);
69 #if ENABLE(GESTURE_EVENTS)
70 virtual void handleGestureEvent(const PlatformGestureEvent&);
74 void immediateScrollToPoint(const FloatPoint& newPosition);
75 void immediateScrollByDeltaX(float deltaX);
76 void immediateScrollByDeltaY(float deltaY);
78 id scrollbarPainterDelegate();
81 RetainPtr<id> m_scrollAnimationHelper;
82 RetainPtr<ScrollAnimationHelperDelegate> m_scrollAnimationHelperDelegate;
84 #if defined(USE_WK_SCROLLBAR_PAINTER_AND_CONTROLLER)
85 RetainPtr<WKScrollbarPainterControllerRef> m_scrollbarPainterController;
86 RetainPtr<ScrollbarPainterControllerDelegate> m_scrollbarPainterControllerDelegate;
87 RetainPtr<id> m_scrollbarPainterDelegate;
90 virtual void notityPositionChanged();
91 virtual void contentAreaWillPaint() const;
92 virtual void mouseEnteredContentArea() const;
93 virtual void mouseExitedContentArea() const;
94 virtual void mouseMovedInContentArea() const;
95 virtual void willStartLiveResize();
96 virtual void contentsResized() const;
97 virtual void willEndLiveResize();
98 virtual void contentAreaDidShow() const;
99 virtual void contentAreaDidHide() const;
101 #if ENABLE(RUBBER_BANDING)
102 bool allowsVerticalStretching() const;
103 bool allowsHorizontalStretching() const;
104 bool pinnedInDirection(float deltaX, float deltaY);
105 void snapRubberBand();
106 void snapRubberBandTimerFired(Timer<ScrollAnimatorMac>*);
107 void smoothScrollWithEvent(PlatformWheelEvent&);
108 void beginScrollGesture();
109 void endScrollGesture();
111 bool m_inScrollGesture;
112 bool m_momentumScrollInProgress;
113 bool m_ignoreMomentumScrolls;
114 CFTimeInterval m_lastMomemtumScrollTimestamp;
115 FloatSize m_overflowScrollDelta;
116 FloatSize m_stretchScrollForce;
117 FloatSize m_momentumVelocity;
119 // Rubber band state.
120 CFTimeInterval m_startTime;
121 FloatSize m_startStretch;
122 FloatPoint m_origOrigin;
123 FloatSize m_origVelocity;
124 Timer<ScrollAnimatorMac> m_snapRubberBandTimer;
128 } // namespace WebCore
130 #endif // ENABLE(SMOOTH_SCROLLING)
132 #endif // ScrollAnimatorMac_h