| 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 const size_t kTenSeconds = 10 * 1000 * 1000; | 15 const size_t kTenSeconds = 10 * 1000 * 1000; |
| 16 | 16 |
| 17 bool IsContinuousEvent(const std::unique_ptr<EventWithDispatchType>& event) { | 17 bool IsContinuousEvent(const std::unique_ptr<EventWithDispatchType>& event) { |
| 18 switch (event->event().type) { | 18 switch (event->event().type()) { |
| 19 case blink::WebInputEvent::MouseMove: | 19 case blink::WebInputEvent::MouseMove: |
| 20 case blink::WebInputEvent::MouseWheel: | 20 case blink::WebInputEvent::MouseWheel: |
| 21 return true; | 21 return true; |
| 22 case blink::WebInputEvent::TouchMove: | 22 case blink::WebInputEvent::TouchMove: |
| 23 // TouchMoves that are blocking end up blocking scroll. Do not treat | 23 // TouchMoves that are blocking end up blocking scroll. Do not treat |
| 24 // them as continuous events otherwise we will end up waiting up to an | 24 // them as continuous events otherwise we will end up waiting up to an |
| 25 // additional frame. | 25 // additional frame. |
| 26 return static_cast<const blink::WebTouchEvent&>(event->event()) | 26 return static_cast<const blink::WebTouchEvent&>(event->event()) |
| 27 .dispatchType != blink::WebInputEvent::Blocking; | 27 .dispatchType != blink::WebInputEvent::Blocking; |
| 28 default: | 28 default: |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 InputEventDispatchType original_dispatch_type, | 85 InputEventDispatchType original_dispatch_type, |
| 86 InputEventAckState ack_result) { | 86 InputEventAckState ack_result) { |
| 87 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING || | 87 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING || |
| 88 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING); | 88 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING); |
| 89 DCHECK(ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING || | 89 DCHECK(ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING || |
| 90 ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING_DUE_TO_FLING || | 90 ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING_DUE_TO_FLING || |
| 91 ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 91 ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 92 | 92 |
| 93 bool non_blocking = original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING || | 93 bool non_blocking = original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING || |
| 94 ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING; | 94 ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING; |
| 95 bool is_wheel = event->type == blink::WebInputEvent::MouseWheel; | 95 bool is_wheel = event->type() == blink::WebInputEvent::MouseWheel; |
| 96 bool is_touch = blink::WebInputEvent::isTouchEventType(event->type); | 96 bool is_touch = blink::WebInputEvent::isTouchEventType(event->type()); |
| 97 | 97 |
| 98 if (is_touch) { | 98 if (is_touch) { |
| 99 blink::WebTouchEvent* touch_event = | 99 blink::WebTouchEvent* touch_event = |
| 100 static_cast<blink::WebTouchEvent*>(event.get()); | 100 static_cast<blink::WebTouchEvent*>(event.get()); |
| 101 | 101 |
| 102 // Adjust the |dispatchType| on the event since the compositor | 102 // Adjust the |dispatchType| on the event since the compositor |
| 103 // determined all event listeners are passive. | 103 // determined all event listeners are passive. |
| 104 if (non_blocking) { | 104 if (non_blocking) { |
| 105 touch_event->dispatchType = | 105 touch_event->dispatchType = |
| 106 blink::WebInputEvent::ListenersNonBlockingPassive; | 106 blink::WebInputEvent::ListenersNonBlockingPassive; |
| 107 } | 107 } |
| 108 if (touch_event->type == blink::WebInputEvent::TouchStart) | 108 if (touch_event->type() == blink::WebInputEvent::TouchStart) |
| 109 last_touch_start_forced_nonblocking_due_to_fling_ = false; | 109 last_touch_start_forced_nonblocking_due_to_fling_ = false; |
| 110 | 110 |
| 111 if (enable_fling_passive_listener_flag_ && | 111 if (enable_fling_passive_listener_flag_ && |
| 112 touch_event->touchStartOrFirstTouchMove && | 112 touch_event->touchStartOrFirstTouchMove && |
| 113 touch_event->dispatchType == blink::WebInputEvent::Blocking) { | 113 touch_event->dispatchType == blink::WebInputEvent::Blocking) { |
| 114 // If the touch start is forced to be passive due to fling, its following | 114 // If the touch start is forced to be passive due to fling, its following |
| 115 // touch move should also be passive. | 115 // touch move should also be passive. |
| 116 if (ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING_DUE_TO_FLING || | 116 if (ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING_DUE_TO_FLING || |
| 117 last_touch_start_forced_nonblocking_due_to_fling_) { | 117 last_touch_start_forced_nonblocking_due_to_fling_) { |
| 118 touch_event->dispatchType = | 118 touch_event->dispatchType = |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 if (needs_main_frame) | 313 if (needs_main_frame) |
| 314 client_->NeedsMainFrame(routing_id_); | 314 client_->NeedsMainFrame(routing_id_); |
| 315 } | 315 } |
| 316 | 316 |
| 317 bool MainThreadEventQueue::IsRafAlignedInputDisabled() { | 317 bool MainThreadEventQueue::IsRafAlignedInputDisabled() { |
| 318 return !handle_raf_aligned_mouse_input_ && !handle_raf_aligned_touch_input_; | 318 return !handle_raf_aligned_mouse_input_ && !handle_raf_aligned_touch_input_; |
| 319 } | 319 } |
| 320 | 320 |
| 321 bool MainThreadEventQueue::IsRafAlignedEvent( | 321 bool MainThreadEventQueue::IsRafAlignedEvent( |
| 322 const blink::WebInputEvent& event) { | 322 const blink::WebInputEvent& event) { |
| 323 switch (event.type) { | 323 switch (event.type()) { |
| 324 case blink::WebInputEvent::MouseMove: | 324 case blink::WebInputEvent::MouseMove: |
| 325 case blink::WebInputEvent::MouseWheel: | 325 case blink::WebInputEvent::MouseWheel: |
| 326 return handle_raf_aligned_mouse_input_; | 326 return handle_raf_aligned_mouse_input_; |
| 327 case blink::WebInputEvent::TouchMove: | 327 case blink::WebInputEvent::TouchMove: |
| 328 // TouchMoves that are blocking end up blocking scroll. Do not treat | 328 // TouchMoves that are blocking end up blocking scroll. Do not treat |
| 329 // them as continuous events otherwise we will end up waiting up to an | 329 // them as continuous events otherwise we will end up waiting up to an |
| 330 // additional frame. | 330 // additional frame. |
| 331 return static_cast<const blink::WebTouchEvent&>(event).dispatchType != | 331 return static_cast<const blink::WebTouchEvent&>(event).dispatchType != |
| 332 blink::WebInputEvent::Blocking && | 332 blink::WebInputEvent::Blocking && |
| 333 handle_raf_aligned_touch_input_; | 333 handle_raf_aligned_touch_input_; |
| 334 default: | 334 default: |
| 335 return false; | 335 return false; |
| 336 } | 336 } |
| 337 } | 337 } |
| 338 | 338 |
| 339 } // namespace content | 339 } // namespace content |
| OLD | NEW |