| OLD | NEW |
| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 ui::ScopedWebInputEvent web_event, |
| 99 const std::vector<const blink::WebInputEvent*>& coalescedEvents, |
| 99 const base::Callback<void(EventResult)>& ack) { | 100 const base::Callback<void(EventResult)>& ack) { |
| 100 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 101 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 101 RenderWidgetMusConnection* connection = | 102 RenderWidgetMusConnection* connection = |
| 102 RenderWidgetMusConnection::Get(routing_id_); | 103 RenderWidgetMusConnection::Get(routing_id_); |
| 103 if (!connection) { | 104 if (!connection) { |
| 104 ack.Run(EventResult::UNHANDLED); | 105 ack.Run(EventResult::UNHANDLED); |
| 105 return; | 106 return; |
| 106 } | 107 } |
| 107 connection->OnWindowInputEvent(std::move(web_event), ack); | 108 connection->OnWindowInputEvent(std::move(web_event), coalescedEvents, ack); |
| 108 } | 109 } |
| 109 | 110 |
| 110 void CompositorMusConnection::OnWindowInputEventAckOnMainThread( | 111 void CompositorMusConnection::OnWindowInputEventAckOnMainThread( |
| 111 const base::Callback<void(EventResult)>& ack, | 112 const base::Callback<void(EventResult)>& ack, |
| 112 EventResult result) { | 113 EventResult result) { |
| 113 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 114 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 114 compositor_task_runner_->PostTask(FROM_HERE, base::Bind(ack, result)); | 115 compositor_task_runner_->PostTask(FROM_HERE, base::Bind(ack, result)); |
| 115 } | 116 } |
| 116 | 117 |
| 117 std::unique_ptr<blink::WebInputEvent> CompositorMusConnection::Convert( | 118 std::unique_ptr<blink::WebInputEvent> CompositorMusConnection::Convert( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 void CompositorMusConnection::OnWindowInputEvent( | 181 void CompositorMusConnection::OnWindowInputEvent( |
| 181 ui::Window* window, | 182 ui::Window* window, |
| 182 const ui::Event& event, | 183 const ui::Event& event, |
| 183 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) { | 184 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) { |
| 184 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); | 185 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); |
| 185 | 186 |
| 186 // Take ownership of the callback, indicating that we will handle it. | 187 // Take ownership of the callback, indicating that we will handle it. |
| 187 std::unique_ptr<base::Callback<void(EventResult)>> callback = | 188 std::unique_ptr<base::Callback<void(EventResult)>> callback = |
| 188 std::move(*ack_callback); | 189 std::move(*ack_callback); |
| 189 ui::ScopedWebInputEvent web_event(Convert(event).release()); | 190 ui::ScopedWebInputEvent web_event(Convert(event).release()); |
| 190 // TODO(sad): We probably need to plumb LatencyInfo through Mus. | 191 // TODO(sad): We probably need to plumb LatencyInfo and coalescedEvents |
| 192 // through Mus. |
| 191 ui::LatencyInfo info; | 193 ui::LatencyInfo info; |
| 194 std::vector<const blink::WebInputEvent*> coalescedEvents; |
| 192 input_handler_manager_->HandleInputEvent( | 195 input_handler_manager_->HandleInputEvent( |
| 193 routing_id_, std::move(web_event), info, | 196 routing_id_, std::move(web_event), coalescedEvents, info, |
| 194 base::Bind( | 197 base::Bind( |
| 195 &CompositorMusConnection::DidHandleWindowInputEventAndOverscroll, | 198 &CompositorMusConnection::DidHandleWindowInputEventAndOverscroll, |
| 196 this, base::Passed(std::move(callback)))); | 199 this, base::Passed(std::move(callback)))); |
| 197 } | 200 } |
| 198 | 201 |
| 199 void CompositorMusConnection::DidHandleWindowInputEventAndOverscroll( | 202 void CompositorMusConnection::DidHandleWindowInputEventAndOverscroll( |
| 200 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback, | 203 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback, |
| 201 InputEventAckState ack_state, | 204 InputEventAckState ack_state, |
| 202 ui::ScopedWebInputEvent web_event, | 205 ui::ScopedWebInputEvent web_event, |
| 203 const ui::LatencyInfo& latency_info, | 206 const ui::LatencyInfo& latency_info, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 225 } else { | 228 } else { |
| 226 // We took the ownership of the callback, so we need to send the ack, and | 229 // 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. | 230 // mark the event as not consumed to preserve existing behavior. |
| 228 ack_callback->Run(EventResult::UNHANDLED); | 231 ack_callback->Run(EventResult::UNHANDLED); |
| 229 } | 232 } |
| 230 ack_callback.reset(); | 233 ack_callback.reset(); |
| 231 | 234 |
| 232 main_task_runner_->PostTask( | 235 main_task_runner_->PostTask( |
| 233 FROM_HERE, | 236 FROM_HERE, |
| 234 base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this, | 237 base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this, |
| 235 base::Passed(std::move(web_event)), ack)); | 238 base::Passed(std::move(web_event)), |
| 239 std::vector<const blink::WebInputEvent*>(), ack)); |
| 236 } | 240 } |
| 237 | 241 |
| 238 } // namespace content | 242 } // namespace content |
| OLD | NEW |