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

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

Issue 2270953002: Merge the mojo blink type converter into ui/events/blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Review Created 4 years, 3 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 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 "mojo/converters/blink/blink_input_events_type_converters.h" 10 #include "ui/events/blink/blink_event_util.h"
11 #include "ui/events/blink/did_overscroll_params.h" 11 #include "ui/events/blink/did_overscroll_params.h"
12 #include "ui/events/blink/web_input_event.h"
12 #include "ui/events/blink/web_input_event_traits.h" 13 #include "ui/events/blink/web_input_event_traits.h"
13 #include "ui/events/latency_info.h" 14 #include "ui/events/latency_info.h"
14 #include "ui/events/mojo/event.mojom.h" 15 #include "ui/events/mojo/event.mojom.h"
15 16
16 using ui::mojom::EventResult; 17 using ui::mojom::EventResult;
17 18
18 namespace { 19 namespace {
19 20
20 void DoNothingWithEventResult(EventResult result) {} 21 void DoNothingWithEventResult(EventResult result) {}
21 22
23 gfx::Point GetScreenLocationFromEvent(const ui::LocatedEvent& event) {
24 return event.root_location();
25 }
26
22 } // namespace 27 } // namespace
23 28
24 namespace content { 29 namespace content {
25 30
26 CompositorMusConnection::CompositorMusConnection( 31 CompositorMusConnection::CompositorMusConnection(
27 int routing_id, 32 int routing_id,
28 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, 33 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
29 const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner, 34 const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner,
30 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request, 35 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request,
31 InputHandlerManager* input_handler_manager) 36 InputHandlerManager* input_handler_manager)
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 const ui::PointerEvent& event, 123 const ui::PointerEvent& event,
119 ui::Window* target) { 124 ui::Window* target) {
120 // Compositor does not use StartPointerWatcher(). 125 // Compositor does not use StartPointerWatcher().
121 } 126 }
122 127
123 void CompositorMusConnection::OnWindowInputEvent( 128 void CompositorMusConnection::OnWindowInputEvent(
124 ui::Window* window, 129 ui::Window* window,
125 const ui::Event& event, 130 const ui::Event& event,
126 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) { 131 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) {
127 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); 132 DCHECK(compositor_task_runner_->BelongsToCurrentThread());
128 std::unique_ptr<blink::WebInputEvent> web_event( 133 std::unique_ptr<blink::WebInputEvent> web_event(Convert(event));
129 mojo::TypeConverter<std::unique_ptr<blink::WebInputEvent>,
130 ui::Event>::Convert(event));
131 // TODO(sad): We probably need to plumb LatencyInfo through Mus. 134 // TODO(sad): We probably need to plumb LatencyInfo through Mus.
132 ui::LatencyInfo info; 135 ui::LatencyInfo info;
133 InputEventAckState ack_state = input_handler_manager_->HandleInputEvent( 136 InputEventAckState ack_state = input_handler_manager_->HandleInputEvent(
134 routing_id_, web_event.get(), &info); 137 routing_id_, web_event.get(), &info);
135 // TODO(jonross): We probably need to ack the event based on the consumed 138 // TODO(jonross): We probably need to ack the event based on the consumed
136 // state. 139 // state.
137 if (ack_state != INPUT_EVENT_ACK_STATE_NOT_CONSUMED) 140 if (ack_state != INPUT_EVENT_ACK_STATE_NOT_CONSUMED)
138 return; 141 return;
139 base::Callback<void(EventResult)> ack = 142 base::Callback<void(EventResult)> ack =
140 base::Bind(&::DoNothingWithEventResult); 143 base::Bind(&::DoNothingWithEventResult);
141 const bool send_ack = 144 const bool send_ack =
142 ui::WebInputEventTraits::ShouldBlockEventStream(*web_event); 145 ui::WebInputEventTraits::ShouldBlockEventStream(*web_event);
143 if (send_ack) { 146 if (send_ack) {
144 // Ultimately, this ACK needs to go back to the Mus client lib which is not 147 // Ultimately, this ACK needs to go back to the Mus client lib which is not
145 // thread-safe and lives on the compositor thread. For ACKs that are passed 148 // thread-safe and lives on the compositor thread. For ACKs that are passed
146 // to the main thread we pass them back to the compositor thread via 149 // to the main thread we pass them back to the compositor thread via
147 // OnWindowInputEventAckOnMainThread. 150 // OnWindowInputEventAckOnMainThread.
148 ack = 151 ack =
149 base::Bind(&CompositorMusConnection::OnWindowInputEventAckOnMainThread, 152 base::Bind(&CompositorMusConnection::OnWindowInputEventAckOnMainThread,
150 this, *ack_callback->get()); 153 this, *ack_callback->get());
151 ack_callback->reset(); 154 ack_callback->reset();
152 } 155 }
153 main_task_runner_->PostTask( 156 main_task_runner_->PostTask(
154 FROM_HERE, 157 FROM_HERE,
155 base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this, 158 base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this,
156 base::Passed(std::move(web_event)), ack)); 159 base::Passed(std::move(web_event)), ack));
157 } 160 }
158 161
162 std::unique_ptr<blink::WebInputEvent> CompositorMusConnection::Convert(
163 const ui::Event& event) {
164 if (event.IsMousePointerEvent()) {
165 const ui::MouseEvent mouse_event(*event.AsPointerEvent());
166 blink::WebMouseEvent blink_event = ui::MakeWebMouseEvent(
167 mouse_event, base::Bind(&GetScreenLocationFromEvent));
168 return base::WrapUnique(new blink::WebMouseEvent(blink_event));
sadrul 2016/08/26 02:37:02 Would "return base::MakeUnique<blink::WebMouseEven
jonross 2016/08/26 14:33:50 Done.
169 } else if (event.IsTouchPointerEvent()) {
170 ui::TouchEvent touch_event(*event.AsPointerEvent());
171 pointer_state_.OnTouch(touch_event);
172 blink::WebTouchEvent blink_event = ui::CreateWebTouchEventFromMotionEvent(
173 pointer_state_, touch_event.may_cause_scrolling());
174 pointer_state_.CleanupRemovedTouchPoints(touch_event);
175 return base::WrapUnique(new blink::WebTouchEvent(blink_event));
176 } else if (event.IsMouseWheelEvent()) {
177 blink::WebMouseWheelEvent blink_event = ui::MakeWebMouseWheelEvent(
178 *event.AsMouseWheelEvent(), base::Bind(&GetScreenLocationFromEvent));
179 return base::WrapUnique(new blink::WebMouseWheelEvent(blink_event));
sadrul 2016/08/26 02:37:02 We will be getting PointerEvents for wheel-events
jonross 2016/08/26 14:33:50 Added a comment on that review. I'll redo this sec
180 } else if (event.IsKeyEvent()) {
181 blink::WebKeyboardEvent blink_event =
182 ui::MakeWebKeyboardEvent(*event.AsKeyEvent());
183 return base::WrapUnique(new blink::WebKeyboardEvent(blink_event));
184 } else {
185 return nullptr;
186 }
sadrul 2016/08/26 02:37:02 This entire block doesn't need any else, since eac
jonross 2016/08/26 14:33:50 Done.
187 }
188
159 } // namespace content 189 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698