2 * Copyright (c) 2011, Google 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 are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef ScrollAnimatorNone_h
32 #define ScrollAnimatorNone_h
34 #if ENABLE(SMOOTH_SCROLLING)
36 #include "LayoutTypes.h"
37 #include "ScrollAnimator.h"
40 class ScrollAnimatorNoneTest;
44 struct ScrollAnimatorParameters;
46 class ScrollAnimatorNone : public ScrollAnimator {
48 ScrollAnimatorNone(ScrollableArea*);
49 virtual ~ScrollAnimatorNone();
51 virtual bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier);
52 virtual void scrollToOffsetWithoutAnimation(const FloatPoint&);
54 virtual void willEndLiveResize();
55 virtual void didAddVerticalScrollbar(Scrollbar*);
56 virtual void didAddHorizontalScrollbar(Scrollbar*);
68 Parameters(bool isEnabled, double animationTime, double repeatMinimumSustainTime, Curve attackCurve, double attackTime, Curve releaseCurve, double releaseTime, Curve coastTimeCurve, double maximumCoastTime);
70 // Note that the times can be overspecified such that releaseTime or releaseTime and attackTime are greater
71 // than animationTime. animationTime takes priority over releaseTime, capping it. attackTime is capped at
72 // whatever time remains, or zero if none.
74 double m_animationTime;
75 double m_repeatMinimumSustainTime;
83 Curve m_coastTimeCurve;
84 double m_maximumCoastTime;
88 friend class ::ScrollAnimatorNoneTest;
91 PerAxisData(ScrollAnimatorNone* parent, float* currentPos, LayoutUnit visibleLength);
93 bool updateDataFromParameters(float step, float multiplier, float scrollableSize, double currentTime, Parameters*);
94 bool animateScroll(double currentTime);
95 void updateVisibleLength(LayoutUnit visibleLength);
97 static double curveAt(Curve, double t);
98 static double attackCurve(Curve, double deltaT, double curveT, double startPos, double attackPos);
99 static double releaseCurve(Curve, double deltaT, double curveT, double releasePos, double desiredPos);
100 static double coastCurve(Curve, double factor);
102 static double curveIntegralAt(Curve, double t);
103 static double attackArea(Curve, double startT, double endT);
104 static double releaseArea(Curve, double startT, double endT);
106 float* m_currentPosition;
107 double m_currentVelocity;
109 double m_desiredPosition;
110 double m_desiredVelocity;
112 double m_startPosition;
114 double m_startVelocity;
116 double m_animationTime;
117 double m_lastAnimationTime;
119 double m_attackPosition;
123 double m_releasePosition;
124 double m_releaseTime;
125 Curve m_releaseCurve;
127 LayoutUnit m_visibleLength;
130 void animationTimerFired(Timer<ScrollAnimatorNone>*);
131 void stopAnimationTimerIfNeeded();
132 void updateVisibleLengths();
134 PerAxisData m_horizontalData;
135 PerAxisData m_verticalData;
138 Timer<ScrollAnimatorNone> m_animationTimer;
141 } // namespace WebCore
143 #endif // ENABLE(SMOOTH_SCROLLING)
145 #endif // ScrollAnimatorNone_h