| 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 "content/common/input/event_with_latency_info.h" | 7 #include "content/common/input/event_with_latency_info.h" |
| 8 #include "content/common/input_messages.h" | 8 #include "content/common/input_messages.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 int routing_id, | 39 int routing_id, |
| 40 MainThreadEventQueueClient* client, | 40 MainThreadEventQueueClient* client, |
| 41 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, | 41 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, |
| 42 blink::scheduler::RendererScheduler* renderer_scheduler) | 42 blink::scheduler::RendererScheduler* renderer_scheduler) |
| 43 : routing_id_(routing_id), | 43 : routing_id_(routing_id), |
| 44 client_(client), | 44 client_(client), |
| 45 is_flinging_(false), | 45 is_flinging_(false), |
| 46 last_touch_start_forced_nonblocking_due_to_fling_(false), | 46 last_touch_start_forced_nonblocking_due_to_fling_(false), |
| 47 enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled( | 47 enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled( |
| 48 features::kPassiveEventListenersDueToFling)), | 48 features::kPassiveEventListenersDueToFling)), |
| 49 enable_non_blocking_due_to_main_thread_responsiveness_flag_( |
| 50 base::FeatureList::IsEnabled( |
| 51 features::kMainThreadBusyScrollIntervention)), |
| 49 main_task_runner_(main_task_runner), | 52 main_task_runner_(main_task_runner), |
| 50 renderer_scheduler_(renderer_scheduler) {} | 53 renderer_scheduler_(renderer_scheduler) {} |
| 51 | 54 |
| 52 MainThreadEventQueue::~MainThreadEventQueue() {} | 55 MainThreadEventQueue::~MainThreadEventQueue() {} |
| 53 | 56 |
| 54 bool MainThreadEventQueue::HandleEvent( | 57 bool MainThreadEventQueue::HandleEvent( |
| 55 ui::ScopedWebInputEvent event, | 58 ui::ScopedWebInputEvent event, |
| 56 const ui::LatencyInfo& latency, | 59 const ui::LatencyInfo& latency, |
| 57 InputEventDispatchType original_dispatch_type, | 60 InputEventDispatchType original_dispatch_type, |
| 58 InputEventAckState ack_result) { | 61 InputEventAckState ack_result) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 84 touch_event->dispatchType == blink::WebInputEvent::Blocking) { | 87 touch_event->dispatchType == blink::WebInputEvent::Blocking) { |
| 85 // If the touch start is forced to be passive due to fling, its following | 88 // If the touch start is forced to be passive due to fling, its following |
| 86 // touch move should also be passive. | 89 // touch move should also be passive. |
| 87 if (is_flinging_ || last_touch_start_forced_nonblocking_due_to_fling_) { | 90 if (is_flinging_ || last_touch_start_forced_nonblocking_due_to_fling_) { |
| 88 touch_event->dispatchType = | 91 touch_event->dispatchType = |
| 89 blink::WebInputEvent::ListenersForcedNonBlockingDueToFling; | 92 blink::WebInputEvent::ListenersForcedNonBlockingDueToFling; |
| 90 non_blocking = true; | 93 non_blocking = true; |
| 91 last_touch_start_forced_nonblocking_due_to_fling_ = true; | 94 last_touch_start_forced_nonblocking_due_to_fling_ = true; |
| 92 } | 95 } |
| 93 } | 96 } |
| 97 |
| 98 if (enable_non_blocking_due_to_main_thread_responsiveness_flag_ && |
| 99 touch_event->dispatchType == blink::WebInputEvent::Blocking) { |
| 100 bool passive_due_to_unresponsive_main = |
| 101 renderer_scheduler_ |
| 102 ->ShouldForceEventsNonBlockingForUnresponsiveMainThread(); |
| 103 if (passive_due_to_unresponsive_main) { |
| 104 touch_event->dispatchType = blink::WebInputEvent:: |
| 105 ListenersForcedNonBlockingDueToMainThreadResponsiveness; |
| 106 non_blocking = true; |
| 107 } |
| 108 } |
| 94 } | 109 } |
| 95 if (is_wheel && non_blocking) { | 110 if (is_wheel && non_blocking) { |
| 96 // Adjust the |dispatchType| on the event since the compositor | 111 // Adjust the |dispatchType| on the event since the compositor |
| 97 // determined all event listeners are passive. | 112 // determined all event listeners are passive. |
| 98 static_cast<blink::WebMouseWheelEvent*>(event.get()) | 113 static_cast<blink::WebMouseWheelEvent*>(event.get()) |
| 99 ->dispatchType = blink::WebInputEvent::ListenersNonBlockingPassive; | 114 ->dispatchType = blink::WebInputEvent::ListenersNonBlockingPassive; |
| 100 } | 115 } |
| 101 | 116 |
| 102 InputEventDispatchType dispatch_type = | 117 InputEventDispatchType dispatch_type = |
| 103 non_blocking ? DISPATCH_TYPE_NON_BLOCKING : DISPATCH_TYPE_BLOCKING; | 118 non_blocking ? DISPATCH_TYPE_NON_BLOCKING : DISPATCH_TYPE_BLOCKING; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 base::AutoLock lock(event_queue_lock_); | 174 base::AutoLock lock(event_queue_lock_); |
| 160 size_t size_before = events_.size(); | 175 size_t size_before = events_.size(); |
| 161 events_.Queue(std::move(event)); | 176 events_.Queue(std::move(event)); |
| 162 send_notification = events_.size() != size_before; | 177 send_notification = events_.size() != size_before; |
| 163 } | 178 } |
| 164 if (send_notification) | 179 if (send_notification) |
| 165 SendEventNotificationToMainThread(); | 180 SendEventNotificationToMainThread(); |
| 166 } | 181 } |
| 167 | 182 |
| 168 } // namespace content | 183 } // namespace content |
| OLD | NEW |