| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "third_party/WebKit/public/web/WebInputEvent.h" | 10 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 11 | 11 |
| 12 namespace ui { | 12 namespace ui { |
| 13 struct LatencyInfo; | 13 struct LatencyInfo; |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 class MockRenderWidgetHost; | 18 class MockRenderWidgetHost; |
| 19 class OverscrollControllerDelegate; | 19 class OverscrollControllerDelegate; |
| 20 class RenderWidgetHostImpl; | |
| 21 | 20 |
| 22 // Indicates the direction that the scroll is heading in relative to the screen, | 21 // Indicates the direction that the scroll is heading in relative to the screen, |
| 23 // with the top being NORTH. | 22 // with the top being NORTH. |
| 24 enum OverscrollMode { | 23 enum OverscrollMode { |
| 25 OVERSCROLL_NONE, | 24 OVERSCROLL_NONE, |
| 26 OVERSCROLL_NORTH, | 25 OVERSCROLL_NORTH, |
| 27 OVERSCROLL_SOUTH, | 26 OVERSCROLL_SOUTH, |
| 28 OVERSCROLL_WEST, | 27 OVERSCROLL_WEST, |
| 29 OVERSCROLL_EAST, | 28 OVERSCROLL_EAST, |
| 30 OVERSCROLL_COUNT | 29 OVERSCROLL_COUNT |
| 31 }; | 30 }; |
| 32 | 31 |
| 33 // When a page is scrolled beyond the scrollable region, it will trigger an | 32 // When a page is scrolled beyond the scrollable region, it will trigger an |
| 34 // overscroll gesture. This controller receives the events that are dispatched | 33 // overscroll gesture. This controller receives the events that are dispatched |
| 35 // to the renderer, and the ACKs of events, and updates the overscroll gesture | 34 // to the renderer, and the ACKs of events, and updates the overscroll gesture |
| 36 // status accordingly. | 35 // status accordingly. |
| 37 class OverscrollController { | 36 class OverscrollController { |
| 38 public: | 37 public: |
| 39 // Creates an overscroll controller for the specified RenderWidgetHost. | 38 OverscrollController(); |
| 40 // The RenderWidgetHost owns this overscroll controller. | |
| 41 // TODO(jdduke): crbug.com/306194 - Take an OverscrollControllerClient. | |
| 42 explicit OverscrollController(RenderWidgetHostImpl* widget_host); | |
| 43 virtual ~OverscrollController(); | 39 virtual ~OverscrollController(); |
| 44 | 40 |
| 45 // The result of |DispatchEvent()|, indicating either how the event was | 41 // The result of |DispatchEvent()|, indicating either how the event was |
| 46 // handled, or how it should be handled by the caller. | 42 // handled, or how it should be handled by the caller. |
| 47 enum Disposition { | 43 enum Disposition { |
| 48 CONSUMED, | 44 CONSUMED, |
| 49 SHOULD_FORWARD_TO_RENDERER, | 45 SHOULD_FORWARD_TO_RENDERER, |
| 50 SHOULD_FORWARD_TO_GESTURE_FILTER | 46 SHOULD_FORWARD_TO_GESTURE_FILTER |
| 51 }; | 47 }; |
| 52 // This must be called when dispatching any event from the | 48 // This must be called when dispatching any event from the |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 float delta_y, | 103 float delta_y, |
| 108 WebKit::WebInputEvent::Type event_type); | 104 WebKit::WebInputEvent::Type event_type); |
| 109 | 105 |
| 110 // Completes the desired action from the current gesture. | 106 // Completes the desired action from the current gesture. |
| 111 void CompleteAction(); | 107 void CompleteAction(); |
| 112 | 108 |
| 113 // Sets the overscroll mode (and triggers callback in the delegate when | 109 // Sets the overscroll mode (and triggers callback in the delegate when |
| 114 // appropriate). | 110 // appropriate). |
| 115 void SetOverscrollMode(OverscrollMode new_mode); | 111 void SetOverscrollMode(OverscrollMode new_mode); |
| 116 | 112 |
| 117 // The RenderWidgetHost that owns this overscroll controller. | |
| 118 RenderWidgetHostImpl* render_widget_host_; | |
| 119 | |
| 120 // The current state of overscroll gesture. | 113 // The current state of overscroll gesture. |
| 121 OverscrollMode overscroll_mode_; | 114 OverscrollMode overscroll_mode_; |
| 122 | 115 |
| 123 // Used to keep track of the scrolling state. | 116 // Used to keep track of the scrolling state. |
| 124 // If scrolling starts, and some scroll events are consumed at the beginning | 117 // If scrolling starts, and some scroll events are consumed at the beginning |
| 125 // of the scroll (i.e. some content on the web-page was scrolled), then do not | 118 // of the scroll (i.e. some content on the web-page was scrolled), then do not |
| 126 // process any of the subsequent scroll events for generating overscroll | 119 // process any of the subsequent scroll events for generating overscroll |
| 127 // gestures. | 120 // gestures. |
| 128 ScrollState scroll_state_; | 121 ScrollState scroll_state_; |
| 129 | 122 |
| 130 // The amount of overscroll in progress. These values are invalid when | 123 // The amount of overscroll in progress. These values are invalid when |
| 131 // |overscroll_mode_| is set to OVERSCROLL_NONE. | 124 // |overscroll_mode_| is set to OVERSCROLL_NONE. |
| 132 float overscroll_delta_x_; | 125 float overscroll_delta_x_; |
| 133 float overscroll_delta_y_; | 126 float overscroll_delta_y_; |
| 134 | 127 |
| 135 // The delegate that receives the overscroll updates. The delegate is not | 128 // The delegate that receives the overscroll updates. The delegate is not |
| 136 // owned by this controller. | 129 // owned by this controller. |
| 137 OverscrollControllerDelegate* delegate_; | 130 OverscrollControllerDelegate* delegate_; |
| 138 | 131 |
| 139 DISALLOW_COPY_AND_ASSIGN(OverscrollController); | 132 DISALLOW_COPY_AND_ASSIGN(OverscrollController); |
| 140 }; | 133 }; |
| 141 | 134 |
| 142 } // namespace content | 135 } // namespace content |
| 143 | 136 |
| 144 #endif // CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ | 137 #endif // CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ |
| OLD | NEW |