OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/renderer_host/input/web_input_event_builders_android.h " | 5 #include "content/browser/renderer_host/input/web_input_event_builders_android.h " |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/browser/renderer_host/input/motion_event_android.h" | 8 #include "content/browser/renderer_host/input/motion_event_android.h" |
9 #include "content/browser/renderer_host/input/web_input_event_util.h" | 9 #include "content/browser/renderer_host/input/web_input_event_util.h" |
10 #include "content/browser/renderer_host/input/web_input_event_util_posix.h" | 10 #include "content/browser/renderer_host/input/web_input_event_util_posix.h" |
11 #include "ui/events/keycodes/dom/dom_code.h" | |
12 #include "ui/events/keycodes/dom/keycode_converter.h" | |
11 #include "ui/events/keycodes/keyboard_code_conversion_android.h" | 13 #include "ui/events/keycodes/keyboard_code_conversion_android.h" |
12 #include "ui/events/keycodes/keyboard_codes_posix.h" | 14 #include "ui/events/keycodes/keyboard_codes_posix.h" |
13 | 15 |
14 using blink::WebInputEvent; | 16 using blink::WebInputEvent; |
15 using blink::WebKeyboardEvent; | 17 using blink::WebKeyboardEvent; |
16 using blink::WebGestureEvent; | 18 using blink::WebGestureEvent; |
17 using blink::WebMouseEvent; | 19 using blink::WebMouseEvent; |
18 using blink::WebMouseWheelEvent; | 20 using blink::WebMouseWheelEvent; |
19 using blink::WebTouchEvent; | 21 using blink::WebTouchEvent; |
20 using blink::WebTouchPoint; | 22 using blink::WebTouchPoint; |
21 | 23 |
22 namespace content { | 24 namespace content { |
23 | 25 |
24 WebKeyboardEvent WebKeyboardEventBuilder::Build(WebInputEvent::Type type, | 26 WebKeyboardEvent WebKeyboardEventBuilder::Build(WebInputEvent::Type type, |
25 int modifiers, | 27 int modifiers, |
26 double time_sec, | 28 double time_sec, |
27 int keycode, | 29 int keycode, |
30 int scancode, | |
28 int unicode_character, | 31 int unicode_character, |
29 bool is_system_key) { | 32 bool is_system_key) { |
30 DCHECK(WebInputEvent::isKeyboardEventType(type)); | 33 DCHECK(WebInputEvent::isKeyboardEventType(type)); |
31 WebKeyboardEvent result; | 34 WebKeyboardEvent result; |
32 | 35 |
36 ui::DomCode dom_code = ui::DomCode::NONE; | |
37 if (scancode != 0) | |
Wez
2015/09/14 22:03:50
nit: if (scancode)
| |
38 dom_code = ui::KeycodeConverter::NativeKeycodeToDomCode(scancode); | |
33 result.type = type; | 39 result.type = type; |
34 result.modifiers = modifiers; | 40 result.modifiers = modifiers; |
35 result.timeStampSeconds = time_sec; | 41 result.timeStampSeconds = time_sec; |
36 ui::KeyboardCode windows_key_code = | 42 ui::KeyboardCode windows_key_code = |
37 ui::KeyboardCodeFromAndroidKeyCode(keycode); | 43 ui::KeyboardCodeFromAndroidKeyCode(keycode); |
38 UpdateWindowsKeyCodeAndKeyIdentifier(&result, windows_key_code); | 44 UpdateWindowsKeyCodeAndKeyIdentifier(&result, windows_key_code); |
39 result.modifiers |= GetLocationModifiersFromWindowsKeyCode(windows_key_code); | 45 result.modifiers |= GetLocationModifiersFromWindowsKeyCode(windows_key_code); |
40 result.nativeKeyCode = keycode; | 46 result.nativeKeyCode = keycode; |
47 result.domCode = static_cast<int>(dom_code); | |
41 result.unmodifiedText[0] = unicode_character; | 48 result.unmodifiedText[0] = unicode_character; |
42 if (result.windowsKeyCode == ui::VKEY_RETURN) { | 49 if (result.windowsKeyCode == ui::VKEY_RETURN) { |
43 // This is the same behavior as GTK: | 50 // This is the same behavior as GTK: |
44 // We need to treat the enter key as a key press of character \r. This | 51 // We need to treat the enter key as a key press of character \r. This |
45 // is apparently just how webkit handles it and what it expects. | 52 // is apparently just how webkit handles it and what it expects. |
46 result.unmodifiedText[0] = '\r'; | 53 result.unmodifiedText[0] = '\r'; |
47 } | 54 } |
48 result.text[0] = result.unmodifiedText[0]; | 55 result.text[0] = result.unmodifiedText[0]; |
49 result.isSystemKey = is_system_key; | 56 result.isSystemKey = is_system_key; |
50 | 57 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 result.type = type; | 119 result.type = type; |
113 result.x = x; | 120 result.x = x; |
114 result.y = y; | 121 result.y = y; |
115 result.timeStampSeconds = time_sec; | 122 result.timeStampSeconds = time_sec; |
116 result.sourceDevice = blink::WebGestureDeviceTouchscreen; | 123 result.sourceDevice = blink::WebGestureDeviceTouchscreen; |
117 | 124 |
118 return result; | 125 return result; |
119 } | 126 } |
120 | 127 |
121 } // namespace content | 128 } // namespace content |
OLD | NEW |