| 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 |
| 11 namespace content { | 11 namespace content { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 // The maximum number of post-coalesced events processed per rAF task. 10 was | 15 // The maximum number of post-coalesced events processed per rAF task. 10 was |
| 16 // chosen because it really should never be hit yet prevents an infinite loop if | 16 // chosen because it really should never be hit yet prevents an infinite loop if |
| 17 // the compositor keeps delivering events faster than the main thread can | 17 // the compositor keeps delivering events faster than the main thread can |
| 18 // process them. | 18 // process them. |
| 19 const size_t kMaxEventsPerRafTask = 10; | 19 const size_t kMaxEventsPerRafTask = 10; |
| 20 | 20 |
| 21 const size_t kTenSeconds = 10 * 1000 * 1000; | 21 const size_t kTenSeconds = 10 * 1000 * 1000; |
| 22 | 22 |
| 23 bool isContinuousEvent(const std::unique_ptr<EventWithDispatchType>& event) { | 23 bool isContinuousEvent(const std::unique_ptr<EventWithDispatchType>& event) { |
| 24 switch (event->event().type) { | 24 switch (event->event().type) { |
| 25 case blink::WebInputEvent::MouseMove: | 25 case blink::WebInputEvent::MouseMove: |
| 26 case blink::WebInputEvent::TouchMove: | |
| 27 case blink::WebInputEvent::MouseWheel: | 26 case blink::WebInputEvent::MouseWheel: |
| 28 return true; | 27 return true; |
| 28 case blink::WebInputEvent::TouchMove: |
| 29 // TouchMoves that are blocking end up blocking scroll. Do not treat |
| 30 // them as continuous events otherwise we will end up waiting up to an |
| 31 // additional frame. |
| 32 return static_cast<const blink::WebTouchEvent&>(event->event()) |
| 33 .dispatchType != blink::WebInputEvent::Blocking; |
| 29 default: | 34 default: |
| 30 return false; | 35 return false; |
| 31 } | 36 } |
| 32 } | 37 } |
| 33 | 38 |
| 34 } // namespace | 39 } // namespace |
| 35 | 40 |
| 36 EventWithDispatchType::EventWithDispatchType( | 41 EventWithDispatchType::EventWithDispatchType( |
| 37 ui::ScopedWebInputEvent event, | 42 ui::ScopedWebInputEvent event, |
| 38 const ui::LatencyInfo& latency, | 43 const ui::LatencyInfo& latency, |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 } | 284 } |
| 280 } | 285 } |
| 281 } | 286 } |
| 282 for (size_t i = 0; i < send_notification_count; ++i) | 287 for (size_t i = 0; i < send_notification_count; ++i) |
| 283 SendEventNotificationToMainThread(); | 288 SendEventNotificationToMainThread(); |
| 284 if (needs_main_frame) | 289 if (needs_main_frame) |
| 285 client_->NeedsMainFrame(routing_id_); | 290 client_->NeedsMainFrame(routing_id_); |
| 286 } | 291 } |
| 287 | 292 |
| 288 } // namespace content | 293 } // namespace content |
| OLD | NEW |