OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 CC_INPUT_INPUT_HANDLER_H_ | 5 #ifndef CC_INPUT_INPUT_HANDLER_H_ |
6 #define CC_INPUT_INPUT_HANDLER_H_ | 6 #define CC_INPUT_INPUT_HANDLER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 : thread(SCROLL_ON_IMPL_THREAD), | 92 : thread(SCROLL_ON_IMPL_THREAD), |
93 main_thread_scrolling_reasons( | 93 main_thread_scrolling_reasons( |
94 MainThreadScrollingReason::kNotScrollingOnMain) {} | 94 MainThreadScrollingReason::kNotScrollingOnMain) {} |
95 ScrollStatus(ScrollThread thread, uint32_t main_thread_scrolling_reasons) | 95 ScrollStatus(ScrollThread thread, uint32_t main_thread_scrolling_reasons) |
96 : thread(thread), | 96 : thread(thread), |
97 main_thread_scrolling_reasons(main_thread_scrolling_reasons) {} | 97 main_thread_scrolling_reasons(main_thread_scrolling_reasons) {} |
98 ScrollThread thread; | 98 ScrollThread thread; |
99 uint32_t main_thread_scrolling_reasons; | 99 uint32_t main_thread_scrolling_reasons; |
100 }; | 100 }; |
101 | 101 |
102 enum ScrollInputType { GESTURE, WHEEL, ANIMATED_WHEEL, NON_BUBBLING_GESTURE }; | 102 enum ScrollInputType { |
| 103 // TODO(dtapuska): crbug.com/593017; Remove GESTURE and just use |
| 104 // TOUCHSCREEN. |
| 105 GESTURE, |
| 106 TOUCHSCREEN = GESTURE, |
| 107 WHEEL, |
| 108 ANIMATED_WHEEL, |
| 109 NON_BUBBLING_GESTURE |
| 110 }; |
103 | 111 |
104 // Binds a client to this handler to receive notifications. Only one client | 112 // Binds a client to this handler to receive notifications. Only one client |
105 // can be bound to an InputHandler. The client must live at least until the | 113 // can be bound to an InputHandler. The client must live at least until the |
106 // handler calls WillShutdown() on the client. | 114 // handler calls WillShutdown() on the client. |
107 virtual void BindToClient(InputHandlerClient* client) = 0; | 115 virtual void BindToClient(InputHandlerClient* client) = 0; |
108 | 116 |
109 // Selects a layer to be scrolled using the |scroll_state| start position. | 117 // Selects a layer to be scrolled using the |scroll_state| start position. |
110 // Returns SCROLL_STARTED if the layer at the coordinates can be scrolled, | 118 // Returns SCROLL_STARTED if the layer at the coordinates can be scrolled, |
111 // SCROLL_ON_MAIN_THREAD if the scroll event should instead be delegated to | 119 // SCROLL_ON_MAIN_THREAD if the scroll event should instead be delegated to |
112 // the main thread, or SCROLL_IGNORED if there is nothing to be scrolled at | 120 // the main thread, or SCROLL_IGNORED if there is nothing to be scrolled at |
113 // the given coordinates. | 121 // the given coordinates. |
114 virtual ScrollStatus ScrollBegin(ScrollState* scroll_state, | 122 virtual ScrollStatus ScrollBegin(ScrollState* scroll_state, |
115 ScrollInputType type) = 0; | 123 ScrollInputType type) = 0; |
116 | 124 |
117 // Similar to ScrollBegin, except the hit test is skipped and scroll always | 125 // Similar to ScrollBegin, except the hit test is skipped and scroll always |
118 // targets at the root layer. | 126 // targets at the root layer. |
119 virtual ScrollStatus RootScrollBegin(ScrollState* scroll_state, | 127 virtual ScrollStatus RootScrollBegin(ScrollState* scroll_state, |
120 ScrollInputType type) = 0; | 128 ScrollInputType type) = 0; |
| 129 |
| 130 // Returns SCROLL_ON_IMPL_THREAD if a layer is actively being scrolled or |
| 131 // a subsequent call to ScrollAnimated can begin on the impl thread. |
| 132 virtual ScrollStatus ScrollAnimatedBegin( |
| 133 const gfx::Point& viewport_point) = 0; |
| 134 |
121 virtual ScrollStatus ScrollAnimated(const gfx::Point& viewport_point, | 135 virtual ScrollStatus ScrollAnimated(const gfx::Point& viewport_point, |
122 const gfx::Vector2dF& scroll_delta) = 0; | 136 const gfx::Vector2dF& scroll_delta) = 0; |
123 | 137 |
124 // Scroll the layer selected by |ScrollBegin| by given |scroll_state| delta. | 138 // Scroll the layer selected by |ScrollBegin| by given |scroll_state| delta. |
125 // Internally, the delta is transformed to local layer's coordinate space for | 139 // Internally, the delta is transformed to local layer's coordinate space for |
126 // scrolls gestures that are direct manipulation (e.g. touch). If there is no | 140 // scrolls gestures that are direct manipulation (e.g. touch). If there is no |
127 // room to move the layer in the requested direction, its first ancestor layer | 141 // room to move the layer in the requested direction, its first ancestor layer |
128 // that can be scrolled will be moved instead. The return value's |did_scroll| | 142 // that can be scrolled will be moved instead. The return value's |did_scroll| |
129 // field is set to false if no layer can be moved in the requested direction | 143 // field is set to false if no layer can be moved in the requested direction |
130 // at all, and set to true if any layer is moved. If the scroll delta hits the | 144 // at all, and set to true if any layer is moved. If the scroll delta hits the |
131 // root layer, and the layer can no longer move, the root overscroll | 145 // root layer, and the layer can no longer move, the root overscroll |
132 // accumulated within this ScrollBegin() scope is reported in the return | 146 // accumulated within this ScrollBegin() scope is reported in the return |
133 // value's |accumulated_overscroll| field. Should only be called if | 147 // value's |accumulated_overscroll| field. Should only be called if |
134 // ScrollBegin() returned SCROLL_STARTED. | 148 // ScrollBegin() returned SCROLL_STARTED. |
135 virtual InputHandlerScrollResult ScrollBy(ScrollState* scroll_state) = 0; | 149 virtual InputHandlerScrollResult ScrollBy(ScrollState* scroll_state) = 0; |
136 | 150 |
137 virtual bool ScrollVerticallyByPage(const gfx::Point& viewport_point, | 151 virtual bool ScrollVerticallyByPage(const gfx::Point& viewport_point, |
138 ScrollDirection direction) = 0; | 152 ScrollDirection direction) = 0; |
139 | 153 |
140 // Returns SCROLL_STARTED if a layer was being actively being scrolled, | 154 // Returns SCROLL_STARTED if a layer was actively being scrolled, |
141 // SCROLL_IGNORED if not. | 155 // SCROLL_IGNORED if not. |
142 virtual ScrollStatus FlingScrollBegin() = 0; | 156 virtual ScrollStatus FlingScrollBegin() = 0; |
143 | 157 |
144 virtual void MouseMoveAt(const gfx::Point& mouse_position) = 0; | 158 virtual void MouseMoveAt(const gfx::Point& mouse_position) = 0; |
145 | 159 |
146 // Stop scrolling the selected layer. Should only be called if ScrollBegin() | 160 // Stop scrolling the selected layer. Should only be called if ScrollBegin() |
147 // returned SCROLL_STARTED. | 161 // returned SCROLL_STARTED. |
148 virtual void ScrollEnd(ScrollState* scroll_state) = 0; | 162 virtual void ScrollEnd(ScrollState* scroll_state) = 0; |
149 | 163 |
150 // Requests a callback to UpdateRootLayerStateForSynchronousInputHandler() | 164 // Requests a callback to UpdateRootLayerStateForSynchronousInputHandler() |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 InputHandler() {} | 206 InputHandler() {} |
193 virtual ~InputHandler() {} | 207 virtual ~InputHandler() {} |
194 | 208 |
195 private: | 209 private: |
196 DISALLOW_COPY_AND_ASSIGN(InputHandler); | 210 DISALLOW_COPY_AND_ASSIGN(InputHandler); |
197 }; | 211 }; |
198 | 212 |
199 } // namespace cc | 213 } // namespace cc |
200 | 214 |
201 #endif // CC_INPUT_INPUT_HANDLER_H_ | 215 #endif // CC_INPUT_INPUT_HANDLER_H_ |
OLD | NEW |