| 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. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 case PlatformEvent::KeyDown: | 42 case PlatformEvent::KeyDown: |
| 43 // The caller should disambiguate the combined event into RawKeyDown
or Char events. | 43 // The caller should disambiguate the combined event into RawKeyDown
or Char events. |
| 44 break; | 44 break; |
| 45 default: | 45 default: |
| 46 break; | 46 break; |
| 47 } | 47 } |
| 48 ASSERT_NOT_REACHED(); | 48 ASSERT_NOT_REACHED(); |
| 49 return EventTypeNames::keydown; | 49 return EventTypeNames::keydown; |
| 50 } | 50 } |
| 51 | 51 |
| 52 static inline int windowsVirtualKeyCodeWithoutLocation(int keycode) | |
| 53 { | |
| 54 switch (keycode) { | |
| 55 case VK_LCONTROL: | |
| 56 case VK_RCONTROL: | |
| 57 return VK_CONTROL; | |
| 58 case VK_LSHIFT: | |
| 59 case VK_RSHIFT: | |
| 60 return VK_SHIFT; | |
| 61 case VK_LMENU: | |
| 62 case VK_RMENU: | |
| 63 return VK_MENU; | |
| 64 default: | |
| 65 return keycode; | |
| 66 } | |
| 67 } | |
| 68 | |
| 69 static inline KeyboardEvent::KeyLocationCode keyLocationCode(const PlatformKeybo
ardEvent& key) | 52 static inline KeyboardEvent::KeyLocationCode keyLocationCode(const PlatformKeybo
ardEvent& key) |
| 70 { | 53 { |
| 71 if (key.isKeypad()) | 54 if (key.isKeypad()) |
| 72 return KeyboardEvent::DOM_KEY_LOCATION_NUMPAD; | 55 return KeyboardEvent::DOM_KEY_LOCATION_NUMPAD; |
| 73 | 56 if (key.modifiers() & PlatformEvent::IsLeft) |
| 74 switch (key.windowsVirtualKeyCode()) { | |
| 75 case VK_LCONTROL: | |
| 76 case VK_LSHIFT: | |
| 77 case VK_LMENU: | |
| 78 case VK_LWIN: | |
| 79 return KeyboardEvent::DOM_KEY_LOCATION_LEFT; | 57 return KeyboardEvent::DOM_KEY_LOCATION_LEFT; |
| 80 case VK_RCONTROL: | 58 if (key.modifiers() & PlatformEvent::IsRight) |
| 81 case VK_RSHIFT: | |
| 82 case VK_RMENU: | |
| 83 case VK_RWIN: | |
| 84 return KeyboardEvent::DOM_KEY_LOCATION_RIGHT; | 59 return KeyboardEvent::DOM_KEY_LOCATION_RIGHT; |
| 85 default: | 60 return KeyboardEvent::DOM_KEY_LOCATION_STANDARD; |
| 86 return KeyboardEvent::DOM_KEY_LOCATION_STANDARD; | |
| 87 } | |
| 88 } | 61 } |
| 89 | 62 |
| 90 PassRefPtrWillBeRawPtr<KeyboardEvent> KeyboardEvent::create(ScriptState* scriptS
tate, const AtomicString& type, const KeyboardEventInit& initializer) | 63 PassRefPtrWillBeRawPtr<KeyboardEvent> KeyboardEvent::create(ScriptState* scriptS
tate, const AtomicString& type, const KeyboardEventInit& initializer) |
| 91 { | 64 { |
| 92 if (scriptState->world().isIsolatedWorld()) | 65 if (scriptState->world().isIsolatedWorld()) |
| 93 UIEventWithKeyState::didCreateEventInIsolatedWorld(initializer.ctrlKey()
, initializer.altKey(), initializer.shiftKey(), initializer.metaKey()); | 66 UIEventWithKeyState::didCreateEventInIsolatedWorld(initializer.ctrlKey()
, initializer.altKey(), initializer.shiftKey(), initializer.metaKey()); |
| 94 return adoptRefWillBeNoop(new KeyboardEvent(type, initializer)); | 67 return adoptRefWillBeNoop(new KeyboardEvent(type, initializer)); |
| 95 } | 68 } |
| 96 | 69 |
| 97 KeyboardEvent::KeyboardEvent() | 70 KeyboardEvent::KeyboardEvent() |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 return 0; | 151 return 0; |
| 179 | 152 |
| 180 #if OS(ANDROID) | 153 #if OS(ANDROID) |
| 181 // FIXME: Check to see if this applies to other OS. | 154 // FIXME: Check to see if this applies to other OS. |
| 182 // If the key event belongs to IME composition then propagate to JS. | 155 // If the key event belongs to IME composition then propagate to JS. |
| 183 if (m_keyEvent->nativeVirtualKeyCode() == 0xE5) // VKEY_PROCESSKEY | 156 if (m_keyEvent->nativeVirtualKeyCode() == 0xE5) // VKEY_PROCESSKEY |
| 184 return m_keyEvent->nativeVirtualKeyCode(); | 157 return m_keyEvent->nativeVirtualKeyCode(); |
| 185 #endif | 158 #endif |
| 186 | 159 |
| 187 if (type() == EventTypeNames::keydown || type() == EventTypeNames::keyup) | 160 if (type() == EventTypeNames::keydown || type() == EventTypeNames::keyup) |
| 188 return windowsVirtualKeyCodeWithoutLocation(m_keyEvent->windowsVirtualKe
yCode()); | 161 return m_keyEvent->windowsVirtualKeyCode(); |
| 189 | 162 |
| 190 return charCode(); | 163 return charCode(); |
| 191 } | 164 } |
| 192 | 165 |
| 193 int KeyboardEvent::charCode() const | 166 int KeyboardEvent::charCode() const |
| 194 { | 167 { |
| 195 // IE: not supported | 168 // IE: not supported |
| 196 // Firefox: 0 for keydown/keyup events, character code for keypress | 169 // Firefox: 0 for keydown/keyup events, character code for keypress |
| 197 // We match Firefox | 170 // We match Firefox |
| 198 | 171 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 { | 212 { |
| 240 } | 213 } |
| 241 | 214 |
| 242 bool KeyboardEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) c
onst | 215 bool KeyboardEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) c
onst |
| 243 { | 216 { |
| 244 // Make sure not to return true if we already took default action while hand
ling the event. | 217 // Make sure not to return true if we already took default action while hand
ling the event. |
| 245 return EventDispatchMediator::dispatchEvent(dispatcher) && !event().defaultH
andled(); | 218 return EventDispatchMediator::dispatchEvent(dispatcher) && !event().defaultH
andled(); |
| 246 } | 219 } |
| 247 | 220 |
| 248 } // namespace blink | 221 } // namespace blink |
| OLD | NEW |