| 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 #include "content/common/input/event_with_latency_info.h" | 6 #include "content/common/input/event_with_latency_info.h" |
| 7 #include "content/common/input_messages.h" | 7 #include "content/common/input_messages.h" |
| 8 | 8 |
| 9 namespace content { | 9 namespace content { |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 const ui::LatencyInfo& latency, | 50 const ui::LatencyInfo& latency, |
| 51 InputEventDispatchType original_dispatch_type, | 51 InputEventDispatchType original_dispatch_type, |
| 52 InputEventAckState ack_result) { | 52 InputEventAckState ack_result) { |
| 53 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING || | 53 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING || |
| 54 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING); | 54 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING); |
| 55 DCHECK(ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING || | 55 DCHECK(ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING || |
| 56 ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 56 ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 57 | 57 |
| 58 bool non_blocking = original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING || | 58 bool non_blocking = original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING || |
| 59 ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING; | 59 ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING; |
| 60 | |
| 61 InputEventDispatchType dispatch_type = | |
| 62 non_blocking ? DISPATCH_TYPE_NON_BLOCKING : DISPATCH_TYPE_BLOCKING; | |
| 63 | |
| 64 bool is_wheel = event->type == blink::WebInputEvent::MouseWheel; | 60 bool is_wheel = event->type == blink::WebInputEvent::MouseWheel; |
| 65 bool is_touch = blink::WebInputEvent::isTouchEventType(event->type); | 61 bool is_touch = blink::WebInputEvent::isTouchEventType(event->type); |
| 66 | 62 |
| 67 if (is_touch) { | 63 if (is_touch) { |
| 68 blink::WebTouchEvent* touch_event = | 64 blink::WebTouchEvent* touch_event = |
| 69 static_cast<blink::WebTouchEvent*>(event.get()); | 65 static_cast<blink::WebTouchEvent*>(event.get()); |
| 70 touch_event->dispatchedDuringFling = is_flinging_; | 66 touch_event->dispatchedDuringFling = is_flinging_; |
| 71 // Adjust the |dispatchType| on the event since the compositor | 67 // Adjust the |dispatchType| on the event since the compositor |
| 72 // determined all event listeners are passive. | 68 // determined all event listeners are passive. |
| 73 if (non_blocking) { | 69 if (non_blocking) { |
| 74 touch_event->dispatchType = | 70 touch_event->dispatchType = |
| 75 blink::WebInputEvent::ListenersNonBlockingPassive; | 71 blink::WebInputEvent::ListenersNonBlockingPassive; |
| 76 } | 72 } |
| 73 if (is_flinging_ && touch_event->touchStartOrFirstTouchMove && |
| 74 touch_event->dispatchType == blink::WebInputEvent::Blocking) { |
| 75 touch_event->dispatchType = |
| 76 blink::WebInputEvent::ListenersForcedNonBlockingPassiveDueToFling; |
| 77 non_blocking = true; |
| 78 } |
| 77 } | 79 } |
| 78 if (is_wheel && non_blocking) { | 80 if (is_wheel && non_blocking) { |
| 79 // Adjust the |dispatchType| on the event since the compositor | 81 // Adjust the |dispatchType| on the event since the compositor |
| 80 // determined all event listeners are passive. | 82 // determined all event listeners are passive. |
| 81 static_cast<blink::WebMouseWheelEvent*>(event.get()) | 83 static_cast<blink::WebMouseWheelEvent*>(event.get()) |
| 82 ->dispatchType = blink::WebInputEvent::ListenersNonBlockingPassive; | 84 ->dispatchType = blink::WebInputEvent::ListenersNonBlockingPassive; |
| 83 } | 85 } |
| 84 | 86 |
| 87 InputEventDispatchType dispatch_type = |
| 88 non_blocking ? DISPATCH_TYPE_NON_BLOCKING : DISPATCH_TYPE_BLOCKING; |
| 85 std::unique_ptr<EventWithDispatchType> event_with_dispatch_type( | 89 std::unique_ptr<EventWithDispatchType> event_with_dispatch_type( |
| 86 new EventWithDispatchType(std::move(event), latency, dispatch_type)); | 90 new EventWithDispatchType(std::move(event), latency, dispatch_type)); |
| 87 | 91 |
| 88 QueueEvent(std::move(event_with_dispatch_type)); | 92 QueueEvent(std::move(event_with_dispatch_type)); |
| 89 | 93 |
| 90 // send an ack when we are non-blocking. | 94 // send an ack when we are non-blocking. |
| 91 return non_blocking; | 95 return non_blocking; |
| 92 } | 96 } |
| 93 | 97 |
| 94 void MainThreadEventQueue::PopEventOnMainThread() { | 98 void MainThreadEventQueue::PopEventOnMainThread() { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 base::AutoLock lock(event_queue_lock_); | 139 base::AutoLock lock(event_queue_lock_); |
| 136 size_t size_before = events_.size(); | 140 size_t size_before = events_.size(); |
| 137 events_.Queue(std::move(event)); | 141 events_.Queue(std::move(event)); |
| 138 send_notification = events_.size() != size_before; | 142 send_notification = events_.size() != size_before; |
| 139 } | 143 } |
| 140 if (send_notification) | 144 if (send_notification) |
| 141 SendEventNotificationToMainThread(); | 145 SendEventNotificationToMainThread(); |
| 142 } | 146 } |
| 143 | 147 |
| 144 } // namespace content | 148 } // namespace content |
| OLD | NEW |