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 namespace content { | 7 namespace content { |
8 | 8 |
9 MainThreadEventQueue::MainThreadEventQueue(int routing_id, | 9 MainThreadEventQueue::MainThreadEventQueue(int routing_id, |
10 MainThreadEventQueueClient* client) | 10 MainThreadEventQueueClient* client) |
11 : routing_id_(routing_id), client_(client) {} | 11 : routing_id_(routing_id), client_(client) {} |
12 | 12 |
13 MainThreadEventQueue::~MainThreadEventQueue() {} | 13 MainThreadEventQueue::~MainThreadEventQueue() {} |
14 | 14 |
15 bool MainThreadEventQueue::HandleEvent( | 15 bool MainThreadEventQueue::HandleEvent( |
16 const blink::WebInputEvent* event, | 16 const blink::WebInputEvent* event, |
17 const ui::LatencyInfo& latency, | 17 const ui::LatencyInfo& latency, |
18 InputEventDispatchType original_dispatch_type, | 18 InputEventDispatchType original_dispatch_type, |
19 InputEventAckState ack_result) { | 19 InputEventAckState ack_result, |
| 20 bool is_flinging) { |
20 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING || | 21 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING || |
21 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING); | 22 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING); |
22 DCHECK(ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING || | 23 DCHECK(ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING || |
23 ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 24 ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
24 | 25 |
25 bool non_blocking = original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING || | 26 bool non_blocking = original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING || |
26 ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING; | 27 ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING; |
27 | 28 |
28 InputEventDispatchType dispatch_type = | 29 InputEventDispatchType dispatch_type = |
29 non_blocking ? DISPATCH_TYPE_NON_BLOCKING_NOTIFY_MAIN | 30 non_blocking ? DISPATCH_TYPE_NON_BLOCKING_NOTIFY_MAIN |
(...skipping 26 matching lines...) Expand all Loading... |
56 // having the main thread call us back as an optimization. | 57 // having the main thread call us back as an optimization. |
57 client_->SendEventToMainThread(routing_id_, | 58 client_->SendEventToMainThread(routing_id_, |
58 &modified_dispatch_type_event.event, | 59 &modified_dispatch_type_event.event, |
59 latency, original_dispatch_type); | 60 latency, original_dispatch_type); |
60 } | 61 } |
61 } | 62 } |
62 } else if (blink::WebInputEvent::isTouchEventType(event->type)) { | 63 } else if (blink::WebInputEvent::isTouchEventType(event->type)) { |
63 PendingTouchEvent modified_dispatch_type_event = | 64 PendingTouchEvent modified_dispatch_type_event = |
64 PendingTouchEvent(*static_cast<const blink::WebTouchEvent*>(event), | 65 PendingTouchEvent(*static_cast<const blink::WebTouchEvent*>(event), |
65 latency, dispatch_type); | 66 latency, dispatch_type); |
| 67 modified_dispatch_type_event.event.shouldForceBePassive = is_flinging; |
66 | 68 |
67 // Adjust the |dispatchType| on the event since the compositor | 69 // Adjust the |dispatchType| on the event since the compositor |
68 // determined all event listeners are passive. | 70 // determined all event listeners are passive. |
69 if (non_blocking) { | 71 if (non_blocking) { |
70 modified_dispatch_type_event.event.dispatchType = | 72 modified_dispatch_type_event.event.dispatchType = |
71 blink::WebInputEvent::ListenersNonBlockingPassive; | 73 blink::WebInputEvent::ListenersNonBlockingPassive; |
72 } | 74 } |
73 | 75 |
74 if (touch_events_.state() == WebInputEventQueueState::ITEM_PENDING) { | 76 if (touch_events_.state() == WebInputEventQueueState::ITEM_PENDING) { |
75 touch_events_.Queue(modified_dispatch_type_event); | 77 touch_events_.Queue(modified_dispatch_type_event); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 event->type); | 115 event->type); |
114 } else { | 116 } else { |
115 touch_events_.set_state(WebInputEventQueueState::ITEM_NOT_PENDING); | 117 touch_events_.set_state(WebInputEventQueueState::ITEM_NOT_PENDING); |
116 } | 118 } |
117 } else { | 119 } else { |
118 NOTREACHED() << "Invalid passive event type"; | 120 NOTREACHED() << "Invalid passive event type"; |
119 } | 121 } |
120 } | 122 } |
121 | 123 |
122 } // namespace content | 124 } // namespace content |
OLD | NEW |