Chromium Code Reviews| 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 |
| 21 namespace ui { | 22 namespace ui { |
| 22 | 23 |
| 23 namespace test { | 24 namespace test { |
| 24 class InputHandlerProxyTest; | 25 class InputHandlerProxyTest; |
| 26 class InputHandlerProxyEventQueueTest; | |
| 25 } | 27 } |
| 26 | 28 |
| 29 class CompositorThreadEventQueue; | |
| 30 class EventWithCallback; | |
| 27 class InputHandlerProxyClient; | 31 class InputHandlerProxyClient; |
| 28 class InputScrollElasticityController; | 32 class InputScrollElasticityController; |
| 29 class SynchronousInputHandler; | 33 class SynchronousInputHandler; |
| 30 class SynchronousInputHandlerProxy; | 34 class SynchronousInputHandlerProxy; |
| 31 struct DidOverscrollParams; | 35 struct DidOverscrollParams; |
| 32 | 36 |
| 33 // This class is a proxy between the blink web input events for a WebWidget and | 37 // 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 | 38 // the compositor's input handling logic. InputHandlerProxy instances live |
| 35 // entirely on the compositor thread. Each InputHandler instance handles input | 39 // entirely on the compositor thread. Each InputHandler instance handles input |
| 36 // events intended for a specific WebWidget. | 40 // 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; | 77 void Animate(base::TimeTicks time) override; |
| 74 void MainThreadHasStoppedFlinging() override; | 78 void MainThreadHasStoppedFlinging() override; |
| 75 void ReconcileElasticOverscrollAndRootScroll() override; | 79 void ReconcileElasticOverscrollAndRootScroll() override; |
| 76 void UpdateRootLayerStateForSynchronousInputHandler( | 80 void UpdateRootLayerStateForSynchronousInputHandler( |
| 77 const gfx::ScrollOffset& total_scroll_offset, | 81 const gfx::ScrollOffset& total_scroll_offset, |
| 78 const gfx::ScrollOffset& max_scroll_offset, | 82 const gfx::ScrollOffset& max_scroll_offset, |
| 79 const gfx::SizeF& scrollable_size, | 83 const gfx::SizeF& scrollable_size, |
| 80 float page_scale_factor, | 84 float page_scale_factor, |
| 81 float min_page_scale_factor, | 85 float min_page_scale_factor, |
| 82 float max_page_scale_factor) override; | 86 float max_page_scale_factor) override; |
| 87 void DeliverInputForBeginFrame() override; | |
| 83 | 88 |
| 84 // SynchronousInputHandlerProxy implementation. | 89 // SynchronousInputHandlerProxy implementation. |
| 85 void SetOnlySynchronouslyAnimateRootFlings( | 90 void SetOnlySynchronouslyAnimateRootFlings( |
| 86 SynchronousInputHandler* synchronous_input_handler) override; | 91 SynchronousInputHandler* synchronous_input_handler) override; |
| 87 void SynchronouslyAnimate(base::TimeTicks time) override; | 92 void SynchronouslyAnimate(base::TimeTicks time) override; |
| 88 void SynchronouslySetRootScrollOffset( | 93 void SynchronouslySetRootScrollOffset( |
| 89 const gfx::ScrollOffset& root_offset) override; | 94 const gfx::ScrollOffset& root_offset) override; |
| 90 void SynchronouslyZoomBy(float magnify_delta, | 95 void SynchronouslyZoomBy(float magnify_delta, |
| 91 const gfx::Point& anchor) override; | 96 const gfx::Point& anchor) override; |
| 92 | 97 |
| 93 // blink::WebGestureCurveTarget implementation. | 98 // blink::WebGestureCurveTarget implementation. |
| 94 bool scrollBy(const blink::WebFloatSize& offset, | 99 bool scrollBy(const blink::WebFloatSize& offset, |
| 95 const blink::WebFloatSize& velocity) override; | 100 const blink::WebFloatSize& velocity) override; |
| 96 | 101 |
| 97 bool gesture_scroll_on_impl_thread_for_testing() const { | 102 bool gesture_scroll_on_impl_thread_for_testing() const { |
| 98 return gesture_scroll_on_impl_thread_; | 103 return gesture_scroll_on_impl_thread_; |
| 99 } | 104 } |
| 100 | 105 |
| 101 protected: | 106 protected: |
| 102 void RecordMainThreadScrollingReasons(blink::WebGestureDevice device, | 107 void RecordMainThreadScrollingReasons(blink::WebGestureDevice device, |
| 103 uint32_t reasons); | 108 uint32_t reasons); |
| 104 | 109 |
| 105 private: | 110 private: |
| 106 friend class test::InputHandlerProxyTest; | 111 friend class test::InputHandlerProxyTest; |
| 112 friend class test::InputHandlerProxyEventQueueTest; | |
| 113 | |
| 114 void DispatchSingleInputEvent(std::unique_ptr<EventWithCallback>); | |
| 115 void DispatchQueuedInputEvents(); | |
| 107 | 116 |
| 108 // Helper functions for handling more complicated input events. | 117 // Helper functions for handling more complicated input events. |
| 109 EventDisposition HandleMouseWheel( | 118 EventDisposition HandleMouseWheel( |
| 110 const blink::WebMouseWheelEvent& event); | 119 const blink::WebMouseWheelEvent& event); |
| 111 EventDisposition ScrollByMouseWheel( | 120 EventDisposition ScrollByMouseWheel( |
| 112 const blink::WebMouseWheelEvent& event, | 121 const blink::WebMouseWheelEvent& event, |
| 113 cc::EventListenerProperties listener_properties); | 122 cc::EventListenerProperties listener_properties); |
| 114 EventDisposition HandleGestureScrollBegin( | 123 EventDisposition HandleGestureScrollBegin( |
| 115 const blink::WebGestureEvent& event); | 124 const blink::WebGestureEvent& event); |
| 116 EventDisposition HandleGestureScrollUpdate( | 125 EventDisposition HandleGestureScrollUpdate( |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 int32_t touch_start_result_; | 230 int32_t touch_start_result_; |
| 222 | 231 |
| 223 base::TimeTicks last_fling_animate_time_; | 232 base::TimeTicks last_fling_animate_time_; |
| 224 | 233 |
| 225 // Used to record overscroll notifications while an event is being | 234 // Used to record overscroll notifications while an event is being |
| 226 // dispatched. If the event causes overscroll, the overscroll metadata can be | 235 // 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 | 236 // bundled in the event ack, saving an IPC. Note that we must continue |
| 228 // supporting overscroll IPC notifications due to fling animation updates. | 237 // supporting overscroll IPC notifications due to fling animation updates. |
| 229 std::unique_ptr<DidOverscrollParams> current_overscroll_params_; | 238 std::unique_ptr<DidOverscrollParams> current_overscroll_params_; |
| 230 | 239 |
| 240 std::unique_ptr<CompositorThreadEventQueue> event_queue_; | |
| 241 bool has_ongoing_compositor_scroll_pinch_; | |
| 242 bool compositor_event_queue_enabled_; | |
|
dtapuska
2016/11/09 21:28:05
Can we use the existence of the event_queue_ as kn
chongz
2016/11/11 21:52:05
Done.
| |
| 243 | |
| 244 // Testing only | |
| 245 static std::unique_ptr<base::TimeTicks> testing_timestamp_now_; | |
| 246 | |
| 231 DISALLOW_COPY_AND_ASSIGN(InputHandlerProxy); | 247 DISALLOW_COPY_AND_ASSIGN(InputHandlerProxy); |
| 232 }; | 248 }; |
| 233 | 249 |
| 234 } // namespace ui | 250 } // namespace ui |
| 235 | 251 |
| 236 #endif // UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_H_ | 252 #endif // UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_H_ |
| OLD | NEW |