Chromium Code Reviews| Index: content/renderer/input/main_thread_event_queue.cc |
| diff --git a/content/renderer/input/main_thread_event_queue.cc b/content/renderer/input/main_thread_event_queue.cc |
| index 99881bdf0e1a805a1bb2c7cf84ecd989fe01fc33..6005d314868130cf4c7c6ca3fa6b0fa914d77bb6 100644 |
| --- a/content/renderer/input/main_thread_event_queue.cc |
| +++ b/content/renderer/input/main_thread_event_queue.cc |
| @@ -14,7 +14,8 @@ namespace { |
| const size_t kTenSeconds = 10 * 1000 * 1000; |
| -bool isContinuousEvent(const std::unique_ptr<EventWithDispatchType>& event) { |
| +bool isPossiblyContinuousEvent( |
|
Charlie Reis
2016/10/25 16:58:46
Style nit: "Is" should be capitalized.
dtapuska
2016/10/26 02:34:52
Done.
|
| + const std::unique_ptr<EventWithDispatchType>& event) { |
| switch (event->event().type) { |
| case blink::WebInputEvent::MouseMove: |
| case blink::WebInputEvent::MouseWheel: |
| @@ -72,8 +73,10 @@ MainThreadEventQueue::MainThreadEventQueue( |
| last_touch_start_forced_nonblocking_due_to_fling_(false), |
| enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled( |
| features::kPassiveEventListenersDueToFling)), |
| - handle_raf_aligned_input_( |
| - base::FeatureList::IsEnabled(features::kRafAlignedInputEvents)), |
| + handle_raf_aligned_touch_input_( |
| + base::FeatureList::IsEnabled(features::kRafAlignedTouchInputEvents)), |
| + handle_raf_aligned_mouse_input_( |
| + base::FeatureList::IsEnabled(features::kRafAlignedMouseInputEvents)), |
| main_task_runner_(main_task_runner), |
| renderer_scheduler_(renderer_scheduler) {} |
| @@ -143,7 +146,7 @@ void MainThreadEventQueue::DispatchInFlightEvent() { |
| // Report the coalesced count only for continuous events; otherwise |
| // the zero value would be dominated by non-continuous events. |
| base::TimeTicks now = base::TimeTicks::Now(); |
| - if (isContinuousEvent(in_flight_event_)) { |
| + if (isPossiblyContinuousEvent(in_flight_event_)) { |
| UMA_HISTOGRAM_CUSTOM_COUNTS( |
| "Event.MainThreadEventQueue.Continuous.QueueingTime", |
| (now - in_flight_event_->creationTimestamp()).InMicroseconds(), 1, |
| @@ -178,14 +181,14 @@ void MainThreadEventQueue::DispatchInFlightEvent() { |
| } |
| void MainThreadEventQueue::PossiblyScheduleMainFrame() { |
| - if (!handle_raf_aligned_input_) |
| + if (RafAlignedInputDisabled()) |
| return; |
| bool needs_main_frame = false; |
| { |
| base::AutoLock lock(shared_state_lock_); |
| if (!shared_state_.sent_main_frame_request_ && |
| !shared_state_.events_.empty() && |
| - isContinuousEvent(shared_state_.events_.front())) { |
| + IsContinuousEvent(shared_state_.events_.front())) { |
| needs_main_frame = !shared_state_.sent_main_frame_request_; |
| shared_state_.sent_main_frame_request_ = false; |
| } |
| @@ -221,7 +224,7 @@ void MainThreadEventQueue::EventHandled(blink::WebInputEvent::Type type, |
| } |
| void MainThreadEventQueue::DispatchRafAlignedInput() { |
| - if (!handle_raf_aligned_input_) |
| + if (RafAlignedInputDisabled()) |
| return; |
| std::deque<std::unique_ptr<EventWithDispatchType>> events_to_process; |
| @@ -230,7 +233,7 @@ void MainThreadEventQueue::DispatchRafAlignedInput() { |
| shared_state_.sent_main_frame_request_ = false; |
| while(!shared_state_.events_.empty()) { |
| - if (!isContinuousEvent(shared_state_.events_.front())) |
| + if (!IsContinuousEvent(shared_state_.events_.front())) |
| break; |
| events_to_process.emplace_back(shared_state_.events_.Pop()); |
| } |
| @@ -251,7 +254,7 @@ void MainThreadEventQueue::SendEventNotificationToMainThread() { |
| void MainThreadEventQueue::QueueEvent( |
| std::unique_ptr<EventWithDispatchType> event) { |
| - bool is_continuous = isContinuousEvent(event); |
| + bool is_continuous = IsContinuousEvent(event); |
| size_t send_notification_count = 0; |
| bool needs_main_frame = false; |
| { |
| @@ -259,15 +262,16 @@ void MainThreadEventQueue::QueueEvent( |
| size_t size_before = shared_state_.events_.size(); |
| shared_state_.events_.Queue(std::move(event)); |
| size_t size_after = shared_state_.events_.size(); |
| + |
| if (size_before != size_after) { |
| - if (!handle_raf_aligned_input_) { |
| + if (RafAlignedInputDisabled()) { |
| send_notification_count = 1; |
| } else if (!is_continuous) { |
| send_notification_count = 1; |
| // If we had just enqueued a non-rAF input event we will send a series |
| // of normal post messages to ensure they are all handled right away. |
| for (size_t pos = size_after - 1; pos >= 1; --pos) { |
| - if (isContinuousEvent(shared_state_.events_.at(pos - 1))) |
| + if (IsContinuousEvent(shared_state_.events_.at(pos - 1))) |
| send_notification_count++; |
| else |
| break; |
| @@ -284,4 +288,26 @@ void MainThreadEventQueue::QueueEvent( |
| client_->NeedsMainFrame(routing_id_); |
| } |
| +bool MainThreadEventQueue::RafAlignedInputDisabled() { |
| + return !handle_raf_aligned_mouse_input_ && !handle_raf_aligned_touch_input_; |
| +} |
| + |
| +bool MainThreadEventQueue::IsContinuousEvent( |
|
tdresser
2016/10/25 17:37:44
Can we name this more clearly? Whether or not rAF
dtapuska
2016/10/26 02:34:52
Done.
|
| + const std::unique_ptr<EventWithDispatchType>& event) { |
| + switch (event->event().type) { |
| + case blink::WebInputEvent::MouseMove: |
| + case blink::WebInputEvent::MouseWheel: |
| + return handle_raf_aligned_mouse_input_; |
| + case blink::WebInputEvent::TouchMove: |
| + // TouchMoves that are blocking end up blocking scroll. Do not treat |
| + // them as continuous events otherwise we will end up waiting up to an |
| + // additional frame. |
| + return static_cast<const blink::WebTouchEvent&>(event->event()) |
| + .dispatchType != blink::WebInputEvent::Blocking && |
| + handle_raf_aligned_touch_input_; |
| + default: |
| + return false; |
| + } |
| +} |
| + |
| } // namespace content |