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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 MainThreadEventQueue::MainThreadEventQueue( | 63 MainThreadEventQueue::MainThreadEventQueue( |
64 int routing_id, | 64 int routing_id, |
65 MainThreadEventQueueClient* client, | 65 MainThreadEventQueueClient* client, |
66 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, | 66 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, |
67 blink::scheduler::RendererScheduler* renderer_scheduler) | 67 blink::scheduler::RendererScheduler* renderer_scheduler) |
68 : routing_id_(routing_id), | 68 : routing_id_(routing_id), |
69 client_(client), | 69 client_(client), |
70 last_touch_start_forced_nonblocking_due_to_fling_(false), | 70 last_touch_start_forced_nonblocking_due_to_fling_(false), |
71 enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled( | 71 enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled( |
72 features::kPassiveEventListenersDueToFling)), | 72 features::kPassiveEventListenersDueToFling)), |
| 73 enable_non_blocking_due_to_main_thread_responsiveness_flag_( |
| 74 base::FeatureList::IsEnabled( |
| 75 features::kMainThreadBusyScrollIntervention)), |
73 handle_raf_aligned_touch_input_( | 76 handle_raf_aligned_touch_input_( |
74 base::FeatureList::IsEnabled(features::kRafAlignedTouchInputEvents)), | 77 base::FeatureList::IsEnabled(features::kRafAlignedTouchInputEvents)), |
75 handle_raf_aligned_mouse_input_( | 78 handle_raf_aligned_mouse_input_( |
76 base::FeatureList::IsEnabled(features::kRafAlignedMouseInputEvents)), | 79 base::FeatureList::IsEnabled(features::kRafAlignedMouseInputEvents)), |
77 main_task_runner_(main_task_runner), | 80 main_task_runner_(main_task_runner), |
78 renderer_scheduler_(renderer_scheduler) {} | 81 renderer_scheduler_(renderer_scheduler) {} |
79 | 82 |
80 MainThreadEventQueue::~MainThreadEventQueue() {} | 83 MainThreadEventQueue::~MainThreadEventQueue() {} |
81 | 84 |
82 bool MainThreadEventQueue::HandleEvent( | 85 bool MainThreadEventQueue::HandleEvent( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // If the touch start is forced to be passive due to fling, its following | 117 // If the touch start is forced to be passive due to fling, its following |
115 // touch move should also be passive. | 118 // touch move should also be passive. |
116 if (ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING_DUE_TO_FLING || | 119 if (ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING_DUE_TO_FLING || |
117 last_touch_start_forced_nonblocking_due_to_fling_) { | 120 last_touch_start_forced_nonblocking_due_to_fling_) { |
118 touch_event->dispatchType = | 121 touch_event->dispatchType = |
119 blink::WebInputEvent::ListenersForcedNonBlockingDueToFling; | 122 blink::WebInputEvent::ListenersForcedNonBlockingDueToFling; |
120 non_blocking = true; | 123 non_blocking = true; |
121 last_touch_start_forced_nonblocking_due_to_fling_ = true; | 124 last_touch_start_forced_nonblocking_due_to_fling_ = true; |
122 } | 125 } |
123 } | 126 } |
| 127 |
124 // If handling rAF aligned touch input ACK non-cancelable events right | 128 // If handling rAF aligned touch input ACK non-cancelable events right |
125 // away. | 129 // away. |
126 if (!non_blocking && IsRafAlignedEvent(*touch_event)) | 130 if (!non_blocking && IsRafAlignedEvent(*touch_event)) |
127 non_blocking = true; | 131 non_blocking = true; |
| 132 |
| 133 if (enable_non_blocking_due_to_main_thread_responsiveness_flag_ && |
| 134 touch_event->dispatchType == blink::WebInputEvent::Blocking) { |
| 135 bool passive_due_to_unresponsive_main = |
| 136 renderer_scheduler_->MainThreadSeemsUnresponsive(); |
| 137 if (passive_due_to_unresponsive_main) { |
| 138 touch_event->dispatchType = blink::WebInputEvent:: |
| 139 ListenersForcedNonBlockingDueToMainThreadResponsiveness; |
| 140 non_blocking = true; |
| 141 } |
| 142 } |
128 } | 143 } |
129 if (is_wheel && non_blocking) { | 144 if (is_wheel && non_blocking) { |
130 // Adjust the |dispatchType| on the event since the compositor | 145 // Adjust the |dispatchType| on the event since the compositor |
131 // determined all event listeners are passive. | 146 // determined all event listeners are passive. |
132 static_cast<blink::WebMouseWheelEvent*>(event.get()) | 147 static_cast<blink::WebMouseWheelEvent*>(event.get()) |
133 ->dispatchType = blink::WebInputEvent::ListenersNonBlockingPassive; | 148 ->dispatchType = blink::WebInputEvent::ListenersNonBlockingPassive; |
134 } | 149 } |
135 | 150 |
136 InputEventDispatchType dispatch_type = | 151 InputEventDispatchType dispatch_type = |
137 non_blocking ? DISPATCH_TYPE_NON_BLOCKING : DISPATCH_TYPE_BLOCKING; | 152 non_blocking ? DISPATCH_TYPE_NON_BLOCKING : DISPATCH_TYPE_BLOCKING; |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 // additional frame. | 345 // additional frame. |
331 return static_cast<const blink::WebTouchEvent&>(event).dispatchType != | 346 return static_cast<const blink::WebTouchEvent&>(event).dispatchType != |
332 blink::WebInputEvent::Blocking && | 347 blink::WebInputEvent::Blocking && |
333 handle_raf_aligned_touch_input_; | 348 handle_raf_aligned_touch_input_; |
334 default: | 349 default: |
335 return false; | 350 return false; |
336 } | 351 } |
337 } | 352 } |
338 | 353 |
339 } // namespace content | 354 } // namespace content |
OLD | NEW |