| 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 |
| 11 EventWithDispatchType::EventWithDispatchType( | 11 EventWithDispatchType::EventWithDispatchType( |
| 12 ScopedWebInputEvent event, | 12 ui::ScopedWebInputEvent event, |
| 13 const ui::LatencyInfo& latency, | 13 const ui::LatencyInfo& latency, |
| 14 InputEventDispatchType dispatch_type) | 14 InputEventDispatchType dispatch_type) |
| 15 : ScopedWebInputEventWithLatencyInfo(std::move(event), latency), | 15 : ScopedWebInputEventWithLatencyInfo(std::move(event), latency), |
| 16 dispatch_type_(dispatch_type) {} | 16 dispatch_type_(dispatch_type) {} |
| 17 | 17 |
| 18 EventWithDispatchType::~EventWithDispatchType() {} | 18 EventWithDispatchType::~EventWithDispatchType() {} |
| 19 | 19 |
| 20 bool EventWithDispatchType::CanCoalesceWith( | 20 bool EventWithDispatchType::CanCoalesceWith( |
| 21 const EventWithDispatchType& other) const { | 21 const EventWithDispatchType& other) const { |
| 22 return other.dispatch_type_ == dispatch_type_ && | 22 return other.dispatch_type_ == dispatch_type_ && |
| 23 ScopedWebInputEventWithLatencyInfo::CanCoalesceWith(other); | 23 ScopedWebInputEventWithLatencyInfo::CanCoalesceWith(other); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void EventWithDispatchType::CoalesceWith(const EventWithDispatchType& other) { | 26 void EventWithDispatchType::CoalesceWith(const EventWithDispatchType& other) { |
| 27 // If we are blocking and are coalescing touch, make sure to keep | 27 // If we are blocking and are coalescing touch, make sure to keep |
| 28 // the touch ids that need to be acked. | 28 // the touch ids that need to be acked. |
| 29 if (dispatch_type_ == DISPATCH_TYPE_BLOCKING) { | 29 if (dispatch_type_ == DISPATCH_TYPE_BLOCKING) { |
| 30 // We should only have blocking touch events that need coalescing. | 30 // We should only have blocking touch events that need coalescing. |
| 31 eventsToAck_.push_back( | 31 eventsToAck_.push_back( |
| 32 WebInputEventTraits::GetUniqueTouchEventId(other.event())); | 32 ui::WebInputEventTraits::GetUniqueTouchEventId(other.event())); |
| 33 } | 33 } |
| 34 ScopedWebInputEventWithLatencyInfo::CoalesceWith(other); | 34 ScopedWebInputEventWithLatencyInfo::CoalesceWith(other); |
| 35 } | 35 } |
| 36 | 36 |
| 37 MainThreadEventQueue::MainThreadEventQueue( | 37 MainThreadEventQueue::MainThreadEventQueue( |
| 38 int routing_id, | 38 int routing_id, |
| 39 MainThreadEventQueueClient* client, | 39 MainThreadEventQueueClient* client, |
| 40 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner) | 40 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner) |
| 41 : routing_id_(routing_id), | 41 : routing_id_(routing_id), |
| 42 client_(client), | 42 client_(client), |
| 43 is_flinging_(false), | 43 is_flinging_(false), |
| 44 main_task_runner_(main_task_runner) {} | 44 main_task_runner_(main_task_runner) {} |
| 45 | 45 |
| 46 MainThreadEventQueue::~MainThreadEventQueue() {} | 46 MainThreadEventQueue::~MainThreadEventQueue() {} |
| 47 | 47 |
| 48 bool MainThreadEventQueue::HandleEvent( | 48 bool MainThreadEventQueue::HandleEvent( |
| 49 ScopedWebInputEvent event, | 49 ui::ScopedWebInputEvent event, |
| 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; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 base::AutoLock lock(event_queue_lock_); | 135 base::AutoLock lock(event_queue_lock_); |
| 136 size_t size_before = events_.size(); | 136 size_t size_before = events_.size(); |
| 137 events_.Queue(std::move(event)); | 137 events_.Queue(std::move(event)); |
| 138 send_notification = events_.size() != size_before; | 138 send_notification = events_.size() != size_before; |
| 139 } | 139 } |
| 140 if (send_notification) | 140 if (send_notification) |
| 141 SendEventNotificationToMainThread(); | 141 SendEventNotificationToMainThread(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 } // namespace content | 144 } // namespace content |
| OLD | NEW |