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" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 // Returns true if the event indicates that the in-progress overscroll gesture | 83 // Returns true if the event indicates that the in-progress overscroll gesture |
84 // can now be completed. | 84 // can now be completed. |
85 bool DispatchEventCompletesAction( | 85 bool DispatchEventCompletesAction( |
86 const WebKit::WebInputEvent& event) const; | 86 const WebKit::WebInputEvent& event) const; |
87 | 87 |
88 // Returns true to indicate that dispatching the event should reset the | 88 // Returns true to indicate that dispatching the event should reset the |
89 // overscroll gesture status. | 89 // overscroll gesture status. |
90 bool DispatchEventResetsState(const WebKit::WebInputEvent& event) const; | 90 bool DispatchEventResetsState(const WebKit::WebInputEvent& event) const; |
91 | 91 |
92 // Processes an event and updates internal state for overscroll. | 92 // Processes an event to update the internal state for overscroll. Returns |
93 void ProcessEventForOverscroll(const WebKit::WebInputEvent& event); | 93 // true if the state is updated, false otherwise. |
| 94 bool ProcessEventForOverscroll(const WebKit::WebInputEvent& event); |
94 | 95 |
95 // Processes horizontal overscroll. This can update both the overscroll mode | 96 // Processes horizontal overscroll. This can update both the overscroll mode |
96 // and the over scroll amount (i.e. |overscroll_mode_|, |overscroll_delta_x_| | 97 // and the over scroll amount (i.e. |overscroll_mode_|, |overscroll_delta_x_| |
97 // and |overscroll_delta_y_|). | 98 // and |overscroll_delta_y_|). |
98 void ProcessOverscroll(float delta_x, | 99 void ProcessOverscroll(float delta_x, |
99 float delta_y, | 100 float delta_y, |
100 WebKit::WebInputEvent::Type event_type); | 101 WebKit::WebInputEvent::Type event_type); |
101 | 102 |
102 // Completes the desired action from the current gesture. | 103 // Completes the desired action from the current gesture. |
103 void CompleteAction(); | 104 void CompleteAction(); |
104 | 105 |
105 // Sets the overscroll mode (and triggers callback in the delegate when | 106 // Sets the overscroll mode (and triggers callback in the delegate when |
106 // appropriate). | 107 // appropriate). |
107 void SetOverscrollMode(OverscrollMode new_mode); | 108 void SetOverscrollMode(OverscrollMode new_mode); |
108 | 109 |
109 // Returns whether the input event should be forwarded to the | |
110 // RenderWidgetHost. | |
111 bool ShouldForwardToHost(const WebKit::WebInputEvent& event) const; | |
112 | |
113 // The RenderWidgetHost that owns this overscroll controller. | 110 // The RenderWidgetHost that owns this overscroll controller. |
114 RenderWidgetHostImpl* render_widget_host_; | 111 RenderWidgetHostImpl* render_widget_host_; |
115 | 112 |
116 // The current state of overscroll gesture. | 113 // The current state of overscroll gesture. |
117 OverscrollMode overscroll_mode_; | 114 OverscrollMode overscroll_mode_; |
118 | 115 |
119 // Used to keep track of the scrolling state. | 116 // Used to keep track of the scrolling state. |
120 // 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 |
121 // 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 |
122 // process any of the subsequent scroll events for generating overscroll | 119 // process any of the subsequent scroll events for generating overscroll |
123 // gestures. | 120 // gestures. |
124 ScrollState scroll_state_; | 121 ScrollState scroll_state_; |
125 | 122 |
126 // The amount of overscroll in progress. These values are invalid when | 123 // The amount of overscroll in progress. These values are invalid when |
127 // |overscroll_mode_| is set to OVERSCROLL_NONE. | 124 // |overscroll_mode_| is set to OVERSCROLL_NONE. |
128 float overscroll_delta_x_; | 125 float overscroll_delta_x_; |
129 float overscroll_delta_y_; | 126 float overscroll_delta_y_; |
130 | 127 |
131 // The delegate that receives the overscroll updates. The delegate is not | 128 // The delegate that receives the overscroll updates. The delegate is not |
132 // owned by this controller. | 129 // owned by this controller. |
133 OverscrollControllerDelegate* delegate_; | 130 OverscrollControllerDelegate* delegate_; |
134 | 131 |
135 DISALLOW_COPY_AND_ASSIGN(OverscrollController); | 132 DISALLOW_COPY_AND_ASSIGN(OverscrollController); |
136 }; | 133 }; |
137 | 134 |
138 } // namespace content | 135 } // namespace content |
139 | 136 |
140 #endif // CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ | 137 #endif // CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ |
OLD | NEW |