Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: Source/core/events/KeyboardEvent.cpp

Issue 663523002: Adding support for DOM3 KeyboardEvents Code in KeyboardEvents (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Test fix Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/events/KeyboardEvent.cpp
diff --git a/Source/core/events/KeyboardEvent.cpp b/Source/core/events/KeyboardEvent.cpp
index 99be09ca9633867bb562e44244bb19ae8691609f..5df6e349eb278a82b748e6eebbc2b54456a65f1a 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 usbCodeToKeyCode(AtomicString type, int usbCode, int windowsVirtualKeyboard)
+{
+ String code = "";
+
+ if (type == EventTypeNames::keypress)
+ return code;
+
+ for (unsigned long i = 0; i < (sizeof(keyCodeMap)/ sizeof(keyCodeMap[0])); ++i) {
+ if ((usbCode && usbCode == keyCodeMap[i].usbCode) || (windowsVirtualKeyboard && windowsVirtualKeyboard == keyCodeMap[i].windowsKeyCode)) {
+ code = String(keyCodeMap[i].code);
+ return code;
+ }
+ }
+
+ return code;
+}
+
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(usbCodeToKeyCode(eventTypeForKeyboardEventType(key.type()), key.usbKeyCode(), key.windowsVirtualKeyCode()))
{
}
@@ -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)
{
}

Powered by Google App Engine
This is Rietveld 408576698