Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 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 waiting_for_first_touch_move_(false) {} | |
| 45 | 46 |
| 46 MainThreadEventQueue::~MainThreadEventQueue() {} | 47 MainThreadEventQueue::~MainThreadEventQueue() {} |
| 47 | 48 |
| 48 bool MainThreadEventQueue::HandleEvent( | 49 bool MainThreadEventQueue::HandleEvent( |
| 49 const blink::WebInputEvent* event, | 50 const blink::WebInputEvent* event, |
| 50 const ui::LatencyInfo& latency, | 51 const ui::LatencyInfo& latency, |
| 51 InputEventDispatchType original_dispatch_type, | 52 InputEventDispatchType original_dispatch_type, |
| 52 InputEventAckState ack_result) { | 53 InputEventAckState ack_result) { |
| 53 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING || | 54 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING || |
| 54 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING); | 55 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 70 if (is_touch) { | 71 if (is_touch) { |
| 71 blink::WebTouchEvent& touch_event = | 72 blink::WebTouchEvent& touch_event = |
| 72 static_cast<blink::WebTouchEvent&>(cloned_event->event()); | 73 static_cast<blink::WebTouchEvent&>(cloned_event->event()); |
| 73 touch_event.dispatchedDuringFling = is_flinging_; | 74 touch_event.dispatchedDuringFling = is_flinging_; |
| 74 // Adjust the |dispatchType| on the event since the compositor | 75 // Adjust the |dispatchType| on the event since the compositor |
| 75 // determined all event listeners are passive. | 76 // determined all event listeners are passive. |
| 76 if (non_blocking) { | 77 if (non_blocking) { |
| 77 touch_event.dispatchType = | 78 touch_event.dispatchType = |
| 78 blink::WebInputEvent::ListenersNonBlockingPassive; | 79 blink::WebInputEvent::ListenersNonBlockingPassive; |
| 79 } | 80 } |
| 81 if (is_flinging_ && | |
|
dtapuska
2016/08/10 14:47:42
does |is_flinging_| change after the touch start?
| |
| 82 touch_event.dispatchType == blink::WebInputEvent::Blocking) { | |
| 83 bool touch_start_or_first_touch_move = false; | |
| 84 if (event->type == blink::WebInputEvent::TouchStart) { | |
| 85 waiting_for_first_touch_move_ = true; | |
| 86 touch_start_or_first_touch_move = true; | |
| 87 } else if (event->type == blink::WebInputEvent::TouchMove) { | |
| 88 touch_start_or_first_touch_move = waiting_for_first_touch_move_; | |
| 89 waiting_for_first_touch_move_ = false; | |
| 90 } | |
| 91 if (touch_start_or_first_touch_move) { | |
| 92 touch_event.dispatchType = | |
| 93 blink::WebInputEvent::ListenersForcedNonBlockingPassiveDueToFling; | |
| 94 } | |
| 95 } | |
| 80 } | 96 } |
| 81 if (is_wheel && non_blocking) { | 97 if (is_wheel && non_blocking) { |
| 82 // Adjust the |dispatchType| on the event since the compositor | 98 // Adjust the |dispatchType| on the event since the compositor |
| 83 // determined all event listeners are passive. | 99 // determined all event listeners are passive. |
| 84 static_cast<blink::WebMouseWheelEvent&>(cloned_event->event()) | 100 static_cast<blink::WebMouseWheelEvent&>(cloned_event->event()) |
| 85 .dispatchType = blink::WebInputEvent::ListenersNonBlockingPassive; | 101 .dispatchType = blink::WebInputEvent::ListenersNonBlockingPassive; |
| 86 } | 102 } |
| 87 | 103 |
| 88 QueueEvent(std::move(cloned_event)); | 104 QueueEvent(std::move(cloned_event)); |
| 89 | 105 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 base::AutoLock lock(event_queue_lock_); | 151 base::AutoLock lock(event_queue_lock_); |
| 136 size_t size_before = events_.size(); | 152 size_t size_before = events_.size(); |
| 137 events_.Queue(std::move(event)); | 153 events_.Queue(std::move(event)); |
| 138 send_notification = events_.size() != size_before; | 154 send_notification = events_.size() != size_before; |
| 139 } | 155 } |
| 140 if (send_notification) | 156 if (send_notification) |
| 141 SendEventNotificationToMainThread(); | 157 SendEventNotificationToMainThread(); |
| 142 } | 158 } |
| 143 | 159 |
| 144 } // namespace content | 160 } // namespace content |
| OLD | NEW |