| 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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "content/common/input/input_event_ack_state.h" | 12 #include "content/common/input/input_event_ack_state.h" |
| 13 #include "ui/android/overscroll_glow.h" | 13 #include "ui/android/overscroll_glow.h" |
| 14 #include "ui/android/overscroll_refresh.h" | 14 #include "ui/android/overscroll_refresh.h" |
| 15 #include "ui/gfx/geometry/vector2d_f.h" | 15 #include "ui/gfx/geometry/vector2d_f.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 class WebGestureEvent; | 18 class WebGestureEvent; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace cc { | 21 namespace cc { |
| 22 class CompositorFrameMetadata; | 22 class CompositorFrameMetadata; |
| 23 class Layer; | 23 class Layer; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace ui { | 26 namespace ui { |
| 27 class WindowAndroidCompositor; | 27 class WindowAndroidCompositor; |
| 28 struct DidOverscrollParams; |
| 28 } | 29 } |
| 29 | 30 |
| 30 namespace content { | 31 namespace content { |
| 31 | 32 |
| 32 class ContentViewCoreImpl; | 33 class ContentViewCoreImpl; |
| 33 struct DidOverscrollParams; | |
| 34 | 34 |
| 35 // Glue class for handling all inputs into Android-specific overscroll effects, | 35 // Glue class for handling all inputs into Android-specific overscroll effects, |
| 36 // both the passive overscroll glow and the active overscroll pull-to-refresh. | 36 // both the passive overscroll glow and the active overscroll pull-to-refresh. |
| 37 // Note that all input coordinates (both for events and overscroll) are in DIPs. | 37 // Note that all input coordinates (both for events and overscroll) are in DIPs. |
| 38 class OverscrollControllerAndroid : public ui::OverscrollGlowClient { | 38 class OverscrollControllerAndroid : public ui::OverscrollGlowClient { |
| 39 public: | 39 public: |
| 40 explicit OverscrollControllerAndroid(ContentViewCoreImpl* content_view_core, | 40 explicit OverscrollControllerAndroid(ContentViewCoreImpl* content_view_core, |
| 41 float dpi_scale); | 41 float dpi_scale); |
| 42 ~OverscrollControllerAndroid() override; | 42 ~OverscrollControllerAndroid() override; |
| 43 | 43 |
| 44 // Returns true if |event| is consumed by an overscroll effect, in which | 44 // Returns true if |event| is consumed by an overscroll effect, in which |
| 45 // case it should cease propagation. | 45 // case it should cease propagation. |
| 46 bool WillHandleGestureEvent(const blink::WebGestureEvent& event); | 46 bool WillHandleGestureEvent(const blink::WebGestureEvent& event); |
| 47 | 47 |
| 48 // To be called upon receipt of a gesture event ack. | 48 // To be called upon receipt of a gesture event ack. |
| 49 void OnGestureEventAck(const blink::WebGestureEvent& event, | 49 void OnGestureEventAck(const blink::WebGestureEvent& event, |
| 50 InputEventAckState ack_result); | 50 InputEventAckState ack_result); |
| 51 | 51 |
| 52 // To be called upon receipt of an overscroll event. | 52 // To be called upon receipt of an overscroll event. |
| 53 void OnOverscrolled(const DidOverscrollParams& overscroll_params); | 53 void OnOverscrolled(const ui::DidOverscrollParams& overscroll_params); |
| 54 | 54 |
| 55 // Returns true if the effect still needs animation ticks. | 55 // Returns true if the effect still needs animation ticks. |
| 56 // Note: The effect will detach itself when no further animation is required. | 56 // Note: The effect will detach itself when no further animation is required. |
| 57 bool Animate(base::TimeTicks current_time, cc::Layer* parent_layer); | 57 bool Animate(base::TimeTicks current_time, cc::Layer* parent_layer); |
| 58 | 58 |
| 59 // To be called whenever the content frame has been updated. | 59 // To be called whenever the content frame has been updated. |
| 60 void OnFrameMetadataUpdated(const cc::CompositorFrameMetadata& metadata); | 60 void OnFrameMetadataUpdated(const cc::CompositorFrameMetadata& metadata); |
| 61 | 61 |
| 62 // Toggle activity of any overscroll effects. When disabled, events will be | 62 // Toggle activity of any overscroll effects. When disabled, events will be |
| 63 // ignored until the controller is re-enabled. | 63 // ignored until the controller is re-enabled. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 78 // TODO(jdduke): Factor out a common API from the two overscroll effects. | 78 // TODO(jdduke): Factor out a common API from the two overscroll effects. |
| 79 std::unique_ptr<ui::OverscrollGlow> glow_effect_; | 79 std::unique_ptr<ui::OverscrollGlow> glow_effect_; |
| 80 std::unique_ptr<ui::OverscrollRefresh> refresh_effect_; | 80 std::unique_ptr<ui::OverscrollRefresh> refresh_effect_; |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(OverscrollControllerAndroid); | 82 DISALLOW_COPY_AND_ASSIGN(OverscrollControllerAndroid); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 } // namespace content | 85 } // namespace content |
| 86 | 86 |
| 87 #endif // CONTENT_BROWSER_ANDROID_OVERSCROLL_CONTROLLER_ANDROID_H_ | 87 #endif // CONTENT_BROWSER_ANDROID_OVERSCROLL_CONTROLLER_ANDROID_H_ |
| OLD | NEW |