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 "ui/events/blink/web_input_event.h" | 5 #include "ui/events/blink/web_input_event.h" |
6 | 6 |
7 #include "ui/events/base_event_utils.h" | 7 #include "ui/events/base_event_utils.h" |
8 #include "ui/events/blink/blink_event_util.h" | 8 #include "ui/events/blink/blink_event_util.h" |
9 #include "ui/events/blink/blink_features.h" | 9 #include "ui/events/blink/blink_features.h" |
10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 ? MakeUntranslatedWebMouseEventFromNativeEvent( | 228 ? MakeUntranslatedWebMouseEventFromNativeEvent( |
229 event.native_event(), event.time_stamp(), | 229 event.native_event(), event.time_stamp(), |
230 EventPointerTypeToWebPointerType( | 230 EventPointerTypeToWebPointerType( |
231 event.pointer_details().pointer_type)) | 231 event.pointer_details().pointer_type)) |
232 : MakeWebMouseEventFromUiEvent(event); | 232 : MakeWebMouseEventFromUiEvent(event); |
233 #else | 233 #else |
234 MakeWebMouseEventFromUiEvent(event); | 234 MakeWebMouseEventFromUiEvent(event); |
235 #endif | 235 #endif |
236 // Replace the event's coordinate fields with translated position data from | 236 // Replace the event's coordinate fields with translated position data from |
237 // |event|. | 237 // |event|. |
238 webkit_event.x = event.x(); | 238 webkit_event.position.x = event.x(); |
239 webkit_event.y = event.y(); | 239 webkit_event.position.y = event.y(); |
240 | 240 |
241 #if defined(OS_WIN) | 241 #if defined(OS_WIN) |
242 if (event.native_event().message) | 242 if (event.native_event().message) |
243 return webkit_event; | 243 return webkit_event; |
244 #endif | 244 #endif |
245 | 245 |
246 const gfx::Point screen_point = | 246 const gfx::Point screen_point = |
247 GetScreenLocationFromEvent(event, screen_location_callback); | 247 GetScreenLocationFromEvent(event, screen_location_callback); |
248 webkit_event.globalX = screen_point.x(); | 248 webkit_event.screenPosition.x = screen_point.x(); |
249 webkit_event.globalY = screen_point.y(); | 249 webkit_event.screenPosition.y = screen_point.y(); |
250 | 250 |
251 return webkit_event; | 251 return webkit_event; |
252 } | 252 } |
253 | 253 |
254 blink::WebMouseWheelEvent MakeWebMouseWheelEvent( | 254 blink::WebMouseWheelEvent MakeWebMouseWheelEvent( |
255 const MouseWheelEvent& event, | 255 const MouseWheelEvent& event, |
256 const base::Callback<gfx::Point(const LocatedEvent& event)>& | 256 const base::Callback<gfx::Point(const LocatedEvent& event)>& |
257 screen_location_callback) { | 257 screen_location_callback) { |
258 #if defined(OS_WIN) | 258 #if defined(OS_WIN) |
259 // Construct an untranslated event from the platform event data. | 259 // Construct an untranslated event from the platform event data. |
260 blink::WebMouseWheelEvent webkit_event = | 260 blink::WebMouseWheelEvent webkit_event = |
261 event.native_event().message | 261 event.native_event().message |
262 ? MakeUntranslatedWebMouseWheelEventFromNativeEvent( | 262 ? MakeUntranslatedWebMouseWheelEventFromNativeEvent( |
263 event.native_event(), event.time_stamp(), | 263 event.native_event(), event.time_stamp(), |
264 EventPointerTypeToWebPointerType( | 264 EventPointerTypeToWebPointerType( |
265 event.pointer_details().pointer_type)) | 265 event.pointer_details().pointer_type)) |
266 : MakeWebMouseWheelEventFromUiEvent(event); | 266 : MakeWebMouseWheelEventFromUiEvent(event); |
267 #else | 267 #else |
268 blink::WebMouseWheelEvent webkit_event = | 268 blink::WebMouseWheelEvent webkit_event = |
269 MakeWebMouseWheelEventFromUiEvent(event); | 269 MakeWebMouseWheelEventFromUiEvent(event); |
270 #endif | 270 #endif |
271 | 271 |
272 // Replace the event's coordinate fields with translated position data from | 272 // Replace the event's coordinate fields with translated position data from |
273 // |event|. | 273 // |event|. |
274 webkit_event.x = event.x(); | 274 webkit_event.position.x = event.x(); |
275 webkit_event.y = event.y(); | 275 webkit_event.position.y = event.y(); |
276 | 276 |
277 const gfx::Point screen_point = | 277 const gfx::Point screen_point = |
278 GetScreenLocationFromEvent(event, screen_location_callback); | 278 GetScreenLocationFromEvent(event, screen_location_callback); |
279 webkit_event.globalX = screen_point.x(); | 279 webkit_event.screenPosition.x = screen_point.x(); |
280 webkit_event.globalY = screen_point.y(); | 280 webkit_event.screenPosition.y = screen_point.y(); |
281 | 281 |
282 return webkit_event; | 282 return webkit_event; |
283 } | 283 } |
284 | 284 |
285 blink::WebMouseWheelEvent MakeWebMouseWheelEvent( | 285 blink::WebMouseWheelEvent MakeWebMouseWheelEvent( |
286 const ScrollEvent& event, | 286 const ScrollEvent& event, |
287 const base::Callback<gfx::Point(const LocatedEvent& event)>& | 287 const base::Callback<gfx::Point(const LocatedEvent& event)>& |
288 screen_location_callback) { | 288 screen_location_callback) { |
289 #if defined(OS_WIN) | 289 #if defined(OS_WIN) |
290 // Construct an untranslated event from the platform event data. | 290 // Construct an untranslated event from the platform event data. |
291 blink::WebMouseWheelEvent webkit_event = | 291 blink::WebMouseWheelEvent webkit_event = |
292 event.native_event().message | 292 event.native_event().message |
293 ? MakeUntranslatedWebMouseWheelEventFromNativeEvent( | 293 ? MakeUntranslatedWebMouseWheelEventFromNativeEvent( |
294 event.native_event(), event.time_stamp(), | 294 event.native_event(), event.time_stamp(), |
295 EventPointerTypeToWebPointerType( | 295 EventPointerTypeToWebPointerType( |
296 event.pointer_details().pointer_type)) | 296 event.pointer_details().pointer_type)) |
297 : MakeWebMouseWheelEventFromUiEvent(event); | 297 : MakeWebMouseWheelEventFromUiEvent(event); |
298 #else | 298 #else |
299 blink::WebMouseWheelEvent webkit_event = | 299 blink::WebMouseWheelEvent webkit_event = |
300 MakeWebMouseWheelEventFromUiEvent(event); | 300 MakeWebMouseWheelEventFromUiEvent(event); |
301 #endif | 301 #endif |
302 | 302 |
303 // Replace the event's coordinate fields with translated position data from | 303 // Replace the event's coordinate fields with translated position data from |
304 // |event|. | 304 // |event|. |
305 webkit_event.x = event.x(); | 305 webkit_event.position.x = event.x(); |
306 webkit_event.y = event.y(); | 306 webkit_event.position.y = event.y(); |
307 | 307 |
308 const gfx::Point screen_point = | 308 const gfx::Point screen_point = |
309 GetScreenLocationFromEvent(event, screen_location_callback); | 309 GetScreenLocationFromEvent(event, screen_location_callback); |
310 webkit_event.globalX = screen_point.x(); | 310 webkit_event.screenPosition.x = screen_point.x(); |
311 webkit_event.globalY = screen_point.y(); | 311 webkit_event.screenPosition.y = screen_point.y(); |
312 | 312 |
313 return webkit_event; | 313 return webkit_event; |
314 } | 314 } |
315 | 315 |
316 blink::WebKeyboardEvent MakeWebKeyboardEvent(const KeyEvent& event) { | 316 blink::WebKeyboardEvent MakeWebKeyboardEvent(const KeyEvent& event) { |
317 // Windows can figure out whether or not to construct a RawKeyDown or a Char | 317 // Windows can figure out whether or not to construct a RawKeyDown or a Char |
318 // WebInputEvent based on the type of message carried in | 318 // WebInputEvent based on the type of message carried in |
319 // event.native_event(). X11 is not so fortunate, there is no separate | 319 // event.native_event(). X11 is not so fortunate, there is no separate |
320 // translated event type, so DesktopHostLinux sends an extra KeyEvent with | 320 // translated event type, so DesktopHostLinux sends an extra KeyEvent with |
321 // is_char() == true. We need to pass the KeyEvent to the X11 function | 321 // is_char() == true. We need to pass the KeyEvent to the X11 function |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 webkit_event.tiltX = roundf(event.pointer_details().tilt_x); | 470 webkit_event.tiltX = roundf(event.pointer_details().tilt_x); |
471 webkit_event.tiltY = roundf(event.pointer_details().tilt_y); | 471 webkit_event.tiltY = roundf(event.pointer_details().tilt_y); |
472 webkit_event.force = event.pointer_details().force; | 472 webkit_event.force = event.pointer_details().force; |
473 webkit_event.pointerType = | 473 webkit_event.pointerType = |
474 EventPointerTypeToWebPointerType(event.pointer_details().pointer_type); | 474 EventPointerTypeToWebPointerType(event.pointer_details().pointer_type); |
475 | 475 |
476 return webkit_event; | 476 return webkit_event; |
477 } | 477 } |
478 | 478 |
479 } // namespace ui | 479 } // namespace ui |
OLD | NEW |