| 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 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 #include "core/events/KeyboardEvent.h" | 23 #include "core/events/KeyboardEvent.h" |
| 24 | 24 |
| 25 #include "bindings/core/v8/DOMWrapperWorld.h" | 25 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 26 #include "bindings/core/v8/ScriptState.h" | 26 #include "bindings/core/v8/ScriptState.h" |
| 27 #include "platform/PlatformKeyboardEvent.h" | 27 #include "platform/PlatformKeyboardEvent.h" |
| 28 #include "platform/WindowsKeyboardCodes.h" | 28 #include "platform/WindowsKeyboardCodes.h" |
| 29 | 29 |
| 30 namespace blink { | 30 namespace blink { |
| 31 | 31 |
| 32 static inline const AtomicString& eventTypeForKeyboardEventType(PlatformEvent::T
ype type) | 32 static inline const AtomicString& eventTypeForKeyboardEventType(PlatformEvent::E
ventType type) |
| 33 { | 33 { |
| 34 switch (type) { | 34 switch (type) { |
| 35 case PlatformEvent::KeyUp: | 35 case PlatformEvent::KeyUp: |
| 36 return EventTypeNames::keyup; | 36 return EventTypeNames::keyup; |
| 37 case PlatformEvent::RawKeyDown: | 37 case PlatformEvent::RawKeyDown: |
| 38 return EventTypeNames::keydown; | 38 return EventTypeNames::keydown; |
| 39 case PlatformEvent::Char: | 39 case PlatformEvent::Char: |
| 40 return EventTypeNames::keypress; | 40 return EventTypeNames::keypress; |
| 41 case PlatformEvent::KeyDown: | 41 case PlatformEvent::KeyDown: |
| 42 // The caller should disambiguate the combined event into RawKeyDown
or Char events. | 42 // The caller should disambiguate the combined event into RawKeyDown
or Char events. |
| 43 break; | 43 break; |
| 44 default: | 44 default: |
| 45 break; | 45 break; |
| 46 } | 46 } |
| 47 ASSERT_NOT_REACHED(); | 47 ASSERT_NOT_REACHED(); |
| 48 return EventTypeNames::keydown; | 48 return EventTypeNames::keydown; |
| 49 } | 49 } |
| 50 | 50 |
| 51 static inline KeyboardEvent::KeyLocationCode keyLocationCode(const PlatformKeybo
ardEvent& key) | 51 static inline KeyboardEvent::KeyLocationCode keyLocationCode(const PlatformKeybo
ardEvent& key) |
| 52 { | 52 { |
| 53 if (key.isKeypad()) | 53 if (key.isKeypad()) |
| 54 return KeyboardEvent::DOM_KEY_LOCATION_NUMPAD; | 54 return KeyboardEvent::DOM_KEY_LOCATION_NUMPAD; |
| 55 if (key.modifiers() & PlatformEvent::IsLeft) | 55 if (key.getModifiers() & PlatformEvent::IsLeft) |
| 56 return KeyboardEvent::DOM_KEY_LOCATION_LEFT; | 56 return KeyboardEvent::DOM_KEY_LOCATION_LEFT; |
| 57 if (key.modifiers() & PlatformEvent::IsRight) | 57 if (key.getModifiers() & PlatformEvent::IsRight) |
| 58 return KeyboardEvent::DOM_KEY_LOCATION_RIGHT; | 58 return KeyboardEvent::DOM_KEY_LOCATION_RIGHT; |
| 59 return KeyboardEvent::DOM_KEY_LOCATION_STANDARD; | 59 return KeyboardEvent::DOM_KEY_LOCATION_STANDARD; |
| 60 } | 60 } |
| 61 | 61 |
| 62 PassRefPtrWillBeRawPtr<KeyboardEvent> KeyboardEvent::create(ScriptState* scriptS
tate, const AtomicString& type, const KeyboardEventInit& initializer) | 62 PassRefPtrWillBeRawPtr<KeyboardEvent> KeyboardEvent::create(ScriptState* scriptS
tate, const AtomicString& type, const KeyboardEventInit& initializer) |
| 63 { | 63 { |
| 64 if (scriptState->world().isIsolatedWorld()) | 64 if (scriptState->world().isIsolatedWorld()) |
| 65 UIEventWithKeyState::didCreateEventInIsolatedWorld(initializer.ctrlKey()
, initializer.altKey(), initializer.shiftKey(), initializer.metaKey()); | 65 UIEventWithKeyState::didCreateEventInIsolatedWorld(initializer.ctrlKey()
, initializer.altKey(), initializer.shiftKey(), initializer.metaKey()); |
| 66 return adoptRefWillBeNoop(new KeyboardEvent(type, initializer)); | 66 return adoptRefWillBeNoop(new KeyboardEvent(type, initializer)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 KeyboardEvent::KeyboardEvent() | 69 KeyboardEvent::KeyboardEvent() |
| 70 : m_location(DOM_KEY_LOCATION_STANDARD) | 70 : m_location(DOM_KEY_LOCATION_STANDARD) |
| 71 { | 71 { |
| 72 } | 72 } |
| 73 | 73 |
| 74 KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, AbstractView* vie
w) | 74 KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, AbstractView* vie
w) |
| 75 : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type()), true, true,
view, 0, key.modifiers(), key.timestamp(), InputDeviceCapabilities::doesntFireT
ouchEventsSourceCapabilities()) | 75 : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type()), true, true,
view, 0, key.getModifiers(), key.timestamp(), InputDeviceCapabilities::doesntFi
reTouchEventsSourceCapabilities()) |
| 76 , m_keyEvent(adoptPtr(new PlatformKeyboardEvent(key))) | 76 , m_keyEvent(adoptPtr(new PlatformKeyboardEvent(key))) |
| 77 , m_keyIdentifier(key.keyIdentifier()) | 77 , m_keyIdentifier(key.keyIdentifier()) |
| 78 , m_code(key.code()) | 78 , m_code(key.code()) |
| 79 , m_key(key.key()) | 79 , m_key(key.key()) |
| 80 , m_location(keyLocationCode(key)) | 80 , m_location(keyLocationCode(key)) |
| 81 { | 81 { |
| 82 initLocationModifiers(m_location); | 82 initLocationModifiers(m_location); |
| 83 } | 83 } |
| 84 | 84 |
| 85 KeyboardEvent::KeyboardEvent(const AtomicString& eventType, const KeyboardEventI
nit& initializer) | 85 KeyboardEvent::KeyboardEvent(const AtomicString& eventType, const KeyboardEventI
nit& initializer) |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 break; | 191 break; |
| 192 } | 192 } |
| 193 } | 193 } |
| 194 | 194 |
| 195 DEFINE_TRACE(KeyboardEvent) | 195 DEFINE_TRACE(KeyboardEvent) |
| 196 { | 196 { |
| 197 UIEventWithKeyState::trace(visitor); | 197 UIEventWithKeyState::trace(visitor); |
| 198 } | 198 } |
| 199 | 199 |
| 200 } // namespace blink | 200 } // namespace blink |
| OLD | NEW |