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

Unified Diff: content/child/blink_platform_impl.cc

Issue 929053004: [KeyboardEvent] Add embedder APIs to translate between Dom |key| enum and strings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated MakeWebKeyboardEvent function with the changes. Created 5 years, 6 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: content/child/blink_platform_impl.cc
diff --git a/content/child/blink_platform_impl.cc b/content/child/blink_platform_impl.cc
index 78939bb0167d693444707233ea5ba300d1cc7eb3..9c87777d0758caeca30573143c6c77fc881c2384 100644
--- a/content/child/blink_platform_impl.cc
+++ b/content/child/blink_platform_impl.cc
@@ -71,6 +71,7 @@
#include "third_party/WebKit/public/web/WebSecurityOrigin.h"
#include "ui/base/layout.h"
#include "ui/events/gestures/blink/web_gesture_curve_impl.h"
+#include "ui/events/keycodes/dom/dom_key.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
using blink::WebData;
@@ -1392,4 +1393,23 @@ int BlinkPlatformImpl::domEnumFromCodeString(const WebString& code) {
code.utf8().data()));
}
+WebString BlinkPlatformImpl::domKeyStringFromEnum(int dom_key) {
+ if (dom_key < DOM_KEY_PRINT_NON_DIFF) {
+ std::string dom_key_char = base::StringPrintf("%c", dom_key);
+ return WebString::fromUTF8(dom_key_char);
+ } else {
+ return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString(
+ static_cast<ui::DomKey>(dom_key - DOM_KEY_PRINT_NON_DIFF)));
+ }
+}
+
+int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key) {
+ ui::DomKey dom_key =
+ ui::KeycodeConverter::KeyStringToDomKey(key.utf8().data());
+ if (ui::DomKey::NONE == dom_key) {
Wez 2015/06/25 10:40:21 This should be testing for DomKey::CHARACTER, not
Habib Virji 2015/06/26 17:35:38 KeyStringToDomKey returns DomKey::NONE if no match
+ return key.at(0);
+ }
+ return static_cast<int>(dom_key);
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698