OLD | NEW |
1 /** | 1 /** |
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) | 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) |
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) | 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) |
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
5 * Copyright (C) 2003, 2005, 2006, 2007 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2005, 2006, 2007 Apple Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
11 * | 11 * |
12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
21 */ | 21 */ |
22 | 22 |
23 #include "config.h" | 23 #include "config.h" |
24 #include "core/events/KeyboardEvent.h" | 24 #include "core/events/KeyboardEvent.h" |
25 | 25 |
| 26 #include "KeyboardCode.h" |
26 #include "platform/PlatformKeyboardEvent.h" | 27 #include "platform/PlatformKeyboardEvent.h" |
27 #include "platform/WindowsKeyboardCodes.h" | 28 #include "platform/WindowsKeyboardCodes.h" |
28 | 29 |
29 namespace blink { | 30 namespace blink { |
30 | 31 |
31 static inline const AtomicString& eventTypeForKeyboardEventType(PlatformEvent::T
ype type) | 32 static inline const AtomicString& eventTypeForKeyboardEventType(PlatformEvent::T
ype type) |
32 { | 33 { |
33 switch (type) { | 34 switch (type) { |
34 case PlatformEvent::KeyUp: | 35 case PlatformEvent::KeyUp: |
35 return EventTypeNames::keyup; | 36 return EventTypeNames::keyup; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 case VK_RCONTROL: | 79 case VK_RCONTROL: |
79 case VK_RSHIFT: | 80 case VK_RSHIFT: |
80 case VK_RMENU: | 81 case VK_RMENU: |
81 case VK_RWIN: | 82 case VK_RWIN: |
82 return KeyboardEvent::DOM_KEY_LOCATION_RIGHT; | 83 return KeyboardEvent::DOM_KEY_LOCATION_RIGHT; |
83 default: | 84 default: |
84 return KeyboardEvent::DOM_KEY_LOCATION_STANDARD; | 85 return KeyboardEvent::DOM_KEY_LOCATION_STANDARD; |
85 } | 86 } |
86 } | 87 } |
87 | 88 |
| 89 static inline String usbCodeToKeyCode(AtomicString type, int usbCode, int window
sVirtualKeyboard) |
| 90 { |
| 91 String code = ""; |
| 92 |
| 93 if (type == EventTypeNames::keypress) |
| 94 return code; |
| 95 |
| 96 for (unsigned long i = 0; i < (sizeof(keyCodeMap)/ sizeof(keyCodeMap[0])); +
+i) { |
| 97 if ((usbCode && usbCode == keyCodeMap[i].usbCode) || (windowsVirtualKeyb
oard && windowsVirtualKeyboard == keyCodeMap[i].windowsKeyCode)) { |
| 98 code = String(keyCodeMap[i].code); |
| 99 return code; |
| 100 } |
| 101 } |
| 102 |
| 103 return code; |
| 104 } |
| 105 |
88 KeyboardEventInit::KeyboardEventInit() | 106 KeyboardEventInit::KeyboardEventInit() |
89 : location(0) | 107 : location(0) |
90 , ctrlKey(false) | 108 , ctrlKey(false) |
91 , altKey(false) | 109 , altKey(false) |
92 , shiftKey(false) | 110 , shiftKey(false) |
93 , metaKey(false) | 111 , metaKey(false) |
94 , repeat(false) | 112 , repeat(false) |
95 { | 113 { |
96 } | 114 } |
97 | 115 |
98 KeyboardEvent::KeyboardEvent() | 116 KeyboardEvent::KeyboardEvent() |
99 : m_location(DOM_KEY_LOCATION_STANDARD) | 117 : m_location(DOM_KEY_LOCATION_STANDARD) |
100 , m_isAutoRepeat(false) | 118 , m_isAutoRepeat(false) |
101 { | 119 { |
102 } | 120 } |
103 | 121 |
104 KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, AbstractView* vie
w) | 122 KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, AbstractView* vie
w) |
105 : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type()), | 123 : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type()), |
106 true, true, view, 0, key.ctrlKey(), key.altKey(), key.
shiftKey(), key.metaKey()) | 124 true, true, view, 0, key.ctrlKey(), key.altKey(), key.
shiftKey(), key.metaKey()) |
107 , m_keyEvent(adoptPtr(new PlatformKeyboardEvent(key))) | 125 , m_keyEvent(adoptPtr(new PlatformKeyboardEvent(key))) |
108 , m_keyIdentifier(key.keyIdentifier()) | 126 , m_keyIdentifier(key.keyIdentifier()) |
109 , m_location(keyLocationCode(key)) | 127 , m_location(keyLocationCode(key)) |
110 , m_isAutoRepeat(key.isAutoRepeat()) | 128 , m_isAutoRepeat(key.isAutoRepeat()) |
| 129 , m_code(usbCodeToKeyCode(eventTypeForKeyboardEventType(key.type()), key.usb
KeyCode(), key.windowsVirtualKeyCode())) |
111 { | 130 { |
112 } | 131 } |
113 | 132 |
114 KeyboardEvent::KeyboardEvent(const AtomicString& eventType, const KeyboardEventI
nit& initializer) | 133 KeyboardEvent::KeyboardEvent(const AtomicString& eventType, const KeyboardEventI
nit& initializer) |
115 : UIEventWithKeyState(eventType, initializer.bubbles, initializer.cancelable
, initializer.view, initializer.detail, initializer.ctrlKey, initializer.altKey,
initializer.shiftKey, initializer.metaKey) | 134 : UIEventWithKeyState(eventType, initializer.bubbles, initializer.cancelable
, initializer.view, initializer.detail, initializer.ctrlKey, initializer.altKey,
initializer.shiftKey, initializer.metaKey) |
116 , m_keyIdentifier(initializer.keyIdentifier) | 135 , m_keyIdentifier(initializer.keyIdentifier) |
117 , m_location(initializer.location) | 136 , m_location(initializer.location) |
118 , m_isAutoRepeat(initializer.repeat) | 137 , m_isAutoRepeat(initializer.repeat) |
| 138 , m_code(initializer.code) |
119 { | 139 { |
120 } | 140 } |
121 | 141 |
122 KeyboardEvent::KeyboardEvent(const AtomicString& eventType, bool canBubble, bool
cancelable, AbstractView *view, | 142 KeyboardEvent::KeyboardEvent(const AtomicString& eventType, bool canBubble, bool
cancelable, AbstractView *view, |
123 const String &keyIdentifier, unsigned location, | 143 const String &keyIdentifier, unsigned location, |
124 bool ctrlKey, bool altKey, bool shiftKey, bool meta
Key) | 144 bool ctrlKey, bool altKey, bool shiftKey, bool meta
Key) |
125 : UIEventWithKeyState(eventType, canBubble, cancelable, view, 0, ctrlKey, al
tKey, shiftKey, metaKey) | 145 : UIEventWithKeyState(eventType, canBubble, cancelable, view, 0, ctrlKey, al
tKey, shiftKey, metaKey) |
126 , m_keyIdentifier(keyIdentifier) | 146 , m_keyIdentifier(keyIdentifier) |
127 , m_location(location) | 147 , m_location(location) |
128 , m_isAutoRepeat(false) | 148 , m_isAutoRepeat(false) |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 { | 242 { |
223 } | 243 } |
224 | 244 |
225 bool KeyboardEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) c
onst | 245 bool KeyboardEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) c
onst |
226 { | 246 { |
227 // Make sure not to return true if we already took default action while hand
ling the event. | 247 // Make sure not to return true if we already took default action while hand
ling the event. |
228 return EventDispatchMediator::dispatchEvent(dispatcher) && !event()->default
Handled(); | 248 return EventDispatchMediator::dispatchEvent(dispatcher) && !event()->default
Handled(); |
229 } | 249 } |
230 | 250 |
231 } // namespace blink | 251 } // namespace blink |
OLD | NEW |