Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: content/renderer/input/main_thread_event_queue.cc

Issue 2240473002: Give MainThreadEventQueue a mutable WebInputEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed consts Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 const blink::WebInputEvent& event, 12 ScopedWebInputEvent event,
13 const ui::LatencyInfo& latency, 13 const ui::LatencyInfo& latency,
14 InputEventDispatchType dispatch_type) 14 InputEventDispatchType dispatch_type)
15 : ScopedWebInputEventWithLatencyInfo(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
(...skipping 13 matching lines...) Expand all
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 const blink::WebInputEvent* event, 49 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;
60 60
61 InputEventDispatchType dispatch_type = 61 InputEventDispatchType dispatch_type =
62 non_blocking ? DISPATCH_TYPE_NON_BLOCKING : DISPATCH_TYPE_BLOCKING; 62 non_blocking ? DISPATCH_TYPE_NON_BLOCKING : DISPATCH_TYPE_BLOCKING;
63 63
64 bool is_wheel = event->type == blink::WebInputEvent::MouseWheel; 64 bool is_wheel = event->type == blink::WebInputEvent::MouseWheel;
65 bool is_touch = blink::WebInputEvent::isTouchEventType(event->type); 65 bool is_touch = blink::WebInputEvent::isTouchEventType(event->type);
66 66
67 std::unique_ptr<EventWithDispatchType> cloned_event(
68 new EventWithDispatchType(*event, latency, dispatch_type));
69
70 if (is_touch) { 67 if (is_touch) {
71 blink::WebTouchEvent& touch_event = 68 blink::WebTouchEvent* touch_event =
72 static_cast<blink::WebTouchEvent&>(cloned_event->event()); 69 static_cast<blink::WebTouchEvent*>(event.get());
73 touch_event.dispatchedDuringFling = is_flinging_; 70 touch_event->dispatchedDuringFling = is_flinging_;
74 // Adjust the |dispatchType| on the event since the compositor 71 // Adjust the |dispatchType| on the event since the compositor
75 // determined all event listeners are passive. 72 // determined all event listeners are passive.
76 if (non_blocking) { 73 if (non_blocking) {
77 touch_event.dispatchType = 74 touch_event->dispatchType =
78 blink::WebInputEvent::ListenersNonBlockingPassive; 75 blink::WebInputEvent::ListenersNonBlockingPassive;
79 } 76 }
80 } 77 }
81 if (is_wheel && non_blocking) { 78 if (is_wheel && non_blocking) {
82 // Adjust the |dispatchType| on the event since the compositor 79 // Adjust the |dispatchType| on the event since the compositor
83 // determined all event listeners are passive. 80 // determined all event listeners are passive.
84 static_cast<blink::WebMouseWheelEvent&>(cloned_event->event()) 81 static_cast<blink::WebMouseWheelEvent*>(event.get())
85 .dispatchType = blink::WebInputEvent::ListenersNonBlockingPassive; 82 ->dispatchType = blink::WebInputEvent::ListenersNonBlockingPassive;
86 } 83 }
87 84
88 QueueEvent(std::move(cloned_event)); 85 std::unique_ptr<EventWithDispatchType> event_with_dispatch_type(
86 new EventWithDispatchType(std::move(event), latency, dispatch_type));
87
88 QueueEvent(std::move(event_with_dispatch_type));
89 89
90 // send an ack when we are non-blocking. 90 // send an ack when we are non-blocking.
91 return non_blocking; 91 return non_blocking;
92 } 92 }
93 93
94 void MainThreadEventQueue::PopEventOnMainThread() { 94 void MainThreadEventQueue::PopEventOnMainThread() {
95 { 95 {
96 base::AutoLock lock(event_queue_lock_); 96 base::AutoLock lock(event_queue_lock_);
97 if (!events_.empty()) 97 if (!events_.empty())
98 in_flight_event_ = events_.Pop(); 98 in_flight_event_ = events_.Pop();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « content/renderer/input/main_thread_event_queue.h ('k') | content/renderer/input/main_thread_event_queue_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698