| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_H_ | 5 #ifndef UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_H_ |
| 6 #define UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_H_ | 6 #define UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "cc/input/input_handler.h" | 12 #include "cc/input/input_handler.h" |
| 13 #include "third_party/WebKit/public/platform/WebGestureCurve.h" | 13 #include "third_party/WebKit/public/platform/WebGestureCurve.h" |
| 14 #include "third_party/WebKit/public/platform/WebGestureCurveTarget.h" | 14 #include "third_party/WebKit/public/platform/WebGestureCurveTarget.h" |
| 15 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 15 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 16 #include "third_party/WebKit/public/web/WebActiveWheelFlingParameters.h" | 16 #include "third_party/WebKit/public/web/WebActiveWheelFlingParameters.h" |
| 17 #include "ui/events/blink/blink_features.h" |
| 17 #include "ui/events/blink/input_scroll_elasticity_controller.h" | 18 #include "ui/events/blink/input_scroll_elasticity_controller.h" |
| 18 #include "ui/events/blink/scoped_web_input_event.h" | 19 #include "ui/events/blink/scoped_web_input_event.h" |
| 19 #include "ui/events/blink/synchronous_input_handler_proxy.h" | 20 #include "ui/events/blink/synchronous_input_handler_proxy.h" |
| 20 | 21 |
| 22 namespace base { |
| 23 class TickClock; |
| 24 } |
| 25 |
| 21 namespace ui { | 26 namespace ui { |
| 22 | 27 |
| 23 namespace test { | 28 namespace test { |
| 24 class InputHandlerProxyTest; | 29 class InputHandlerProxyTest; |
| 30 class InputHandlerProxyEventQueueTest; |
| 25 } | 31 } |
| 26 | 32 |
| 33 class CompositorThreadEventQueue; |
| 34 class EventWithCallback; |
| 27 class InputHandlerProxyClient; | 35 class InputHandlerProxyClient; |
| 28 class InputScrollElasticityController; | 36 class InputScrollElasticityController; |
| 29 class SynchronousInputHandler; | 37 class SynchronousInputHandler; |
| 30 class SynchronousInputHandlerProxy; | 38 class SynchronousInputHandlerProxy; |
| 31 struct DidOverscrollParams; | 39 struct DidOverscrollParams; |
| 32 | 40 |
| 33 // This class is a proxy between the blink web input events for a WebWidget and | 41 // This class is a proxy between the blink web input events for a WebWidget and |
| 34 // the compositor's input handling logic. InputHandlerProxy instances live | 42 // the compositor's input handling logic. InputHandlerProxy instances live |
| 35 // entirely on the compositor thread. Each InputHandler instance handles input | 43 // entirely on the compositor thread. Each InputHandler instance handles input |
| 36 // events intended for a specific WebWidget. | 44 // events intended for a specific WebWidget. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 void Animate(base::TimeTicks time) override; | 81 void Animate(base::TimeTicks time) override; |
| 74 void MainThreadHasStoppedFlinging() override; | 82 void MainThreadHasStoppedFlinging() override; |
| 75 void ReconcileElasticOverscrollAndRootScroll() override; | 83 void ReconcileElasticOverscrollAndRootScroll() override; |
| 76 void UpdateRootLayerStateForSynchronousInputHandler( | 84 void UpdateRootLayerStateForSynchronousInputHandler( |
| 77 const gfx::ScrollOffset& total_scroll_offset, | 85 const gfx::ScrollOffset& total_scroll_offset, |
| 78 const gfx::ScrollOffset& max_scroll_offset, | 86 const gfx::ScrollOffset& max_scroll_offset, |
| 79 const gfx::SizeF& scrollable_size, | 87 const gfx::SizeF& scrollable_size, |
| 80 float page_scale_factor, | 88 float page_scale_factor, |
| 81 float min_page_scale_factor, | 89 float min_page_scale_factor, |
| 82 float max_page_scale_factor) override; | 90 float max_page_scale_factor) override; |
| 91 void DeliverInputForBeginFrame() override; |
| 83 | 92 |
| 84 // SynchronousInputHandlerProxy implementation. | 93 // SynchronousInputHandlerProxy implementation. |
| 85 void SetOnlySynchronouslyAnimateRootFlings( | 94 void SetOnlySynchronouslyAnimateRootFlings( |
| 86 SynchronousInputHandler* synchronous_input_handler) override; | 95 SynchronousInputHandler* synchronous_input_handler) override; |
| 87 void SynchronouslyAnimate(base::TimeTicks time) override; | 96 void SynchronouslyAnimate(base::TimeTicks time) override; |
| 88 void SynchronouslySetRootScrollOffset( | 97 void SynchronouslySetRootScrollOffset( |
| 89 const gfx::ScrollOffset& root_offset) override; | 98 const gfx::ScrollOffset& root_offset) override; |
| 90 void SynchronouslyZoomBy(float magnify_delta, | 99 void SynchronouslyZoomBy(float magnify_delta, |
| 91 const gfx::Point& anchor) override; | 100 const gfx::Point& anchor) override; |
| 92 | 101 |
| 93 // blink::WebGestureCurveTarget implementation. | 102 // blink::WebGestureCurveTarget implementation. |
| 94 bool scrollBy(const blink::WebFloatSize& offset, | 103 bool scrollBy(const blink::WebFloatSize& offset, |
| 95 const blink::WebFloatSize& velocity) override; | 104 const blink::WebFloatSize& velocity) override; |
| 96 | 105 |
| 97 bool gesture_scroll_on_impl_thread_for_testing() const { | 106 bool gesture_scroll_on_impl_thread_for_testing() const { |
| 98 return gesture_scroll_on_impl_thread_; | 107 return gesture_scroll_on_impl_thread_; |
| 99 } | 108 } |
| 100 | 109 |
| 101 protected: | 110 protected: |
| 102 void RecordMainThreadScrollingReasons(blink::WebGestureDevice device, | 111 void RecordMainThreadScrollingReasons(blink::WebGestureDevice device, |
| 103 uint32_t reasons); | 112 uint32_t reasons); |
| 104 | 113 |
| 105 private: | 114 private: |
| 106 friend class test::InputHandlerProxyTest; | 115 friend class test::InputHandlerProxyTest; |
| 116 friend class test::InputHandlerProxyEventQueueTest; |
| 117 |
| 118 void DispatchSingleInputEvent(std::unique_ptr<EventWithCallback>); |
| 119 void DispatchQueuedInputEvents(); |
| 107 | 120 |
| 108 // Helper functions for handling more complicated input events. | 121 // Helper functions for handling more complicated input events. |
| 109 EventDisposition HandleMouseWheel( | 122 EventDisposition HandleMouseWheel( |
| 110 const blink::WebMouseWheelEvent& event); | 123 const blink::WebMouseWheelEvent& event); |
| 111 EventDisposition ScrollByMouseWheel( | 124 EventDisposition ScrollByMouseWheel( |
| 112 const blink::WebMouseWheelEvent& event, | 125 const blink::WebMouseWheelEvent& event, |
| 113 cc::EventListenerProperties listener_properties); | 126 cc::EventListenerProperties listener_properties); |
| 114 EventDisposition HandleGestureScrollBegin( | 127 EventDisposition HandleGestureScrollBegin( |
| 115 const blink::WebGestureEvent& event); | 128 const blink::WebGestureEvent& event); |
| 116 EventDisposition HandleGestureScrollUpdate( | 129 EventDisposition HandleGestureScrollUpdate( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 bool bundle_overscroll_params_with_ack); | 168 bool bundle_overscroll_params_with_ack); |
| 156 | 169 |
| 157 // Whether to use a smooth scroll animation for this event. | 170 // Whether to use a smooth scroll animation for this event. |
| 158 bool ShouldAnimate(bool has_precise_scroll_deltas) const; | 171 bool ShouldAnimate(bool has_precise_scroll_deltas) const; |
| 159 | 172 |
| 160 // Update the elastic overscroll controller with |gesture_event|. | 173 // Update the elastic overscroll controller with |gesture_event|. |
| 161 void HandleScrollElasticityOverscroll( | 174 void HandleScrollElasticityOverscroll( |
| 162 const blink::WebGestureEvent& gesture_event, | 175 const blink::WebGestureEvent& gesture_event, |
| 163 const cc::InputHandlerScrollResult& scroll_result); | 176 const cc::InputHandlerScrollResult& scroll_result); |
| 164 | 177 |
| 178 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); |
| 179 |
| 165 std::unique_ptr<blink::WebGestureCurve> fling_curve_; | 180 std::unique_ptr<blink::WebGestureCurve> fling_curve_; |
| 166 // Parameters for the active fling animation, stored in case we need to | 181 // Parameters for the active fling animation, stored in case we need to |
| 167 // transfer it out later. | 182 // transfer it out later. |
| 168 blink::WebActiveWheelFlingParameters fling_parameters_; | 183 blink::WebActiveWheelFlingParameters fling_parameters_; |
| 169 | 184 |
| 170 InputHandlerProxyClient* client_; | 185 InputHandlerProxyClient* client_; |
| 171 cc::InputHandler* input_handler_; | 186 cc::InputHandler* input_handler_; |
| 172 | 187 |
| 173 // Time at which an active fling should expire due to a deferred cancellation | 188 // Time at which an active fling should expire due to a deferred cancellation |
| 174 // event. A call to |Animate()| after this time will end the fling. | 189 // event. A call to |Animate()| after this time will end the fling. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 int32_t touch_start_result_; | 236 int32_t touch_start_result_; |
| 222 | 237 |
| 223 base::TimeTicks last_fling_animate_time_; | 238 base::TimeTicks last_fling_animate_time_; |
| 224 | 239 |
| 225 // Used to record overscroll notifications while an event is being | 240 // Used to record overscroll notifications while an event is being |
| 226 // dispatched. If the event causes overscroll, the overscroll metadata can be | 241 // dispatched. If the event causes overscroll, the overscroll metadata can be |
| 227 // bundled in the event ack, saving an IPC. Note that we must continue | 242 // bundled in the event ack, saving an IPC. Note that we must continue |
| 228 // supporting overscroll IPC notifications due to fling animation updates. | 243 // supporting overscroll IPC notifications due to fling animation updates. |
| 229 std::unique_ptr<DidOverscrollParams> current_overscroll_params_; | 244 std::unique_ptr<DidOverscrollParams> current_overscroll_params_; |
| 230 | 245 |
| 246 std::unique_ptr<CompositorThreadEventQueue> compositor_event_queue_; |
| 247 bool has_ongoing_compositor_scroll_pinch_; |
| 248 |
| 249 std::unique_ptr<base::TickClock> tick_clock_; |
| 250 |
| 231 DISALLOW_COPY_AND_ASSIGN(InputHandlerProxy); | 251 DISALLOW_COPY_AND_ASSIGN(InputHandlerProxy); |
| 232 }; | 252 }; |
| 233 | 253 |
| 234 } // namespace ui | 254 } // namespace ui |
| 235 | 255 |
| 236 #endif // UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_H_ | 256 #endif // UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_H_ |
| OLD | NEW |