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) | |
38 dom_code = ui::KeycodeConverter::NativeKeycodeToDomCode(scancode); | |
39 if (dom_code == ui::DomCode::NONE) | |
40 dom_code = ui::DomCodeFromAndroidKeyCode(keycode); | |
Sergey Ulanov
2015/09/09 19:55:44
I don't think this is the right approach. DomCodeF
dtapuska
2015/09/09 20:00:13
So what is your preferred fallback? Not to set the
Sergey Ulanov
2015/09/09 20:20:30
I'm not sure, but I think not setting it at all wo
| |
33 result.type = type; | 41 result.type = type; |
34 result.modifiers = modifiers; | 42 result.modifiers = modifiers; |
35 result.timeStampSeconds = time_sec; | 43 result.timeStampSeconds = time_sec; |
36 ui::KeyboardCode windows_key_code = | 44 ui::KeyboardCode windows_key_code = |
37 ui::KeyboardCodeFromAndroidKeyCode(keycode); | 45 ui::KeyboardCodeFromAndroidKeyCode(keycode); |
38 UpdateWindowsKeyCodeAndKeyIdentifier(&result, windows_key_code); | 46 UpdateWindowsKeyCodeAndKeyIdentifier(&result, windows_key_code); |
39 result.modifiers |= GetLocationModifiersFromWindowsKeyCode(windows_key_code); | 47 result.modifiers |= GetLocationModifiersFromWindowsKeyCode(windows_key_code); |
40 result.nativeKeyCode = keycode; | 48 result.nativeKeyCode = keycode; |
49 result.domCode = static_cast<int>(dom_code); | |
41 result.unmodifiedText[0] = unicode_character; | 50 result.unmodifiedText[0] = unicode_character; |
42 if (result.windowsKeyCode == ui::VKEY_RETURN) { | 51 if (result.windowsKeyCode == ui::VKEY_RETURN) { |
43 // This is the same behavior as GTK: | 52 // This is the same behavior as GTK: |
44 // We need to treat the enter key as a key press of character \r. This | 53 // 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. | 54 // is apparently just how webkit handles it and what it expects. |
46 result.unmodifiedText[0] = '\r'; | 55 result.unmodifiedText[0] = '\r'; |
47 } | 56 } |
48 result.text[0] = result.unmodifiedText[0]; | 57 result.text[0] = result.unmodifiedText[0]; |
49 result.isSystemKey = is_system_key; | 58 result.isSystemKey = is_system_key; |
50 | 59 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 result.type = type; | 121 result.type = type; |
113 result.x = x; | 122 result.x = x; |
114 result.y = y; | 123 result.y = y; |
115 result.timeStampSeconds = time_sec; | 124 result.timeStampSeconds = time_sec; |
116 result.sourceDevice = blink::WebGestureDeviceTouchscreen; | 125 result.sourceDevice = blink::WebGestureDeviceTouchscreen; |
117 | 126 |
118 return result; | 127 return result; |
119 } | 128 } |
120 | 129 |
121 } // namespace content | 130 } // namespace content |
OLD | NEW |