| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "content/renderer/input/main_thread_event_queue.h" | 5 #include "content/renderer/input/main_thread_event_queue.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "content/common/input/event_with_latency_info.h" | 8 #include "content/common/input/event_with_latency_info.h" |
| 9 #include "content/common/input_messages.h" | 9 #include "content/common/input_messages.h" |
| 10 | 10 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 MainThreadEventQueue::SharedState::~SharedState() {} | 62 MainThreadEventQueue::SharedState::~SharedState() {} |
| 63 | 63 |
| 64 MainThreadEventQueue::MainThreadEventQueue( | 64 MainThreadEventQueue::MainThreadEventQueue( |
| 65 int routing_id, | 65 int routing_id, |
| 66 MainThreadEventQueueClient* client, | 66 MainThreadEventQueueClient* client, |
| 67 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, | 67 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, |
| 68 blink::scheduler::RendererScheduler* renderer_scheduler) | 68 blink::scheduler::RendererScheduler* renderer_scheduler) |
| 69 : routing_id_(routing_id), | 69 : routing_id_(routing_id), |
| 70 client_(client), | 70 client_(client), |
| 71 is_flinging_(false), | |
| 72 last_touch_start_forced_nonblocking_due_to_fling_(false), | 71 last_touch_start_forced_nonblocking_due_to_fling_(false), |
| 73 enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled( | 72 enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled( |
| 74 features::kPassiveEventListenersDueToFling)), | 73 features::kPassiveEventListenersDueToFling)), |
| 75 handle_raf_aligned_touch_input_( | 74 handle_raf_aligned_touch_input_( |
| 76 base::FeatureList::IsEnabled(features::kRafAlignedTouchInputEvents)), | 75 base::FeatureList::IsEnabled(features::kRafAlignedTouchInputEvents)), |
| 77 handle_raf_aligned_mouse_input_( | 76 handle_raf_aligned_mouse_input_( |
| 78 base::FeatureList::IsEnabled(features::kRafAlignedMouseInputEvents)), | 77 base::FeatureList::IsEnabled(features::kRafAlignedMouseInputEvents)), |
| 79 main_task_runner_(main_task_runner), | 78 main_task_runner_(main_task_runner), |
| 80 renderer_scheduler_(renderer_scheduler) {} | 79 renderer_scheduler_(renderer_scheduler) {} |
| 81 | 80 |
| 82 MainThreadEventQueue::~MainThreadEventQueue() {} | 81 MainThreadEventQueue::~MainThreadEventQueue() {} |
| 83 | 82 |
| 84 bool MainThreadEventQueue::HandleEvent( | 83 bool MainThreadEventQueue::HandleEvent( |
| 85 ui::ScopedWebInputEvent event, | 84 ui::ScopedWebInputEvent event, |
| 86 const ui::LatencyInfo& latency, | 85 const ui::LatencyInfo& latency, |
| 87 InputEventDispatchType original_dispatch_type, | 86 InputEventDispatchType original_dispatch_type, |
| 88 InputEventAckState ack_result) { | 87 InputEventAckState ack_result) { |
| 89 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING || | 88 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING || |
| 90 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING); | 89 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING); |
| 91 DCHECK(ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING || | 90 DCHECK(ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING || |
| 92 ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 91 ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED || |
| 92 INPUT_EVENT_ACK_STATE_NOT_CONSUMED_NON_BLOCKING); |
| 93 | 93 |
| 94 bool non_blocking = original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING || | 94 bool non_blocking = original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING || |
| 95 ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING; | 95 ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING; |
| 96 bool is_wheel = event->type == blink::WebInputEvent::MouseWheel; | 96 bool is_wheel = event->type == blink::WebInputEvent::MouseWheel; |
| 97 bool is_touch = blink::WebInputEvent::isTouchEventType(event->type); | 97 bool is_touch = blink::WebInputEvent::isTouchEventType(event->type); |
| 98 | 98 |
| 99 if (is_touch) { | 99 if (is_touch) { |
| 100 blink::WebTouchEvent* touch_event = | 100 blink::WebTouchEvent* touch_event = |
| 101 static_cast<blink::WebTouchEvent*>(event.get()); | 101 static_cast<blink::WebTouchEvent*>(event.get()); |
| 102 touch_event->dispatchedDuringFling = is_flinging_; | 102 |
| 103 // Adjust the |dispatchType| on the event since the compositor | 103 // Adjust the |dispatchType| on the event since the compositor |
| 104 // determined all event listeners are passive. | 104 // determined all event listeners are passive. |
| 105 if (non_blocking) { | 105 if (non_blocking) { |
| 106 touch_event->dispatchType = | 106 touch_event->dispatchType = |
| 107 blink::WebInputEvent::ListenersNonBlockingPassive; | 107 blink::WebInputEvent::ListenersNonBlockingPassive; |
| 108 } | 108 } |
| 109 if (touch_event->type == blink::WebInputEvent::TouchStart) | 109 if (touch_event->type == blink::WebInputEvent::TouchStart) |
| 110 last_touch_start_forced_nonblocking_due_to_fling_ = false; | 110 last_touch_start_forced_nonblocking_due_to_fling_ = false; |
| 111 | 111 |
| 112 if (enable_fling_passive_listener_flag_ && | 112 if (enable_fling_passive_listener_flag_ && |
| 113 touch_event->touchStartOrFirstTouchMove && | 113 touch_event->touchStartOrFirstTouchMove && |
| 114 touch_event->dispatchType == blink::WebInputEvent::Blocking) { | 114 touch_event->dispatchType == blink::WebInputEvent::Blocking) { |
| 115 // If the touch start is forced to be passive due to fling, its following | 115 // If the touch start is forced to be passive due to fling, its following |
| 116 // touch move should also be passive. | 116 // touch move should also be passive. |
| 117 if (is_flinging_ || last_touch_start_forced_nonblocking_due_to_fling_) { | 117 if (ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED_NON_BLOCKING || |
| 118 last_touch_start_forced_nonblocking_due_to_fling_) { |
| 118 touch_event->dispatchType = | 119 touch_event->dispatchType = |
| 119 blink::WebInputEvent::ListenersForcedNonBlockingDueToFling; | 120 blink::WebInputEvent::ListenersForcedNonBlockingDueToFling; |
| 120 non_blocking = true; | 121 non_blocking = true; |
| 121 last_touch_start_forced_nonblocking_due_to_fling_ = true; | 122 last_touch_start_forced_nonblocking_due_to_fling_ = true; |
| 122 } | 123 } |
| 123 } | 124 } |
| 124 } | 125 } |
| 125 if (is_wheel && non_blocking) { | 126 if (is_wheel && non_blocking) { |
| 126 // Adjust the |dispatchType| on the event since the compositor | 127 // Adjust the |dispatchType| on the event since the compositor |
| 127 // determined all event listeners are passive. | 128 // determined all event listeners are passive. |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 // additional frame. | 304 // additional frame. |
| 304 return static_cast<const blink::WebTouchEvent&>(event->event()) | 305 return static_cast<const blink::WebTouchEvent&>(event->event()) |
| 305 .dispatchType != blink::WebInputEvent::Blocking && | 306 .dispatchType != blink::WebInputEvent::Blocking && |
| 306 handle_raf_aligned_touch_input_; | 307 handle_raf_aligned_touch_input_; |
| 307 default: | 308 default: |
| 308 return false; | 309 return false; |
| 309 } | 310 } |
| 310 } | 311 } |
| 311 | 312 |
| 312 } // namespace content | 313 } // namespace content |
| OLD | NEW |