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