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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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), | 71 is_flinging_(false), |
72 last_touch_start_forced_nonblocking_due_to_fling_(false), | 72 last_touch_start_forced_nonblocking_due_to_fling_(false), |
73 enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled( | 73 enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled( |
74 features::kPassiveEventListenersDueToFling)), | 74 features::kPassiveEventListenersDueToFling)), |
| 75 enable_non_blocking_due_to_main_thread_responsiveness_flag_( |
| 76 base::FeatureList::IsEnabled( |
| 77 features::kMainThreadBusyScrollIntervention)), |
75 handle_raf_aligned_touch_input_( | 78 handle_raf_aligned_touch_input_( |
76 base::FeatureList::IsEnabled(features::kRafAlignedTouchInputEvents)), | 79 base::FeatureList::IsEnabled(features::kRafAlignedTouchInputEvents)), |
77 handle_raf_aligned_mouse_input_( | 80 handle_raf_aligned_mouse_input_( |
78 base::FeatureList::IsEnabled(features::kRafAlignedMouseInputEvents)), | 81 base::FeatureList::IsEnabled(features::kRafAlignedMouseInputEvents)), |
79 main_task_runner_(main_task_runner), | 82 main_task_runner_(main_task_runner), |
80 renderer_scheduler_(renderer_scheduler) {} | 83 renderer_scheduler_(renderer_scheduler) {} |
81 | 84 |
82 MainThreadEventQueue::~MainThreadEventQueue() {} | 85 MainThreadEventQueue::~MainThreadEventQueue() {} |
83 | 86 |
84 bool MainThreadEventQueue::HandleEvent( | 87 bool MainThreadEventQueue::HandleEvent( |
(...skipping 29 matching lines...) Expand all Loading... |
114 touch_event->dispatchType == blink::WebInputEvent::Blocking) { | 117 touch_event->dispatchType == blink::WebInputEvent::Blocking) { |
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 (is_flinging_ || last_touch_start_forced_nonblocking_due_to_fling_) { | 120 if (is_flinging_ || 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 |
| 128 if (enable_non_blocking_due_to_main_thread_responsiveness_flag_ && |
| 129 touch_event->dispatchType == blink::WebInputEvent::Blocking) { |
| 130 bool passive_due_to_unresponsive_main = |
| 131 renderer_scheduler_ |
| 132 ->ShouldForceEventsNonBlockingForUnresponsiveMainThread(); |
| 133 if (passive_due_to_unresponsive_main) { |
| 134 touch_event->dispatchType = blink::WebInputEvent:: |
| 135 ListenersForcedNonBlockingDueToMainThreadResponsiveness; |
| 136 non_blocking = true; |
| 137 } |
| 138 } |
124 } | 139 } |
125 if (is_wheel && non_blocking) { | 140 if (is_wheel && non_blocking) { |
126 // Adjust the |dispatchType| on the event since the compositor | 141 // Adjust the |dispatchType| on the event since the compositor |
127 // determined all event listeners are passive. | 142 // determined all event listeners are passive. |
128 static_cast<blink::WebMouseWheelEvent*>(event.get()) | 143 static_cast<blink::WebMouseWheelEvent*>(event.get()) |
129 ->dispatchType = blink::WebInputEvent::ListenersNonBlockingPassive; | 144 ->dispatchType = blink::WebInputEvent::ListenersNonBlockingPassive; |
130 } | 145 } |
131 | 146 |
132 InputEventDispatchType dispatch_type = | 147 InputEventDispatchType dispatch_type = |
133 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... |
303 // additional frame. | 318 // additional frame. |
304 return static_cast<const blink::WebTouchEvent&>(event->event()) | 319 return static_cast<const blink::WebTouchEvent&>(event->event()) |
305 .dispatchType != blink::WebInputEvent::Blocking && | 320 .dispatchType != blink::WebInputEvent::Blocking && |
306 handle_raf_aligned_touch_input_; | 321 handle_raf_aligned_touch_input_; |
307 default: | 322 default: |
308 return false; | 323 return false; |
309 } | 324 } |
310 } | 325 } |
311 | 326 |
312 } // namespace content | 327 } // namespace content |
OLD | NEW |