Chromium Code Reviews| Index: content/child/blink_platform_impl.cc |
| diff --git a/content/child/blink_platform_impl.cc b/content/child/blink_platform_impl.cc |
| index d743fffac4636fee02a2845e2dc1a113205cf13d..e09a222714bdc8ac630aaf95bf0e113981c998b9 100644 |
| --- a/content/child/blink_platform_impl.cc |
| +++ b/content/child/blink_platform_impl.cc |
| @@ -72,6 +72,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; |
| @@ -1370,4 +1371,27 @@ int BlinkPlatformImpl::domEnumFromCodeString(const WebString& code) { |
| code.utf8().data())); |
| } |
| +WebString BlinkPlatformImpl::domKeyStringFromEnum(int dom_key) { |
| + if (dom_key < static_cast<int>(ui::DomKey::CHARACTER)) { |
| + return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString( |
| + static_cast<ui::DomKey>(dom_key))); |
|
dtapuska
2015/08/13 13:36:47
This cast is undefined when dom_key is less than 0
|
| + } else { |
| + std::string dom_key_char = base::StringPrintf("%c", |
|
dtapuska
2015/08/13 13:36:47
Does StringPrintf work for unicode characters? ie;
|
| + (dom_key - static_cast<int>(ui::DomKey::CHARACTER))); |
| + return WebString::fromUTF8(dom_key_char); |
| + } |
| +} |
| + |
| +int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key) { |
| + ui::DomKey dom_key = ui::KeycodeConverter::KeyStringToDomKey( |
| + key.utf8().data()); |
| + if (dom_key == ui::DomKey::CHARACTER) { |
| + int dom_char; |
| + base::StringToInt(key.utf8().data(), &dom_char); |
|
dtapuska
2015/08/13 13:36:48
Can we add an ASSERT that this doesn't fail?
|
| + return dom_char + static_cast<int>(ui::DomKey::CHARACTER); |
| + } else { |
| + return static_cast<int>(dom_key); |
| + } |
| +} |
| + |
| } // namespace content |