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