OLD | NEW |
---|---|
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 #include "third_party/WebKit/public/platform/WebConvertableToTraceFormat.h" | 65 #include "third_party/WebKit/public/platform/WebConvertableToTraceFormat.h" |
66 #include "third_party/WebKit/public/platform/WebData.h" | 66 #include "third_party/WebKit/public/platform/WebData.h" |
67 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 67 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
68 #include "third_party/WebKit/public/platform/WebMemoryDumpProvider.h" | 68 #include "third_party/WebKit/public/platform/WebMemoryDumpProvider.h" |
69 #include "third_party/WebKit/public/platform/WebString.h" | 69 #include "third_party/WebKit/public/platform/WebString.h" |
70 #include "third_party/WebKit/public/platform/WebURL.h" | 70 #include "third_party/WebKit/public/platform/WebURL.h" |
71 #include "third_party/WebKit/public/platform/WebWaitableEvent.h" | 71 #include "third_party/WebKit/public/platform/WebWaitableEvent.h" |
72 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 72 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
73 #include "ui/base/layout.h" | 73 #include "ui/base/layout.h" |
74 #include "ui/events/gestures/blink/web_gesture_curve_impl.h" | 74 #include "ui/events/gestures/blink/web_gesture_curve_impl.h" |
75 #include "ui/events/keycodes/dom/dom_key.h" | |
75 #include "ui/events/keycodes/dom/keycode_converter.h" | 76 #include "ui/events/keycodes/dom/keycode_converter.h" |
76 | 77 |
77 using blink::WebData; | 78 using blink::WebData; |
78 using blink::WebFallbackThemeEngine; | 79 using blink::WebFallbackThemeEngine; |
79 using blink::WebLocalizedString; | 80 using blink::WebLocalizedString; |
80 using blink::WebString; | 81 using blink::WebString; |
81 using blink::WebThemeEngine; | 82 using blink::WebThemeEngine; |
82 using blink::WebURL; | 83 using blink::WebURL; |
83 using blink::WebURLError; | 84 using blink::WebURLError; |
84 using blink::WebURLLoader; | 85 using blink::WebURLLoader; |
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1363 WebString BlinkPlatformImpl::domCodeStringFromEnum(int dom_code) { | 1364 WebString BlinkPlatformImpl::domCodeStringFromEnum(int dom_code) { |
1364 return WebString::fromUTF8(ui::KeycodeConverter::DomCodeToCodeString( | 1365 return WebString::fromUTF8(ui::KeycodeConverter::DomCodeToCodeString( |
1365 static_cast<ui::DomCode>(dom_code))); | 1366 static_cast<ui::DomCode>(dom_code))); |
1366 } | 1367 } |
1367 | 1368 |
1368 int BlinkPlatformImpl::domEnumFromCodeString(const WebString& code) { | 1369 int BlinkPlatformImpl::domEnumFromCodeString(const WebString& code) { |
1369 return static_cast<int>(ui::KeycodeConverter::CodeStringToDomCode( | 1370 return static_cast<int>(ui::KeycodeConverter::CodeStringToDomCode( |
1370 code.utf8().data())); | 1371 code.utf8().data())); |
1371 } | 1372 } |
1372 | 1373 |
1374 WebString BlinkPlatformImpl::domKeyStringFromEnum(int dom_key) { | |
1375 if (dom_key < static_cast<int>(ui::DomKey::CHARACTER)) { | |
1376 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString( | |
1377 static_cast<ui::DomKey>(dom_key))); | |
dtapuska
2015/08/13 13:36:47
This cast is undefined when dom_key is less than 0
| |
1378 } else { | |
1379 std::string dom_key_char = base::StringPrintf("%c", | |
dtapuska
2015/08/13 13:36:47
Does StringPrintf work for unicode characters? ie;
| |
1380 (dom_key - static_cast<int>(ui::DomKey::CHARACTER))); | |
1381 return WebString::fromUTF8(dom_key_char); | |
1382 } | |
1383 } | |
1384 | |
1385 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key) { | |
1386 ui::DomKey dom_key = ui::KeycodeConverter::KeyStringToDomKey( | |
1387 key.utf8().data()); | |
1388 if (dom_key == ui::DomKey::CHARACTER) { | |
1389 int dom_char; | |
1390 base::StringToInt(key.utf8().data(), &dom_char); | |
dtapuska
2015/08/13 13:36:48
Can we add an ASSERT that this doesn't fail?
| |
1391 return dom_char + static_cast<int>(ui::DomKey::CHARACTER); | |
1392 } else { | |
1393 return static_cast<int>(dom_key); | |
1394 } | |
1395 } | |
1396 | |
1373 } // namespace content | 1397 } // namespace content |
OLD | NEW |