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 27 matching lines...) Expand all Loading... |
38 #include "core/events/MouseEvent.h" | 38 #include "core/events/MouseEvent.h" |
39 #include "core/events/TouchEvent.h" | 39 #include "core/events/TouchEvent.h" |
40 #include "core/events/WheelEvent.h" | 40 #include "core/events/WheelEvent.h" |
41 #include "core/frame/FrameHost.h" | 41 #include "core/frame/FrameHost.h" |
42 #include "core/frame/FrameView.h" | 42 #include "core/frame/FrameView.h" |
43 #include "core/frame/PinchViewport.h" | 43 #include "core/frame/PinchViewport.h" |
44 #include "core/page/Page.h" | 44 #include "core/page/Page.h" |
45 #include "core/rendering/RenderObject.h" | 45 #include "core/rendering/RenderObject.h" |
46 #include "platform/KeyboardCodes.h" | 46 #include "platform/KeyboardCodes.h" |
47 #include "platform/Widget.h" | 47 #include "platform/Widget.h" |
| 48 #include "public/platform/Platform.h" |
48 | 49 |
49 namespace blink { | 50 namespace blink { |
50 | 51 |
51 static const double millisPerSecond = 1000.0; | 52 static const double millisPerSecond = 1000.0; |
52 | 53 |
53 static float scaleDeltaToWindow(const Widget* widget, float delta) | 54 static float scaleDeltaToWindow(const Widget* widget, float delta) |
54 { | 55 { |
55 float scale = 1; | 56 float scale = 1; |
56 if (widget) { | 57 if (widget) { |
57 FrameView* rootView = toFrameView(widget->root()); | 58 FrameView* rootView = toFrameView(widget->root()); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder(const WebKeyboardEven
t& e) | 309 PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder(const WebKeyboardEven
t& e) |
309 { | 310 { |
310 m_type = toPlatformKeyboardEventType(e.type); | 311 m_type = toPlatformKeyboardEventType(e.type); |
311 m_text = String(e.text); | 312 m_text = String(e.text); |
312 m_unmodifiedText = String(e.unmodifiedText); | 313 m_unmodifiedText = String(e.unmodifiedText); |
313 m_keyIdentifier = String(e.keyIdentifier); | 314 m_keyIdentifier = String(e.keyIdentifier); |
314 m_autoRepeat = (e.modifiers & WebInputEvent::IsAutoRepeat); | 315 m_autoRepeat = (e.modifiers & WebInputEvent::IsAutoRepeat); |
315 m_nativeVirtualKeyCode = e.nativeKeyCode; | 316 m_nativeVirtualKeyCode = e.nativeKeyCode; |
316 m_isKeypad = (e.modifiers & WebInputEvent::IsKeyPad); | 317 m_isKeypad = (e.modifiers & WebInputEvent::IsKeyPad); |
317 m_isSystemKey = e.isSystemKey; | 318 m_isSystemKey = e.isSystemKey; |
| 319 m_code = Platform::current()->domCodeStringFromEnum(e.domCode); |
318 | 320 |
319 m_modifiers = toPlatformEventModifiers(e.modifiers); | 321 m_modifiers = toPlatformEventModifiers(e.modifiers); |
320 | 322 |
321 // 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 |
322 // 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, |
323 // as in other places in the code. | 325 // as in other places in the code. |
324 m_windowsVirtualKeyCode = e.windowsKeyCode; | 326 m_windowsVirtualKeyCode = e.windowsKeyCode; |
325 if (e.windowsKeyCode == VK_SHIFT) { | 327 if (e.windowsKeyCode == VK_SHIFT) { |
326 if (e.modifiers & WebInputEvent::IsLeft) | 328 if (e.modifiers & WebInputEvent::IsLeft) |
327 m_windowsVirtualKeyCode = VK_LSHIFT; | 329 m_windowsVirtualKeyCode = VK_LSHIFT; |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 modifiers |= WebInputEvent::IsRight; | 667 modifiers |= WebInputEvent::IsRight; |
666 | 668 |
667 timeStampSeconds = event.timeStamp() / millisPerSecond; | 669 timeStampSeconds = event.timeStamp() / millisPerSecond; |
668 windowsKeyCode = event.keyCode(); | 670 windowsKeyCode = event.keyCode(); |
669 | 671 |
670 // The platform keyevent does not exist if the event was created using | 672 // The platform keyevent does not exist if the event was created using |
671 // initKeyboardEvent. | 673 // initKeyboardEvent. |
672 if (!event.keyEvent()) | 674 if (!event.keyEvent()) |
673 return; | 675 return; |
674 nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode(); | 676 nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode(); |
| 677 domCode = Platform::current()->domEnumFromCodeString(event.keyEvent()->code(
)); |
675 unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), st
atic_cast<unsigned>(textLengthCap)); | 678 unsigned numberOfCharacters = std::min(event.keyEvent()->text().length(), st
atic_cast<unsigned>(textLengthCap)); |
676 for (unsigned i = 0; i < numberOfCharacters; ++i) { | 679 for (unsigned i = 0; i < numberOfCharacters; ++i) { |
677 text[i] = event.keyEvent()->text()[i]; | 680 text[i] = event.keyEvent()->text()[i]; |
678 unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i]; | 681 unmodifiedText[i] = event.keyEvent()->unmodifiedText()[i]; |
679 } | 682 } |
680 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), event.keyIdentif
ier().length()); | 683 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), event.keyIdentif
ier().length()); |
681 } | 684 } |
682 | 685 |
683 WebInputEvent::Type toWebKeyboardEventType(PlatformEvent::Type type) | 686 WebInputEvent::Type toWebKeyboardEventType(PlatformEvent::Type type) |
684 { | 687 { |
(...skipping 14 matching lines...) Expand all Loading... |
699 WebKeyboardEventBuilder::WebKeyboardEventBuilder(const PlatformKeyboardEvent& ev
ent) | 702 WebKeyboardEventBuilder::WebKeyboardEventBuilder(const PlatformKeyboardEvent& ev
ent) |
700 { | 703 { |
701 type = toWebKeyboardEventType(event.type()); | 704 type = toWebKeyboardEventType(event.type()); |
702 modifiers = toWebEventModifiers(event.modifiers()); | 705 modifiers = toWebEventModifiers(event.modifiers()); |
703 if (event.isAutoRepeat()) | 706 if (event.isAutoRepeat()) |
704 modifiers |= WebInputEvent::IsAutoRepeat; | 707 modifiers |= WebInputEvent::IsAutoRepeat; |
705 if (event.isKeypad()) | 708 if (event.isKeypad()) |
706 modifiers |= WebInputEvent::IsKeyPad; | 709 modifiers |= WebInputEvent::IsKeyPad; |
707 isSystemKey = event.isSystemKey(); | 710 isSystemKey = event.isSystemKey(); |
708 nativeKeyCode = event.nativeVirtualKeyCode(); | 711 nativeKeyCode = event.nativeVirtualKeyCode(); |
| 712 domCode = Platform::current()->domEnumFromCodeString(event.code()); |
709 | 713 |
710 windowsKeyCode = windowsKeyCodeWithoutLocation(event.windowsVirtualKeyCode()
); | 714 windowsKeyCode = windowsKeyCodeWithoutLocation(event.windowsVirtualKeyCode()
); |
711 modifiers |= locationModifiersFromWindowsKeyCode(event.windowsVirtualKeyCode
()); | 715 modifiers |= locationModifiersFromWindowsKeyCode(event.windowsVirtualKeyCode
()); |
712 | 716 |
713 event.text().copyTo(text, 0, textLengthCap); | 717 event.text().copyTo(text, 0, textLengthCap); |
714 event.unmodifiedText().copyTo(unmodifiedText, 0, textLengthCap); | 718 event.unmodifiedText().copyTo(unmodifiedText, 0, textLengthCap); |
715 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), std::min(static_
cast<unsigned>(keyIdentifierLengthCap), event.keyIdentifier().length())); | 719 memcpy(keyIdentifier, event.keyIdentifier().ascii().data(), std::min(static_
cast<unsigned>(keyIdentifierLengthCap), event.keyIdentifier().length())); |
716 } | 720 } |
717 | 721 |
718 static WebTouchPoint toWebTouchPoint(const Touch* touch, const RenderObject* ren
derObject, WebTouchPoint::State state) | 722 static WebTouchPoint toWebTouchPoint(const Touch* touch, const RenderObject* ren
derObject, WebTouchPoint::State state) |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 modifiers = getWebInputModifiers(event); | 806 modifiers = getWebInputModifiers(event); |
803 | 807 |
804 globalX = event.screenX(); | 808 globalX = event.screenX(); |
805 globalY = event.screenY(); | 809 globalY = event.screenY(); |
806 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); | 810 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); |
807 x = localPoint.x(); | 811 x = localPoint.x(); |
808 y = localPoint.y(); | 812 y = localPoint.y(); |
809 } | 813 } |
810 | 814 |
811 } // namespace blink | 815 } // namespace blink |
OLD | NEW |