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

Side by Side Diff: content/renderer/mus/compositor_mus_connection.cc

Issue 2479123003: WIP Add getCoalescedEvents API using vector of WebInputEvents (Closed)
Patch Set: Creating CoalescedWebInputEvent Created 4 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/mus/compositor_mus_connection.h" 5 #include "content/renderer/mus/compositor_mus_connection.h"
6 6
7 #include "base/single_thread_task_runner.h" 7 #include "base/single_thread_task_runner.h"
8 #include "content/renderer/input/input_handler_manager.h" 8 #include "content/renderer/input/input_handler_manager.h"
9 #include "content/renderer/mus/render_widget_mus_connection.h" 9 #include "content/renderer/mus/render_widget_mus_connection.h"
10 #include "ui/events/blink/blink_event_util.h" 10 #include "ui/events/blink/blink_event_util.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 void CompositorMusConnection::OnConnectionLostOnMainThread() { 88 void CompositorMusConnection::OnConnectionLostOnMainThread() {
89 DCHECK(main_task_runner_->BelongsToCurrentThread()); 89 DCHECK(main_task_runner_->BelongsToCurrentThread());
90 RenderWidgetMusConnection* connection = 90 RenderWidgetMusConnection* connection =
91 RenderWidgetMusConnection::Get(routing_id_); 91 RenderWidgetMusConnection::Get(routing_id_);
92 if (!connection) 92 if (!connection)
93 return; 93 return;
94 connection->OnConnectionLost(); 94 connection->OnConnectionLost();
95 } 95 }
96 96
97 void CompositorMusConnection::OnWindowInputEventOnMainThread( 97 void CompositorMusConnection::OnWindowInputEventOnMainThread(
98 ui::ScopedWebInputEvent web_event, 98 blink::ScopedCoalescedWebInputEvent web_event,
99 const base::Callback<void(EventResult)>& ack) { 99 const base::Callback<void(EventResult)>& ack) {
100 DCHECK(main_task_runner_->BelongsToCurrentThread()); 100 DCHECK(main_task_runner_->BelongsToCurrentThread());
101 RenderWidgetMusConnection* connection = 101 RenderWidgetMusConnection* connection =
102 RenderWidgetMusConnection::Get(routing_id_); 102 RenderWidgetMusConnection::Get(routing_id_);
103 if (!connection) { 103 if (!connection) {
104 ack.Run(EventResult::UNHANDLED); 104 ack.Run(EventResult::UNHANDLED);
105 return; 105 return;
106 } 106 }
107 connection->OnWindowInputEvent(std::move(web_event), ack); 107 connection->OnWindowInputEvent(std::move(web_event), ack);
108 } 108 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 179
180 void CompositorMusConnection::OnWindowInputEvent( 180 void CompositorMusConnection::OnWindowInputEvent(
181 ui::Window* window, 181 ui::Window* window,
182 const ui::Event& event, 182 const ui::Event& event,
183 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) { 183 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) {
184 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); 184 DCHECK(compositor_task_runner_->BelongsToCurrentThread());
185 185
186 // Take ownership of the callback, indicating that we will handle it. 186 // Take ownership of the callback, indicating that we will handle it.
187 std::unique_ptr<base::Callback<void(EventResult)>> callback = 187 std::unique_ptr<base::Callback<void(EventResult)>> callback =
188 std::move(*ack_callback); 188 std::move(*ack_callback);
189 ui::ScopedWebInputEvent web_event(Convert(event).release()); 189 blink::ScopedCoalescedWebInputEvent web_event(
190 new blink::CoalescedWebInputEvent(Convert(event).release()));
190 // TODO(sad): We probably need to plumb LatencyInfo through Mus. 191 // TODO(sad): We probably need to plumb LatencyInfo through Mus.
191 ui::LatencyInfo info; 192 ui::LatencyInfo info;
192 input_handler_manager_->HandleInputEvent( 193 input_handler_manager_->HandleInputEvent(
193 routing_id_, std::move(web_event), info, 194 routing_id_, std::move(web_event), info,
194 base::Bind( 195 base::Bind(
195 &CompositorMusConnection::DidHandleWindowInputEventAndOverscroll, 196 &CompositorMusConnection::DidHandleWindowInputEventAndOverscroll,
196 this, base::Passed(std::move(callback)))); 197 this, base::Passed(std::move(callback))));
197 } 198 }
198 199
199 void CompositorMusConnection::DidHandleWindowInputEventAndOverscroll( 200 void CompositorMusConnection::DidHandleWindowInputEventAndOverscroll(
200 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback, 201 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback,
201 InputEventAckState ack_state, 202 InputEventAckState ack_state,
202 ui::ScopedWebInputEvent web_event, 203 blink::ScopedCoalescedWebInputEvent web_event,
203 const ui::LatencyInfo& latency_info, 204 const ui::LatencyInfo& latency_info,
204 std::unique_ptr<ui::DidOverscrollParams> overscroll_params) { 205 std::unique_ptr<ui::DidOverscrollParams> overscroll_params) {
205 // TODO(jonross): We probably need to ack the event based on the consumed 206 // TODO(jonross): We probably need to ack the event based on the consumed
206 // state. 207 // state.
207 if (ack_state != INPUT_EVENT_ACK_STATE_NOT_CONSUMED) { 208 if (ack_state != INPUT_EVENT_ACK_STATE_NOT_CONSUMED) {
208 // We took the ownership of the callback, so we need to send the ack, and 209 // We took the ownership of the callback, so we need to send the ack, and
209 // mark the event as not consumed to preserve existing behavior. 210 // mark the event as not consumed to preserve existing behavior.
210 ack_callback->Run(EventResult::UNHANDLED); 211 ack_callback->Run(EventResult::UNHANDLED);
211 return; 212 return;
212 } 213 }
213 base::Callback<void(EventResult)> ack = 214 base::Callback<void(EventResult)> ack =
214 base::Bind(&::DoNothingWithEventResult); 215 base::Bind(&::DoNothingWithEventResult);
215 const bool send_ack = 216 const bool send_ack =
216 ui::WebInputEventTraits::ShouldBlockEventStream(*web_event); 217 ui::WebInputEventTraits::ShouldBlockEventStream(web_event->event());
217 if (send_ack) { 218 if (send_ack) {
218 // Ultimately, this ACK needs to go back to the Mus client lib which is not 219 // Ultimately, this ACK needs to go back to the Mus client lib which is not
219 // thread-safe and lives on the compositor thread. For ACKs that are passed 220 // thread-safe and lives on the compositor thread. For ACKs that are passed
220 // to the main thread we pass them back to the compositor thread via 221 // to the main thread we pass them back to the compositor thread via
221 // OnWindowInputEventAckOnMainThread. 222 // OnWindowInputEventAckOnMainThread.
222 ack = 223 ack =
223 base::Bind(&CompositorMusConnection::OnWindowInputEventAckOnMainThread, 224 base::Bind(&CompositorMusConnection::OnWindowInputEventAckOnMainThread,
224 this, *ack_callback); 225 this, *ack_callback);
225 } else { 226 } else {
226 // We took the ownership of the callback, so we need to send the ack, and 227 // We took the ownership of the callback, so we need to send the ack, and
227 // mark the event as not consumed to preserve existing behavior. 228 // mark the event as not consumed to preserve existing behavior.
228 ack_callback->Run(EventResult::UNHANDLED); 229 ack_callback->Run(EventResult::UNHANDLED);
229 } 230 }
230 ack_callback.reset(); 231 ack_callback.reset();
231 232
232 main_task_runner_->PostTask( 233 main_task_runner_->PostTask(
233 FROM_HERE, 234 FROM_HERE,
234 base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this, 235 base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this,
235 base::Passed(std::move(web_event)), ack)); 236 base::Passed(std::move(web_event)), ack));
236 } 237 }
237 238
238 } // namespace content 239 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698