| 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" | |
| 11 #include "ui/events/keycodes/dom/dom_code.h" | 10 #include "ui/events/keycodes/dom/dom_code.h" |
| 12 #include "ui/events/keycodes/dom/keycode_converter.h" | 11 #include "ui/events/keycodes/dom/keycode_converter.h" |
| 12 #include "ui/events/keycodes/keyboard_code_conversion.h" |
| 13 #include "ui/events/keycodes/keyboard_code_conversion_android.h" | 13 #include "ui/events/keycodes/keyboard_code_conversion_android.h" |
| 14 #include "ui/events/keycodes/keyboard_codes_posix.h" | 14 #include "ui/events/keycodes/keyboard_codes_posix.h" |
| 15 | 15 |
| 16 using blink::WebInputEvent; | 16 using blink::WebInputEvent; |
| 17 using blink::WebKeyboardEvent; | 17 using blink::WebKeyboardEvent; |
| 18 using blink::WebGestureEvent; | 18 using blink::WebGestureEvent; |
| 19 using blink::WebMouseEvent; | 19 using blink::WebMouseEvent; |
| 20 using blink::WebMouseWheelEvent; | 20 using blink::WebMouseWheelEvent; |
| 21 using blink::WebTouchEvent; | 21 using blink::WebTouchEvent; |
| 22 using blink::WebTouchPoint; | 22 using blink::WebTouchPoint; |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 | 25 |
| 26 WebKeyboardEvent WebKeyboardEventBuilder::Build(WebInputEvent::Type type, | 26 WebKeyboardEvent WebKeyboardEventBuilder::Build(WebInputEvent::Type type, |
| 27 int modifiers, | 27 int modifiers, |
| 28 double time_sec, | 28 double time_sec, |
| 29 int keycode, | 29 int keycode, |
| 30 int scancode, | 30 int scancode, |
| 31 int unicode_character, | 31 int unicode_character, |
| 32 bool is_system_key) { | 32 bool is_system_key) { |
| 33 DCHECK(WebInputEvent::isKeyboardEventType(type)); | 33 DCHECK(WebInputEvent::isKeyboardEventType(type)); |
| 34 WebKeyboardEvent result; | 34 WebKeyboardEvent result; |
| 35 | 35 |
| 36 ui::DomCode dom_code = ui::DomCode::NONE; | 36 ui::DomCode dom_code = ui::DomCode::NONE; |
| 37 if (scancode != 0) | 37 if (scancode != 0) |
| 38 dom_code = ui::KeycodeConverter::NativeKeycodeToDomCode(scancode); | 38 dom_code = ui::KeycodeConverter::NativeKeycodeToDomCode(scancode); |
| 39 result.type = type; | 39 result.type = type; |
| 40 result.modifiers = modifiers; | 40 result.modifiers = modifiers; |
| 41 result.timeStampSeconds = time_sec; | 41 result.timeStampSeconds = time_sec; |
| 42 ui::KeyboardCode windows_key_code = | 42 result.windowsKeyCode = ui::LocatedToNonLocatedKeyboardCode( |
| 43 ui::KeyboardCodeFromAndroidKeyCode(keycode); | 43 ui::KeyboardCodeFromAndroidKeyCode(keycode)); |
| 44 UpdateWindowsKeyCodeAndKeyIdentifier(&result, windows_key_code); | 44 result.modifiers |= DomCodeToWebInputEventModifiers(dom_code); |
| 45 result.modifiers |= GetLocationModifiersFromWindowsKeyCode(windows_key_code); | |
| 46 result.nativeKeyCode = keycode; | 45 result.nativeKeyCode = keycode; |
| 47 result.domCode = static_cast<int>(dom_code); | 46 result.domCode = static_cast<int>(dom_code); |
| 48 result.unmodifiedText[0] = unicode_character; | 47 result.unmodifiedText[0] = unicode_character; |
| 49 if (result.windowsKeyCode == ui::VKEY_RETURN) { | 48 if (result.windowsKeyCode == ui::VKEY_RETURN) { |
| 50 // This is the same behavior as GTK: | 49 // This is the same behavior as GTK: |
| 51 // We need to treat the enter key as a key press of character \r. This | 50 // We need to treat the enter key as a key press of character \r. This |
| 52 // is apparently just how webkit handles it and what it expects. | 51 // is apparently just how webkit handles it and what it expects. |
| 53 result.unmodifiedText[0] = '\r'; | 52 result.unmodifiedText[0] = '\r'; |
| 54 } | 53 } |
| 55 result.text[0] = result.unmodifiedText[0]; | 54 result.text[0] = result.unmodifiedText[0]; |
| 56 result.isSystemKey = is_system_key; | 55 result.isSystemKey = is_system_key; |
| 56 result.setKeyIdentifierFromWindowsKeyCode(); |
| 57 | 57 |
| 58 return result; | 58 return result; |
| 59 } | 59 } |
| 60 | 60 |
| 61 WebMouseEvent WebMouseEventBuilder::Build(blink::WebInputEvent::Type type, | 61 WebMouseEvent WebMouseEventBuilder::Build(blink::WebInputEvent::Type type, |
| 62 WebMouseEvent::Button button, | 62 WebMouseEvent::Button button, |
| 63 double time_sec, | 63 double time_sec, |
| 64 int window_x, | 64 int window_x, |
| 65 int window_y, | 65 int window_y, |
| 66 int modifiers, | 66 int modifiers, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 result.type = type; | 119 result.type = type; |
| 120 result.x = x; | 120 result.x = x; |
| 121 result.y = y; | 121 result.y = y; |
| 122 result.timeStampSeconds = time_sec; | 122 result.timeStampSeconds = time_sec; |
| 123 result.sourceDevice = blink::WebGestureDeviceTouchscreen; | 123 result.sourceDevice = blink::WebGestureDeviceTouchscreen; |
| 124 | 124 |
| 125 return result; | 125 return result; |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace content | 128 } // namespace content |
| OLD | NEW |