OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "core/frame/VisualViewport.h" | 43 #include "core/frame/VisualViewport.h" |
44 #include "core/layout/LayoutObject.h" | 44 #include "core/layout/LayoutObject.h" |
45 #include "core/page/ChromeClient.h" | 45 #include "core/page/ChromeClient.h" |
46 #include "core/page/Page.h" | 46 #include "core/page/Page.h" |
47 #include "platform/KeyboardCodes.h" | 47 #include "platform/KeyboardCodes.h" |
48 #include "platform/Widget.h" | 48 #include "platform/Widget.h" |
49 #include "public/platform/Platform.h" | 49 #include "public/platform/Platform.h" |
50 | 50 |
51 namespace blink { | 51 namespace blink { |
52 | 52 |
53 static const double millisPerSecond = 1000.0; | |
54 | |
55 static float scaleDeltaToWindow(const Widget* widget, float delta) | 53 static float scaleDeltaToWindow(const Widget* widget, float delta) |
56 { | 54 { |
57 float scale = 1; | 55 float scale = 1; |
58 if (widget) { | 56 if (widget) { |
59 FrameView* rootView = toFrameView(widget->root()); | 57 FrameView* rootView = toFrameView(widget->root()); |
60 if (rootView) | 58 if (rootView) |
61 scale = rootView->inputEventsScaleFactor(); | 59 scale = rootView->inputEventsScaleFactor(); |
62 } | 60 } |
63 return delta / scale; | 61 return delta / scale; |
64 } | 62 } |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 m_text = String(e.text); | 311 m_text = String(e.text); |
314 m_unmodifiedText = String(e.unmodifiedText); | 312 m_unmodifiedText = String(e.unmodifiedText); |
315 m_keyIdentifier = String(e.keyIdentifier); | 313 m_keyIdentifier = String(e.keyIdentifier); |
316 m_nativeVirtualKeyCode = e.nativeKeyCode; | 314 m_nativeVirtualKeyCode = e.nativeKeyCode; |
317 m_isSystemKey = e.isSystemKey; | 315 m_isSystemKey = e.isSystemKey; |
318 // TODO: BUG482880 Fix this initialization to lazy initialization. | 316 // TODO: BUG482880 Fix this initialization to lazy initialization. |
319 m_code = Platform::current()->domCodeStringFromEnum(e.domCode); | 317 m_code = Platform::current()->domCodeStringFromEnum(e.domCode); |
320 m_key = Platform::current()->domKeyStringFromEnum(e.domKey); | 318 m_key = Platform::current()->domKeyStringFromEnum(e.domKey); |
321 | 319 |
322 m_modifiers = toPlatformKeyboardEventModifiers(e.modifiers); | 320 m_modifiers = toPlatformKeyboardEventModifiers(e.modifiers); |
| 321 m_timestamp = e.timeStampSeconds; |
323 | 322 |
324 // FIXME: PlatformKeyboardEvents expect a locational version of the keycode
(e.g. VK_LSHIFT | 323 // FIXME: PlatformKeyboardEvents expect a locational version of the keycode
(e.g. VK_LSHIFT |
325 // instead of VK_SHIFT). This should be changed so the location/keycode are
stored separately, | 324 // instead of VK_SHIFT). This should be changed so the location/keycode are
stored separately, |
326 // as in other places in the code. | 325 // as in other places in the code. |
327 m_windowsVirtualKeyCode = e.windowsKeyCode; | 326 m_windowsVirtualKeyCode = e.windowsKeyCode; |
328 if (e.windowsKeyCode == VK_SHIFT) { | 327 if (e.windowsKeyCode == VK_SHIFT) { |
329 if (e.modifiers & WebInputEvent::IsLeft) | 328 if (e.modifiers & WebInputEvent::IsLeft) |
330 m_windowsVirtualKeyCode = VK_LSHIFT; | 329 m_windowsVirtualKeyCode = VK_LSHIFT; |
331 else if (e.modifiers & WebInputEvent::IsRight) | 330 else if (e.modifiers & WebInputEvent::IsRight) |
332 m_windowsVirtualKeyCode = VK_RSHIFT; | 331 m_windowsVirtualKeyCode = VK_RSHIFT; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 472 |
474 static IntPoint convertAbsoluteLocationForLayoutObject(const LayoutPoint& locati
on, const LayoutObject& layoutObject) | 473 static IntPoint convertAbsoluteLocationForLayoutObject(const LayoutPoint& locati
on, const LayoutObject& layoutObject) |
475 { | 474 { |
476 return roundedIntPoint(convertAbsoluteLocationForLayoutObjectFloat(location,
layoutObject)); | 475 return roundedIntPoint(convertAbsoluteLocationForLayoutObjectFloat(location,
layoutObject)); |
477 } | 476 } |
478 | 477 |
479 // FIXME: Change |widget| to const Widget& after RemoteFrames get | 478 // FIXME: Change |widget| to const Widget& after RemoteFrames get |
480 // RemoteFrameViews. | 479 // RemoteFrameViews. |
481 static void updateWebMouseEventFromCoreMouseEvent(const MouseRelatedEvent& event
, const Widget* widget, const LayoutObject& layoutObject, WebMouseEvent& webEven
t) | 480 static void updateWebMouseEventFromCoreMouseEvent(const MouseRelatedEvent& event
, const Widget* widget, const LayoutObject& layoutObject, WebMouseEvent& webEven
t) |
482 { | 481 { |
483 webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond; | 482 webEvent.timeStampSeconds = event.timeStampForPlatformInSeconds(); |
484 webEvent.modifiers = getWebInputModifiers(event); | 483 webEvent.modifiers = getWebInputModifiers(event); |
485 | 484 |
486 FrameView* view = widget ? toFrameView(widget->parent()) : 0; | 485 FrameView* view = widget ? toFrameView(widget->parent()) : 0; |
487 // FIXME: If view == nullptr, pointInRootFrame will really be pointInRootCon
tent. | 486 // FIXME: If view == nullptr, pointInRootFrame will really be pointInRootCon
tent. |
488 IntPoint pointInRootFrame = IntPoint(event.absoluteLocation().x(), event.abs
oluteLocation().y()); | 487 IntPoint pointInRootFrame = IntPoint(event.absoluteLocation().x(), event.abs
oluteLocation().y()); |
489 if (view) | 488 if (view) |
490 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); | 489 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); |
491 webEvent.globalX = event.screenX(); | 490 webEvent.globalX = event.screenX(); |
492 webEvent.globalY = event.screenY(); | 491 webEvent.globalY = event.screenY(); |
493 webEvent.windowX = pointInRootFrame.x(); | 492 webEvent.windowX = pointInRootFrame.x(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 | 562 |
564 if (event.type() == EventTypeNames::touchstart) | 563 if (event.type() == EventTypeNames::touchstart) |
565 type = MouseDown; | 564 type = MouseDown; |
566 else if (event.type() == EventTypeNames::touchmove) | 565 else if (event.type() == EventTypeNames::touchmove) |
567 type = MouseMove; | 566 type = MouseMove; |
568 else if (event.type() == EventTypeNames::touchend) | 567 else if (event.type() == EventTypeNames::touchend) |
569 type = MouseUp; | 568 type = MouseUp; |
570 else | 569 else |
571 return; | 570 return; |
572 | 571 |
573 timeStampSeconds = event.timeStamp() / millisPerSecond; | 572 timeStampSeconds = event.timeStampForPlatformInSeconds(); |
574 modifiers = getWebInputModifiers(event); | 573 modifiers = getWebInputModifiers(event); |
575 | 574 |
576 // The mouse event co-ordinates should be generated from the co-ordinates of
the touch point. | 575 // The mouse event co-ordinates should be generated from the co-ordinates of
the touch point. |
577 FrameView* view = toFrameView(widget->parent()); | 576 FrameView* view = toFrameView(widget->parent()); |
578 // FIXME: if view == nullptr, pointInRootFrame will really be pointInRootCon
tent. | 577 // FIXME: if view == nullptr, pointInRootFrame will really be pointInRootCon
tent. |
579 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation()); | 578 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation()); |
580 if (view) | 579 if (view) |
581 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); | 580 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); |
582 IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); | 581 IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); |
583 globalX = screenPoint.x(); | 582 globalX = screenPoint.x(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 return; // Skip all other keyboard events. | 620 return; // Skip all other keyboard events. |
622 | 621 |
623 modifiers = getWebInputModifiers(event); | 622 modifiers = getWebInputModifiers(event); |
624 if (event.location() == KeyboardEvent::DOM_KEY_LOCATION_NUMPAD) | 623 if (event.location() == KeyboardEvent::DOM_KEY_LOCATION_NUMPAD) |
625 modifiers |= WebInputEvent::IsKeyPad; | 624 modifiers |= WebInputEvent::IsKeyPad; |
626 else if (event.location() == KeyboardEvent::DOM_KEY_LOCATION_LEFT) | 625 else if (event.location() == KeyboardEvent::DOM_KEY_LOCATION_LEFT) |
627 modifiers |= WebInputEvent::IsLeft; | 626 modifiers |= WebInputEvent::IsLeft; |
628 else if (event.location() == KeyboardEvent::DOM_KEY_LOCATION_RIGHT) | 627 else if (event.location() == KeyboardEvent::DOM_KEY_LOCATION_RIGHT) |
629 modifiers |= WebInputEvent::IsRight; | 628 modifiers |= WebInputEvent::IsRight; |
630 | 629 |
631 timeStampSeconds = event.timeStamp() / millisPerSecond; | 630 timeStampSeconds = event.timeStampForPlatformInSeconds(); |
632 windowsKeyCode = event.keyCode(); | 631 windowsKeyCode = event.keyCode(); |
633 | 632 |
634 // The platform keyevent does not exist if the event was created using | 633 // The platform keyevent does not exist if the event was created using |
635 // initKeyboardEvent. | 634 // initKeyboardEvent. |
636 if (!event.keyEvent()) | 635 if (!event.keyEvent()) |
637 return; | 636 return; |
638 nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode(); | 637 nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode(); |
639 domCode = Platform::current()->domEnumFromCodeString(event.keyEvent()->code(
)); | 638 domCode = Platform::current()->domEnumFromCodeString(event.keyEvent()->code(
)); |
640 domKey = Platform::current()->domKeyEnumFromString(event.keyEvent()->key()); | 639 domKey = Platform::current()->domKeyEnumFromString(event.keyEvent()->key()); |
641 unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), st
atic_cast<unsigned>(textLengthCap)); | 640 unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), st
atic_cast<unsigned>(textLengthCap)); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 type = TouchEnd; | 713 type = TouchEnd; |
715 else if (event.type() == EventTypeNames::touchcancel) | 714 else if (event.type() == EventTypeNames::touchcancel) |
716 type = TouchCancel; | 715 type = TouchCancel; |
717 else { | 716 else { |
718 ASSERT_NOT_REACHED(); | 717 ASSERT_NOT_REACHED(); |
719 type = Undefined; | 718 type = Undefined; |
720 return; | 719 return; |
721 } | 720 } |
722 | 721 |
723 modifiers = getWebInputModifiers(event); | 722 modifiers = getWebInputModifiers(event); |
724 timeStampSeconds = event.timeStamp() / millisPerSecond; | 723 timeStampSeconds = event.timeStampForPlatformInSeconds(); |
725 cancelable = event.cancelable(); | 724 cancelable = event.cancelable(); |
726 causesScrollingIfUncanceled = event.causesScrollingIfUncanceled(); | 725 causesScrollingIfUncanceled = event.causesScrollingIfUncanceled(); |
727 | 726 |
728 // Currently touches[] is empty, add stationary points as-is. | 727 // Currently touches[] is empty, add stationary points as-is. |
729 for (unsigned i = 0; i < event.touches()->length() && i < static_cast<unsign
ed>(WebTouchEvent::touchesLengthCap); ++i) { | 728 for (unsigned i = 0; i < event.touches()->length() && i < static_cast<unsign
ed>(WebTouchEvent::touchesLengthCap); ++i) { |
730 touches[i] = toWebTouchPoint(event.touches()->item(i), layoutObject, Web
TouchPoint::StateStationary); | 729 touches[i] = toWebTouchPoint(event.touches()->item(i), layoutObject, Web
TouchPoint::StateStationary); |
731 ++touchesLength; | 730 ++touchesLength; |
732 } | 731 } |
733 // If any existing points are also in the change list, we should update | 732 // If any existing points are also in the change list, we should update |
734 // their state, otherwise just add the new points. | 733 // their state, otherwise just add the new points. |
(...skipping 14 matching lines...) Expand all Loading... |
749 type = GestureScrollEnd; | 748 type = GestureScrollEnd; |
750 else if (event.type() == EventTypeNames::gesturescrollupdate) { | 749 else if (event.type() == EventTypeNames::gesturescrollupdate) { |
751 type = GestureScrollUpdate; | 750 type = GestureScrollUpdate; |
752 data.scrollUpdate.deltaX = event.deltaX(); | 751 data.scrollUpdate.deltaX = event.deltaX(); |
753 data.scrollUpdate.deltaY = event.deltaY(); | 752 data.scrollUpdate.deltaY = event.deltaY(); |
754 } else if (event.type() == EventTypeNames::gesturetap) { | 753 } else if (event.type() == EventTypeNames::gesturetap) { |
755 type = GestureTap; | 754 type = GestureTap; |
756 data.tap.tapCount = 1; | 755 data.tap.tapCount = 1; |
757 } | 756 } |
758 | 757 |
759 timeStampSeconds = event.timeStamp() / millisPerSecond; | 758 timeStampSeconds = event.timeStampForPlatformInSeconds(); |
760 modifiers = getWebInputModifiers(event); | 759 modifiers = getWebInputModifiers(event); |
761 | 760 |
762 globalX = event.screenX(); | 761 globalX = event.screenX(); |
763 globalY = event.screenY(); | 762 globalY = event.screenY(); |
764 IntPoint localPoint = convertAbsoluteLocationForLayoutObject(event.absoluteL
ocation(), *layoutObject); | 763 IntPoint localPoint = convertAbsoluteLocationForLayoutObject(event.absoluteL
ocation(), *layoutObject); |
765 x = localPoint.x(); | 764 x = localPoint.x(); |
766 y = localPoint.y(); | 765 y = localPoint.y(); |
767 } | 766 } |
768 | 767 |
769 } // namespace blink | 768 } // namespace blink |
OLD | NEW |