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

Side by Side 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, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/child/blink_platform_impl.h" 5 #include "content/child/blink_platform_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 #include "third_party/WebKit/public/platform/WebConvertableToTraceFormat.h" 64 #include "third_party/WebKit/public/platform/WebConvertableToTraceFormat.h"
65 #include "third_party/WebKit/public/platform/WebData.h" 65 #include "third_party/WebKit/public/platform/WebData.h"
66 #include "third_party/WebKit/public/platform/WebFloatPoint.h" 66 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
67 #include "third_party/WebKit/public/platform/WebMemoryDumpProvider.h" 67 #include "third_party/WebKit/public/platform/WebMemoryDumpProvider.h"
68 #include "third_party/WebKit/public/platform/WebString.h" 68 #include "third_party/WebKit/public/platform/WebString.h"
69 #include "third_party/WebKit/public/platform/WebURL.h" 69 #include "third_party/WebKit/public/platform/WebURL.h"
70 #include "third_party/WebKit/public/platform/WebWaitableEvent.h" 70 #include "third_party/WebKit/public/platform/WebWaitableEvent.h"
71 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 71 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
72 #include "ui/base/layout.h" 72 #include "ui/base/layout.h"
73 #include "ui/events/gestures/blink/web_gesture_curve_impl.h" 73 #include "ui/events/gestures/blink/web_gesture_curve_impl.h"
74 #include "ui/events/keycodes/dom/dom_key.h"
74 #include "ui/events/keycodes/dom/keycode_converter.h" 75 #include "ui/events/keycodes/dom/keycode_converter.h"
75 76
76 using blink::WebData; 77 using blink::WebData;
77 using blink::WebFallbackThemeEngine; 78 using blink::WebFallbackThemeEngine;
78 using blink::WebLocalizedString; 79 using blink::WebLocalizedString;
79 using blink::WebString; 80 using blink::WebString;
80 using blink::WebThemeEngine; 81 using blink::WebThemeEngine;
81 using blink::WebURL; 82 using blink::WebURL;
82 using blink::WebURLError; 83 using blink::WebURLError;
83 using blink::WebURLLoader; 84 using blink::WebURLLoader;
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 WebString BlinkPlatformImpl::domCodeStringFromEnum(int dom_code) { 1386 WebString BlinkPlatformImpl::domCodeStringFromEnum(int dom_code) {
1386 return WebString::fromUTF8(ui::KeycodeConverter::DomCodeToCodeString( 1387 return WebString::fromUTF8(ui::KeycodeConverter::DomCodeToCodeString(
1387 static_cast<ui::DomCode>(dom_code))); 1388 static_cast<ui::DomCode>(dom_code)));
1388 } 1389 }
1389 1390
1390 int BlinkPlatformImpl::domEnumFromCodeString(const WebString& code) { 1391 int BlinkPlatformImpl::domEnumFromCodeString(const WebString& code) {
1391 return static_cast<int>(ui::KeycodeConverter::CodeStringToDomCode( 1392 return static_cast<int>(ui::KeycodeConverter::CodeStringToDomCode(
1392 code.utf8().data())); 1393 code.utf8().data()));
1393 } 1394 }
1394 1395
1396 WebString BlinkPlatformImpl::domKeyStringFromEnum(int dom_key) {
1397 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
1398 std::string dom_key_char = base::StringPrintf("%c", dom_key);
1399 return WebString::fromUTF8(dom_key_char);
1400 } else {
1401 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString(
1402 static_cast<ui::DomKey>(dom_key - DOM_KEY_PRINT_NON_DIFF)));
1403 }
1404 }
1405
1406 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key) {
1407 ui::DomKey dom_key =
1408 ui::KeycodeConverter::KeyStringToDomKey(key.utf8().data());
1409 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.
1410 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
1411 }
1412 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
1413 }
1414
1395 } // namespace content 1415 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698