Chromium Code Reviews| 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 <android/keycodes.h> | |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 8 #include "content/browser/renderer_host/input/motion_event_android.h" | 9 #include "content/browser/renderer_host/input/motion_event_android.h" |
| 9 #include "content/browser/renderer_host/input/web_input_event_util.h" | 10 #include "content/browser/renderer_host/input/web_input_event_util.h" |
| 10 #include "content/browser/renderer_host/input/web_input_event_util_posix.h" | |
| 11 #include "ui/events/keycodes/keyboard_code_conversion_android.h" | 11 #include "ui/events/keycodes/keyboard_code_conversion_android.h" |
| 12 #include "ui/events/keycodes/keyboard_codes_posix.h" | 12 #include "ui/events/keycodes/keyboard_codes_posix.h" |
| 13 | 13 |
| 14 using blink::WebInputEvent; | 14 using blink::WebInputEvent; |
| 15 using blink::WebKeyboardEvent; | 15 using blink::WebKeyboardEvent; |
| 16 using blink::WebGestureEvent; | 16 using blink::WebGestureEvent; |
| 17 using blink::WebMouseEvent; | 17 using blink::WebMouseEvent; |
| 18 using blink::WebMouseWheelEvent; | 18 using blink::WebMouseWheelEvent; |
| 19 using blink::WebTouchEvent; | 19 using blink::WebTouchEvent; |
| 20 using blink::WebTouchPoint; | 20 using blink::WebTouchPoint; |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 | 23 |
| 24 static blink::WebInputEvent::Modifiers GetLocationModifiersFromAndoridKeyCode( | |
|
Wez
2015/09/03 06:05:47
typo: Andorid -> Android
dtapuska
2015/09/03 13:39:40
Done.
| |
| 25 int key_code) { | |
| 26 switch (key_code) { | |
| 27 case AKEYCODE_ALT_LEFT: | |
| 28 case AKEYCODE_CTRL_LEFT: | |
| 29 case AKEYCODE_META_LEFT: | |
| 30 case AKEYCODE_SHIFT_LEFT: | |
| 31 return blink::WebInputEvent::IsLeft; | |
| 32 case AKEYCODE_ALT_RIGHT: | |
| 33 case AKEYCODE_CTRL_RIGHT: | |
| 34 case AKEYCODE_META_RIGHT: | |
| 35 case AKEYCODE_SHIFT_RIGHT: | |
| 36 return blink::WebInputEvent::IsRight; | |
| 37 case AKEYCODE_NUMPAD_0: | |
| 38 case AKEYCODE_NUMPAD_1: | |
| 39 case AKEYCODE_NUMPAD_2: | |
| 40 case AKEYCODE_NUMPAD_3: | |
| 41 case AKEYCODE_NUMPAD_4: | |
| 42 case AKEYCODE_NUMPAD_5: | |
| 43 case AKEYCODE_NUMPAD_6: | |
| 44 case AKEYCODE_NUMPAD_7: | |
| 45 case AKEYCODE_NUMPAD_8: | |
| 46 case AKEYCODE_NUMPAD_9: | |
| 47 case AKEYCODE_NUMPAD_DIVIDE: | |
| 48 case AKEYCODE_NUMPAD_MULTIPLY: | |
| 49 case AKEYCODE_NUMPAD_SUBTRACT: | |
| 50 case AKEYCODE_NUMPAD_ADD: | |
| 51 case AKEYCODE_NUMPAD_DOT: | |
| 52 return blink::WebInputEvent::IsKeyPad; | |
| 53 default: | |
| 54 return static_cast<blink::WebInputEvent::Modifiers>(0); | |
| 55 } | |
| 56 } | |
| 57 | |
| 24 WebKeyboardEvent WebKeyboardEventBuilder::Build(WebInputEvent::Type type, | 58 WebKeyboardEvent WebKeyboardEventBuilder::Build(WebInputEvent::Type type, |
| 25 int modifiers, | 59 int modifiers, |
| 26 double time_sec, | 60 double time_sec, |
| 27 int keycode, | 61 int keycode, |
| 28 int unicode_character, | 62 int unicode_character, |
| 29 bool is_system_key) { | 63 bool is_system_key) { |
| 30 DCHECK(WebInputEvent::isKeyboardEventType(type)); | 64 DCHECK(WebInputEvent::isKeyboardEventType(type)); |
| 31 WebKeyboardEvent result; | 65 WebKeyboardEvent result; |
| 32 | 66 |
| 33 result.type = type; | 67 result.type = type; |
| 34 result.modifiers = modifiers; | 68 result.modifiers = modifiers; |
| 35 result.timeStampSeconds = time_sec; | 69 result.timeStampSeconds = time_sec; |
| 36 ui::KeyboardCode windows_key_code = | 70 result.windowsKeyCode = ui::KeyboardCodeFromAndroidKeyCode(keycode); |
| 37 ui::KeyboardCodeFromAndroidKeyCode(keycode); | 71 |
|
Wez
2015/09/03 06:05:47
nit: Remove this blank line?
dtapuska
2015/09/03 13:39:40
Done.
| |
| 38 UpdateWindowsKeyCodeAndKeyIdentifier(&result, windows_key_code); | 72 result.modifiers |= GetLocationModifiersFromAndoridKeyCode(keycode); |
| 39 result.modifiers |= GetLocationModifiersFromWindowsKeyCode(windows_key_code); | |
| 40 result.nativeKeyCode = keycode; | 73 result.nativeKeyCode = keycode; |
| 41 result.unmodifiedText[0] = unicode_character; | 74 result.unmodifiedText[0] = unicode_character; |
| 42 if (result.windowsKeyCode == ui::VKEY_RETURN) { | 75 if (result.windowsKeyCode == ui::VKEY_RETURN) { |
| 43 // This is the same behavior as GTK: | 76 // This is the same behavior as GTK: |
| 44 // We need to treat the enter key as a key press of character \r. This | 77 // 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. | 78 // is apparently just how webkit handles it and what it expects. |
| 46 result.unmodifiedText[0] = '\r'; | 79 result.unmodifiedText[0] = '\r'; |
| 47 } | 80 } |
| 48 result.text[0] = result.unmodifiedText[0]; | 81 result.text[0] = result.unmodifiedText[0]; |
| 49 result.isSystemKey = is_system_key; | 82 result.isSystemKey = is_system_key; |
| 83 result.setKeyIdentifierFromWindowsKeyCode(); | |
| 50 | 84 |
| 51 return result; | 85 return result; |
| 52 } | 86 } |
| 53 | 87 |
| 54 WebMouseEvent WebMouseEventBuilder::Build(blink::WebInputEvent::Type type, | 88 WebMouseEvent WebMouseEventBuilder::Build(blink::WebInputEvent::Type type, |
| 55 WebMouseEvent::Button button, | 89 WebMouseEvent::Button button, |
| 56 double time_sec, | 90 double time_sec, |
| 57 int window_x, | 91 int window_x, |
| 58 int window_y, | 92 int window_y, |
| 59 int modifiers, | 93 int modifiers, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 result.type = type; | 146 result.type = type; |
| 113 result.x = x; | 147 result.x = x; |
| 114 result.y = y; | 148 result.y = y; |
| 115 result.timeStampSeconds = time_sec; | 149 result.timeStampSeconds = time_sec; |
| 116 result.sourceDevice = blink::WebGestureDeviceTouchscreen; | 150 result.sourceDevice = blink::WebGestureDeviceTouchscreen; |
| 117 | 151 |
| 118 return result; | 152 return result; |
| 119 } | 153 } |
| 120 | 154 |
| 121 } // namespace content | 155 } // namespace content |
| OLD | NEW |