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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 last_touch_start_forced_nonblocking_due_to_fling_(false), | 71 last_touch_start_forced_nonblocking_due_to_fling_(false), |
72 enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled( | 72 enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled( |
73 features::kPassiveEventListenersDueToFling)), | 73 features::kPassiveEventListenersDueToFling)), |
| 74 enable_non_blocking_due_to_main_thread_responsiveness_flag_( |
| 75 base::FeatureList::IsEnabled( |
| 76 features::kMainThreadBusyScrollIntervention)), |
74 handle_raf_aligned_touch_input_( | 77 handle_raf_aligned_touch_input_( |
75 base::FeatureList::IsEnabled(features::kRafAlignedTouchInputEvents)), | 78 base::FeatureList::IsEnabled(features::kRafAlignedTouchInputEvents)), |
76 handle_raf_aligned_mouse_input_( | 79 handle_raf_aligned_mouse_input_( |
77 base::FeatureList::IsEnabled(features::kRafAlignedMouseInputEvents)), | 80 base::FeatureList::IsEnabled(features::kRafAlignedMouseInputEvents)), |
78 main_task_runner_(main_task_runner), | 81 main_task_runner_(main_task_runner), |
79 renderer_scheduler_(renderer_scheduler) {} | 82 renderer_scheduler_(renderer_scheduler) {} |
80 | 83 |
81 MainThreadEventQueue::~MainThreadEventQueue() {} | 84 MainThreadEventQueue::~MainThreadEventQueue() {} |
82 | 85 |
83 bool MainThreadEventQueue::HandleEvent( | 86 bool MainThreadEventQueue::HandleEvent( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // If the touch start is forced to be passive due to fling, its following | 118 // If the touch start is forced to be passive due to fling, its following |
116 // touch move should also be passive. | 119 // touch move should also be passive. |
117 if (ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING_DUE_TO_FLING || | 120 if (ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING_DUE_TO_FLING || |
118 last_touch_start_forced_nonblocking_due_to_fling_) { | 121 last_touch_start_forced_nonblocking_due_to_fling_) { |
119 touch_event->dispatchType = | 122 touch_event->dispatchType = |
120 blink::WebInputEvent::ListenersForcedNonBlockingDueToFling; | 123 blink::WebInputEvent::ListenersForcedNonBlockingDueToFling; |
121 non_blocking = true; | 124 non_blocking = true; |
122 last_touch_start_forced_nonblocking_due_to_fling_ = true; | 125 last_touch_start_forced_nonblocking_due_to_fling_ = true; |
123 } | 126 } |
124 } | 127 } |
| 128 |
| 129 if (enable_non_blocking_due_to_main_thread_responsiveness_flag_ && |
| 130 touch_event->dispatchType == blink::WebInputEvent::Blocking) { |
| 131 bool passive_due_to_unresponsive_main = |
| 132 renderer_scheduler_->MainThreadSeemsUnresponsive(); |
| 133 if (passive_due_to_unresponsive_main) { |
| 134 touch_event->dispatchType = blink::WebInputEvent:: |
| 135 ListenersForcedNonBlockingDueToMainThreadResponsiveness; |
| 136 non_blocking = true; |
| 137 } |
| 138 } |
125 } | 139 } |
126 if (is_wheel && non_blocking) { | 140 if (is_wheel && non_blocking) { |
127 // Adjust the |dispatchType| on the event since the compositor | 141 // Adjust the |dispatchType| on the event since the compositor |
128 // determined all event listeners are passive. | 142 // determined all event listeners are passive. |
129 static_cast<blink::WebMouseWheelEvent*>(event.get()) | 143 static_cast<blink::WebMouseWheelEvent*>(event.get()) |
130 ->dispatchType = blink::WebInputEvent::ListenersNonBlockingPassive; | 144 ->dispatchType = blink::WebInputEvent::ListenersNonBlockingPassive; |
131 } | 145 } |
132 | 146 |
133 InputEventDispatchType dispatch_type = | 147 InputEventDispatchType dispatch_type = |
134 non_blocking ? DISPATCH_TYPE_NON_BLOCKING : DISPATCH_TYPE_BLOCKING; | 148 non_blocking ? DISPATCH_TYPE_NON_BLOCKING : DISPATCH_TYPE_BLOCKING; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 // additional frame. | 318 // additional frame. |
305 return static_cast<const blink::WebTouchEvent&>(event->event()) | 319 return static_cast<const blink::WebTouchEvent&>(event->event()) |
306 .dispatchType != blink::WebInputEvent::Blocking && | 320 .dispatchType != blink::WebInputEvent::Blocking && |
307 handle_raf_aligned_touch_input_; | 321 handle_raf_aligned_touch_input_; |
308 default: | 322 default: |
309 return false; | 323 return false; |
310 } | 324 } |
311 } | 325 } |
312 | 326 |
313 } // namespace content | 327 } // namespace content |
OLD | NEW |