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

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: UnitTest updated as MakeKeyboardEvent now adds a value to differentiate 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) {
Wez 2015/07/25 23:12:26 Discussing this with kpschoedel@, he prefers that
kpschoedel 2015/07/29 14:43:14 Apologies for being away from this for a while. G
Wez 2015/07/29 17:59:36 SGTM - thanks Kevin!
kpschoedel 2015/07/29 19:16:11 I'm now thinking the opposite for a unified ui::Do
Wez 2015/07/29 19:59:47 I'm not sure that type-safety is really an issue h
Habib Virji 2015/07/31 16:17:29 It is a good suggestion. In the code snippet thoug
+ 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/07/25 23:12:26 As noted previously, NONE means something differen
Habib Virji 2015/07/31 16:17:29 Done.
+ return key.at(0);
Wez 2015/07/25 23:12:26 My understanding is that WebString's are expressed
Habib Virji 2015/07/31 16:17:29 Have changed to using StringToInt as it appears to
+ }
+ return static_cast<int>(dom_key);
Wez 2015/07/25 23:12:26 Note that the way this function is written current
Habib Virji 2015/07/31 16:17:29 With the update checking DomKey::CHARACTER it shou
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698