Chromium Code Reviews| Index: Source/core/events/KeyboardEvent.cpp |
| diff --git a/Source/core/events/KeyboardEvent.cpp b/Source/core/events/KeyboardEvent.cpp |
| index 99be09ca9633867bb562e44244bb19ae8691609f..11d6d15e51278cdf25c54f08d5de4fd5500ac46a 100644 |
| --- a/Source/core/events/KeyboardEvent.cpp |
| +++ b/Source/core/events/KeyboardEvent.cpp |
| @@ -23,6 +23,7 @@ |
| #include "config.h" |
| #include "core/events/KeyboardEvent.h" |
| +#include "KeyboardCode.h" |
| #include "platform/PlatformKeyboardEvent.h" |
| #include "platform/WindowsKeyboardCodes.h" |
| @@ -85,6 +86,23 @@ static inline KeyboardEvent::KeyLocationCode keyLocationCode(const PlatformKeybo |
| } |
| } |
| +static inline String nativeCodeToKeyCode(PlatformEvent::Type type, int nativeCode) |
|
Wez
2014/10/25 00:23:02
This takes a nativeKeyCode and returns a DOM |code
|
| +{ |
| + String code = ""; |
| + |
| + if (type == PlatformEvent::Char) |
| + return code; |
|
Wez
2014/10/25 00:23:02
Why would you ever call this for a Char event?
Habib Virji
2014/10/27 16:48:36
It is due to KeyboardEvent constructor getting cal
|
| + |
| + for (unsigned long i = 0; i < (sizeof(keyCodeMap)/ sizeof(keyCodeMap[0])); ++i) { |
| + if (nativeCode && nativeCode == keyCodeMap[i].nativeCode) { |
| + code = String(keyCodeMap[i].code); |
| + return code; |
|
Wez
2014/10/25 00:23:02
Why not return the new String directly?
Habib Virji
2014/10/27 16:48:36
Acknowledged.
|
| + } |
| + } |
| + |
| + return code; |
|
Wez
2014/10/25 00:23:02
If you reach here then code is always "" - why do
Habib Virji
2014/10/27 16:48:36
Acknowledged.
|
| +} |
| + |
| KeyboardEventInit::KeyboardEventInit() |
| : location(0) |
| , ctrlKey(false) |
| @@ -108,6 +126,7 @@ KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, AbstractView* vie |
| , m_keyIdentifier(key.keyIdentifier()) |
| , m_location(keyLocationCode(key)) |
| , m_isAutoRepeat(key.isAutoRepeat()) |
| + , m_code(nativeCodeToKeyCode(key.type(), key.nativeVirtualKeyCode())) |
| { |
| } |
| @@ -116,6 +135,7 @@ KeyboardEvent::KeyboardEvent(const AtomicString& eventType, const KeyboardEventI |
| , m_keyIdentifier(initializer.keyIdentifier) |
| , m_location(initializer.location) |
| , m_isAutoRepeat(initializer.repeat) |
| + , m_code(initializer.code) |
| { |
| } |