OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Portions based heavily on: | 5 // Portions based heavily on: |
6 // third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFactory.cpp | 6 // third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFactory.cpp |
7 // | 7 // |
8 /* | 8 /* |
9 * Copyright (C) 2006-2011 Google Inc. All rights reserved. | 9 * Copyright (C) 2006-2011 Google Inc. All rights reserved. |
10 * | 10 * |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 | 293 |
294 webkit_event.setKeyIdentifierFromWindowsKeyCode(); | 294 webkit_event.setKeyIdentifierFromWindowsKeyCode(); |
295 | 295 |
296 // TODO: IsAutoRepeat/IsKeyPad? | 296 // TODO: IsAutoRepeat/IsKeyPad? |
297 | 297 |
298 return webkit_event; | 298 return webkit_event; |
299 } | 299 } |
300 | 300 |
301 WebKit::WebGestureEvent MakeWebGestureEventFromAuraEvent( | 301 WebKit::WebGestureEvent MakeWebGestureEventFromAuraEvent( |
302 aura::GestureEvent* event) { | 302 aura::GestureEvent* event) { |
| 303 |
303 WebKit::WebGestureEvent gesture_event; | 304 WebKit::WebGestureEvent gesture_event; |
| 305 gesture_event.deltaX = event->delta_x(); |
| 306 gesture_event.deltaY = event->delta_y(); |
304 | 307 |
305 switch (event->type()) { | 308 switch (event->type()) { |
306 case ui::ET_GESTURE_TAP: | 309 case ui::ET_GESTURE_TAP: |
307 gesture_event.type = WebKit::WebInputEvent::GestureTap; | 310 gesture_event.type = WebKit::WebInputEvent::GestureTap; |
308 break; | 311 break; |
309 case ui::ET_GESTURE_TAP_DOWN: | 312 case ui::ET_GESTURE_TAP_DOWN: |
310 gesture_event.type = WebKit::WebInputEvent::GestureTapDown; | 313 gesture_event.type = WebKit::WebInputEvent::GestureTapDown; |
311 break; | 314 break; |
312 case ui::ET_GESTURE_DOUBLE_TAP: | 315 case ui::ET_GESTURE_DOUBLE_TAP: |
313 gesture_event.type = WebKit::WebInputEvent::GestureDoubleTap; | 316 gesture_event.type = WebKit::WebInputEvent::GestureDoubleTap; |
314 break; | 317 break; |
315 case ui::ET_GESTURE_SCROLL_BEGIN: | 318 case ui::ET_GESTURE_SCROLL_BEGIN: |
316 gesture_event.type = WebKit::WebInputEvent::GestureScrollBegin; | 319 gesture_event.type = WebKit::WebInputEvent::GestureScrollBegin; |
317 break; | 320 break; |
318 case ui::ET_GESTURE_SCROLL_UPDATE: | 321 case ui::ET_GESTURE_SCROLL_UPDATE: |
319 gesture_event.type = WebKit::WebInputEvent::GestureScrollUpdate; | 322 gesture_event.type = WebKit::WebInputEvent::GestureScrollUpdate; |
320 break; | 323 break; |
321 case ui::ET_GESTURE_SCROLL_END: | 324 case ui::ET_GESTURE_SCROLL_END: |
322 gesture_event.type = WebKit::WebInputEvent::GestureScrollEnd; | 325 gesture_event.type = WebKit::WebInputEvent::GestureScrollEnd; |
323 break; | 326 break; |
324 case ui::ET_GESTURE_PINCH_BEGIN: | 327 case ui::ET_GESTURE_PINCH_BEGIN: |
325 gesture_event.type = WebKit::WebInputEvent::GesturePinchBegin; | 328 gesture_event.type = WebKit::WebInputEvent::GesturePinchBegin; |
| 329 gesture_event.deltaX = event->scale_x(); |
| 330 gesture_event.deltaY = event->scale_y(); |
326 break; | 331 break; |
327 case ui::ET_GESTURE_PINCH_UPDATE: | 332 case ui::ET_GESTURE_PINCH_UPDATE: |
328 gesture_event.type = WebKit::WebInputEvent::GesturePinchUpdate; | 333 gesture_event.type = WebKit::WebInputEvent::GesturePinchUpdate; |
| 334 gesture_event.deltaX = event->scale_x(); |
| 335 gesture_event.deltaY = event->scale_y(); |
329 break; | 336 break; |
330 case ui::ET_GESTURE_PINCH_END: | 337 case ui::ET_GESTURE_PINCH_END: |
331 gesture_event.type = WebKit::WebInputEvent::GesturePinchEnd; | 338 gesture_event.type = WebKit::WebInputEvent::GesturePinchEnd; |
| 339 gesture_event.deltaX = event->scale_x(); |
| 340 gesture_event.deltaY = event->scale_y(); |
332 break; | 341 break; |
333 case ui::ET_GESTURE_LONG_PRESS: | 342 case ui::ET_GESTURE_LONG_PRESS: |
334 // TODO(tdresser): Integrate long press with WebKit | 343 // TODO(tdresser): Integrate long press with WebKit |
335 break; | 344 break; |
336 default: | 345 default: |
337 NOTREACHED() << "Unknown gesture type: " << event->type(); | 346 NOTREACHED() << "Unknown gesture type: " << event->type(); |
338 } | 347 } |
339 | 348 |
340 gesture_event.deltaX = event->delta_x(); | |
341 gesture_event.deltaY = event->delta_y(); | |
342 gesture_event.modifiers = EventFlagsToWebEventModifiers(event->flags()); | |
343 | |
344 return gesture_event; | 349 return gesture_event; |
345 } | 350 } |
346 | 351 |
347 WebKit::WebTouchPoint* UpdateWebTouchEventFromAuraEvent( | 352 WebKit::WebTouchPoint* UpdateWebTouchEventFromAuraEvent( |
348 aura::TouchEvent* event, WebKit::WebTouchEvent* web_event) { | 353 aura::TouchEvent* event, WebKit::WebTouchEvent* web_event) { |
349 WebKit::WebTouchPoint* point = NULL; | 354 WebKit::WebTouchPoint* point = NULL; |
350 switch (event->type()) { | 355 switch (event->type()) { |
351 case ui::ET_TOUCH_PRESSED: | 356 case ui::ET_TOUCH_PRESSED: |
352 // Add a new touch point. | 357 // Add a new touch point. |
353 if (web_event->touchesLength < WebKit::WebTouchEvent::touchesLengthCap) { | 358 if (web_event->touchesLength < WebKit::WebTouchEvent::touchesLengthCap) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 | 413 |
409 // Update the type of the touch event. | 414 // Update the type of the touch event. |
410 web_event->type = TouchEventTypeFromEvent(event); | 415 web_event->type = TouchEventTypeFromEvent(event); |
411 web_event->timeStampSeconds = event->time_stamp().InSecondsF(); | 416 web_event->timeStampSeconds = event->time_stamp().InSecondsF(); |
412 web_event->modifiers = EventFlagsToWebEventModifiers(event->flags()); | 417 web_event->modifiers = EventFlagsToWebEventModifiers(event->flags()); |
413 | 418 |
414 return point; | 419 return point; |
415 } | 420 } |
416 | 421 |
417 } // namespace content | 422 } // namespace content |
OLD | NEW |