| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_ANDROID_OVERSCROLL_CONTROLLER_ANDROID_H_ | 5 #ifndef CONTENT_BROWSER_ANDROID_OVERSCROLL_CONTROLLER_ANDROID_H_ |
| 6 #define CONTENT_BROWSER_ANDROID_OVERSCROLL_CONTROLLER_ANDROID_H_ | 6 #define CONTENT_BROWSER_ANDROID_OVERSCROLL_CONTROLLER_ANDROID_H_ |
| 7 | 7 |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "content/browser/android/overscroll_glow.h" | |
| 10 #include "content/browser/android/overscroll_refresh.h" | |
| 11 #include "content/common/input/input_event_ack_state.h" | 9 #include "content/common/input/input_event_ack_state.h" |
| 10 #include "ui/android/overscroll_glow.h" |
| 11 #include "ui/android/overscroll_refresh.h" |
| 12 #include "ui/gfx/geometry/vector2d_f.h" | 12 #include "ui/gfx/geometry/vector2d_f.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 class WebGestureEvent; | 15 class WebGestureEvent; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 class CompositorFrameMetadata; | 19 class CompositorFrameMetadata; |
| 20 class Layer; | 20 class Layer; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace ui { | 23 namespace ui { |
| 24 class WindowAndroidCompositor; | 24 class WindowAndroidCompositor; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace content { | 27 namespace content { |
| 28 | 28 |
| 29 class ContentViewCoreImpl; | 29 class ContentViewCoreImpl; |
| 30 struct DidOverscrollParams; | 30 struct DidOverscrollParams; |
| 31 | 31 |
| 32 // Glue class for handling all inputs into Android-specific overscroll effects, | 32 // Glue class for handling all inputs into Android-specific overscroll effects, |
| 33 // both the passive overscroll glow and the active overscroll pull-to-refresh. | 33 // both the passive overscroll glow and the active overscroll pull-to-refresh. |
| 34 // Note that all input coordinates (both for events and overscroll) are in DIPs. | 34 // Note that all input coordinates (both for events and overscroll) are in DIPs. |
| 35 class OverscrollControllerAndroid : public OverscrollGlowClient { | 35 class OverscrollControllerAndroid : public ui::OverscrollGlowClient { |
| 36 public: | 36 public: |
| 37 explicit OverscrollControllerAndroid(ContentViewCoreImpl* content_view_core); | 37 explicit OverscrollControllerAndroid(ContentViewCoreImpl* content_view_core); |
| 38 ~OverscrollControllerAndroid() override; | 38 ~OverscrollControllerAndroid() override; |
| 39 | 39 |
| 40 // Returns true if |event| is consumed by an overscroll effect, in which | 40 // Returns true if |event| is consumed by an overscroll effect, in which |
| 41 // case it should cease propagation. | 41 // case it should cease propagation. |
| 42 bool WillHandleGestureEvent(const blink::WebGestureEvent& event); | 42 bool WillHandleGestureEvent(const blink::WebGestureEvent& event); |
| 43 | 43 |
| 44 // To be called upon receipt of a gesture event ack. | 44 // To be called upon receipt of a gesture event ack. |
| 45 void OnGestureEventAck(const blink::WebGestureEvent& event, | 45 void OnGestureEventAck(const blink::WebGestureEvent& event, |
| 46 InputEventAckState ack_result); | 46 InputEventAckState ack_result); |
| 47 | 47 |
| 48 // To be called upon receipt of an overscroll event. | 48 // To be called upon receipt of an overscroll event. |
| 49 void OnOverscrolled(const DidOverscrollParams& overscroll_params); | 49 void OnOverscrolled(const DidOverscrollParams& overscroll_params); |
| 50 | 50 |
| 51 // Returns true if the effect still needs animation ticks. | 51 // Returns true if the effect still needs animation ticks. |
| 52 // Note: The effect will detach itself when no further animation is required. | 52 // Note: The effect will detach itself when no further animation is required. |
| 53 bool Animate(base::TimeTicks current_time, cc::Layer* parent_layer); | 53 bool Animate(base::TimeTicks current_time, cc::Layer* parent_layer); |
| 54 | 54 |
| 55 // To be called whenever the content frame has been updated. | 55 // To be called whenever the content frame has been updated. |
| 56 void OnFrameMetadataUpdated(const cc::CompositorFrameMetadata& metadata); | 56 void OnFrameMetadataUpdated(const cc::CompositorFrameMetadata& metadata); |
| 57 | 57 |
| 58 // Toggle activity of any overscroll effects. When disabled, events will be | 58 // Toggle activity of any overscroll effects. When disabled, events will be |
| 59 // ignored until the controller is re-enabled. | 59 // ignored until the controller is re-enabled. |
| 60 void Enable(); | 60 void Enable(); |
| 61 void Disable(); | 61 void Disable(); |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 // OverscrollGlowClient implementation. | 64 // OverscrollGlowClient implementation. |
| 65 scoped_ptr<EdgeEffectBase> CreateEdgeEffect() override; | 65 scoped_ptr<ui::EdgeEffectBase> CreateEdgeEffect() override; |
| 66 | 66 |
| 67 void SetNeedsAnimate(); | 67 void SetNeedsAnimate(); |
| 68 | 68 |
| 69 ui::WindowAndroidCompositor* const compositor_; | 69 ui::WindowAndroidCompositor* const compositor_; |
| 70 const float dpi_scale_; | 70 const float dpi_scale_; |
| 71 | 71 |
| 72 bool enabled_; | 72 bool enabled_; |
| 73 | 73 |
| 74 // TODO(jdduke): Factor out a common API from the two overscroll effects. | 74 // TODO(jdduke): Factor out a common API from the two overscroll effects. |
| 75 scoped_ptr<OverscrollGlow> glow_effect_; | 75 scoped_ptr<ui::OverscrollGlow> glow_effect_; |
| 76 scoped_ptr<OverscrollRefresh> refresh_effect_; | 76 scoped_ptr<ui::OverscrollRefresh> refresh_effect_; |
| 77 | 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(OverscrollControllerAndroid); | 78 DISALLOW_COPY_AND_ASSIGN(OverscrollControllerAndroid); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 } // namespace content | 81 } // namespace content |
| 82 | 82 |
| 83 #endif // CONTENT_BROWSER_ANDROID_OVERSCROLL_CONTROLLER_ANDROID_H_ | 83 #endif // CONTENT_BROWSER_ANDROID_OVERSCROLL_CONTROLLER_ANDROID_H_ |
| OLD | NEW |