OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011, Google Inc. All rights reserved. | 2 * Copyright (c) 2011, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 #ifndef ScrollAnimator_h | 31 #ifndef ScrollAnimator_h |
32 #define ScrollAnimator_h | 32 #define ScrollAnimator_h |
33 | 33 |
34 #include "platform/Timer.h" | 34 #include "platform/Timer.h" |
35 #include "platform/animation/CompositorAnimationDelegate.h" | 35 #include "platform/animation/CompositorAnimationDelegate.h" |
36 #include "platform/animation/CompositorAnimationPlayerClient.h" | 36 #include "platform/animation/CompositorAnimationPlayerClient.h" |
37 #include "platform/animation/CompositorScrollOffsetAnimationCurve.h" | 37 #include "platform/animation/CompositorScrollOffsetAnimationCurve.h" |
38 #include "platform/geometry/FloatPoint.h" | 38 #include "platform/geometry/FloatPoint.h" |
39 #include "platform/scroll/ScrollAnimatorBase.h" | 39 #include "platform/scroll/ScrollAnimatorBase.h" |
| 40 #include <memory> |
40 | 41 |
41 namespace blink { | 42 namespace blink { |
42 | 43 |
43 class ScrollAnimatorTest; | 44 class ScrollAnimatorTest; |
44 class CompositorAnimationTimeline; | 45 class CompositorAnimationTimeline; |
45 | 46 |
46 class PLATFORM_EXPORT ScrollAnimator : public ScrollAnimatorBase { | 47 class PLATFORM_EXPORT ScrollAnimator : public ScrollAnimatorBase { |
47 public: | 48 public: |
48 explicit ScrollAnimator(ScrollableArea*, WTF::TimeFunction = WTF::monotonica
llyIncreasingTime); | 49 explicit ScrollAnimator(ScrollableArea*, WTF::TimeFunction = WTF::monotonica
llyIncreasingTime); |
49 ~ScrollAnimator() override; | 50 ~ScrollAnimator() override; |
(...skipping 20 matching lines...) Expand all Loading... |
70 | 71 |
71 protected: | 72 protected: |
72 // Returns whether or not the animation was sent to the compositor. | 73 // Returns whether or not the animation was sent to the compositor. |
73 virtual bool sendAnimationToCompositor(); | 74 virtual bool sendAnimationToCompositor(); |
74 | 75 |
75 void notifyAnimationTakeover( | 76 void notifyAnimationTakeover( |
76 double monotonicTime, | 77 double monotonicTime, |
77 double animationStartTime, | 78 double animationStartTime, |
78 std::unique_ptr<cc::AnimationCurve>) override; | 79 std::unique_ptr<cc::AnimationCurve>) override; |
79 | 80 |
80 OwnPtr<CompositorScrollOffsetAnimationCurve> m_animationCurve; | 81 std::unique_ptr<CompositorScrollOffsetAnimationCurve> m_animationCurve; |
81 double m_startTime; | 82 double m_startTime; |
82 WTF::TimeFunction m_timeFunction; | 83 WTF::TimeFunction m_timeFunction; |
83 | 84 |
84 private: | 85 private: |
85 // Returns true if the animation was scheduled successfully. If animation | 86 // Returns true if the animation was scheduled successfully. If animation |
86 // could not be scheduled (e.g. because the frame is detached), scrolls | 87 // could not be scheduled (e.g. because the frame is detached), scrolls |
87 // immediately to the target and returns false. | 88 // immediately to the target and returns false. |
88 bool registerAndScheduleAnimation(); | 89 bool registerAndScheduleAnimation(); |
89 | 90 |
90 void createAnimationCurve(); | 91 void createAnimationCurve(); |
91 void postAnimationCleanupAndReset(); | 92 void postAnimationCleanupAndReset(); |
92 | 93 |
93 void addMainThreadScrollingReason(); | 94 void addMainThreadScrollingReason(); |
94 void removeMainThreadScrollingReason(); | 95 void removeMainThreadScrollingReason(); |
95 | 96 |
96 // Returns true if will animate to the given target position. Returns false | 97 // Returns true if will animate to the given target position. Returns false |
97 // only when there is no animation running and we are not starting one | 98 // only when there is no animation running and we are not starting one |
98 // because we are already at targetPos. | 99 // because we are already at targetPos. |
99 bool willAnimateToOffset(const FloatPoint& targetPos); | 100 bool willAnimateToOffset(const FloatPoint& targetPos); |
100 | 101 |
101 FloatPoint m_targetOffset; | 102 FloatPoint m_targetOffset; |
102 ScrollGranularity m_lastGranularity; | 103 ScrollGranularity m_lastGranularity; |
103 }; | 104 }; |
104 | 105 |
105 } // namespace blink | 106 } // namespace blink |
106 | 107 |
107 #endif // ScrollAnimator_h | 108 #endif // ScrollAnimator_h |
OLD | NEW |