| 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 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 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" | |
| 39 #include "platform/scroll/ScrollAnimatorBase.h" | 38 #include "platform/scroll/ScrollAnimatorBase.h" |
| 40 #include <memory> | 39 #include <memory> |
| 41 | 40 |
| 42 namespace blink { | 41 namespace blink { |
| 43 | 42 |
| 44 class ScrollAnimatorTest; | 43 class ScrollAnimatorTest; |
| 45 class CompositorAnimationTimeline; | 44 class CompositorAnimationTimeline; |
| 46 | 45 |
| 47 class PLATFORM_EXPORT ScrollAnimator : public ScrollAnimatorBase { | 46 class PLATFORM_EXPORT ScrollAnimator : public ScrollAnimatorBase { |
| 48 public: | 47 public: |
| 49 explicit ScrollAnimator(ScrollableArea*, | 48 explicit ScrollAnimator(ScrollableArea*, |
| 50 WTF::TimeFunction = WTF::monotonicallyIncreasingTime); | 49 WTF::TimeFunction = WTF::monotonicallyIncreasingTime); |
| 51 ~ScrollAnimator() override; | 50 ~ScrollAnimator() override; |
| 52 | 51 |
| 53 bool hasRunningAnimation() const override; | 52 bool hasRunningAnimation() const override; |
| 54 FloatSize computeDeltaToConsume(const FloatSize& delta) const override; | 53 ScrollOffset computeDeltaToConsume(const ScrollOffset& delta) const override; |
| 55 | 54 |
| 56 ScrollResult userScroll(ScrollGranularity, const FloatSize& delta) override; | 55 ScrollResult userScroll(ScrollGranularity, |
| 57 void scrollToOffsetWithoutAnimation(const FloatPoint&) override; | 56 const ScrollOffset& delta) override; |
| 58 FloatPoint desiredTargetPosition() const override; | 57 void scrollToOffsetWithoutAnimation(const ScrollOffset&) override; |
| 58 ScrollOffset desiredTargetOffset() const override; |
| 59 | 59 |
| 60 // ScrollAnimatorCompositorCoordinator implementation. | 60 // ScrollAnimatorCompositorCoordinator implementation. |
| 61 void tickAnimation(double monotonicTime) override; | 61 void tickAnimation(double monotonicTime) override; |
| 62 void cancelAnimation() override; | 62 void cancelAnimation() override; |
| 63 void adjustAnimationAndSetScrollPosition(const DoublePoint& position, | 63 void adjustAnimationAndSetScrollOffset(const ScrollOffset&, |
| 64 ScrollType) override; | 64 ScrollType) override; |
| 65 void takeOverCompositorAnimation() override; | 65 void takeOverCompositorAnimation() override; |
| 66 void resetAnimationState() override; | 66 void resetAnimationState() override; |
| 67 void updateCompositorAnimations() override; | 67 void updateCompositorAnimations() override; |
| 68 void notifyCompositorAnimationFinished(int groupId) override; | 68 void notifyCompositorAnimationFinished(int groupId) override; |
| 69 void notifyCompositorAnimationAborted(int groupId) override; | 69 void notifyCompositorAnimationAborted(int groupId) override; |
| 70 void layerForCompositedScrollingDidChange( | 70 void layerForCompositedScrollingDidChange( |
| 71 CompositorAnimationTimeline*) override; | 71 CompositorAnimationTimeline*) override; |
| 72 | 72 |
| 73 DECLARE_VIRTUAL_TRACE(); | 73 DECLARE_VIRTUAL_TRACE(); |
| 74 | 74 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 89 // could not be scheduled (e.g. because the frame is detached), scrolls | 89 // could not be scheduled (e.g. because the frame is detached), scrolls |
| 90 // immediately to the target and returns false. | 90 // immediately to the target and returns false. |
| 91 bool registerAndScheduleAnimation(); | 91 bool registerAndScheduleAnimation(); |
| 92 | 92 |
| 93 void createAnimationCurve(); | 93 void createAnimationCurve(); |
| 94 void postAnimationCleanupAndReset(); | 94 void postAnimationCleanupAndReset(); |
| 95 | 95 |
| 96 void addMainThreadScrollingReason(); | 96 void addMainThreadScrollingReason(); |
| 97 void removeMainThreadScrollingReason(); | 97 void removeMainThreadScrollingReason(); |
| 98 | 98 |
| 99 // Returns true if will animate to the given target position. Returns false | 99 // Returns true if will animate to the given target offset. Returns false |
| 100 // only when there is no animation running and we are not starting one | 100 // only when there is no animation running and we are not starting one |
| 101 // because we are already at targetPos. | 101 // because we are already at targetPos. |
| 102 bool willAnimateToOffset(const FloatPoint& targetPos); | 102 bool willAnimateToOffset(const ScrollOffset& targetPos); |
| 103 | 103 |
| 104 FloatPoint m_targetOffset; | 104 ScrollOffset m_targetOffset; |
| 105 ScrollGranularity m_lastGranularity; | 105 ScrollGranularity m_lastGranularity; |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 } // namespace blink | 108 } // namespace blink |
| 109 | 109 |
| 110 #endif // ScrollAnimator_h | 110 #endif // ScrollAnimator_h |
| OLD | NEW |