Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(465)

Side by Side Diff: content/browser/renderer_host/input/web_input_event_builders_android.cc

Issue 1811553002: [Android] Synthetic composition event should have DomKey 'Unidentified' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/renderer_host/input/web_input_event_builders_android_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/input.h> 7 #include <android/input.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/browser/renderer_host/input/web_input_event_util.h" 10 #include "content/browser/renderer_host/input/web_input_event_util.h"
(...skipping 11 matching lines...) Expand all
22 using blink::WebMouseEvent; 22 using blink::WebMouseEvent;
23 using blink::WebMouseWheelEvent; 23 using blink::WebMouseWheelEvent;
24 using blink::WebPointerProperties; 24 using blink::WebPointerProperties;
25 using blink::WebTouchEvent; 25 using blink::WebTouchEvent;
26 using blink::WebTouchPoint; 26 using blink::WebTouchPoint;
27 27
28 namespace content { 28 namespace content {
29 29
30 namespace { 30 namespace {
31 31
32 const int kCompositionKeyCode = 229;
33
32 int WebInputEventToAndroidModifier(int web_modifier) { 34 int WebInputEventToAndroidModifier(int web_modifier) {
33 int android_modifier = 0; 35 int android_modifier = 0;
34 // Currently only Shift, CapsLock are used, add other modifiers if required. 36 // Currently only Shift, CapsLock are used, add other modifiers if required.
35 if (web_modifier & WebInputEvent::ShiftKey) 37 if (web_modifier & WebInputEvent::ShiftKey)
36 android_modifier |= AMETA_SHIFT_ON; 38 android_modifier |= AMETA_SHIFT_ON;
37 if (web_modifier & WebInputEvent::CapsLockOn) 39 if (web_modifier & WebInputEvent::CapsLockOn)
38 android_modifier |= AMETA_CAPS_LOCK_ON; 40 android_modifier |= AMETA_CAPS_LOCK_ON;
39 return android_modifier; 41 return android_modifier;
40 } 42 }
41 43
42 ui::DomKey GetDomKeyFromEvent( 44 ui::DomKey GetDomKeyFromEvent(
43 JNIEnv* env, 45 JNIEnv* env,
44 const base::android::JavaRef<jobject>& android_key_event, 46 const base::android::JavaRef<jobject>& android_key_event,
45 int keycode, 47 int keycode,
48 ui::DomCode dom_code,
46 int modifiers, 49 int modifiers,
47 int unicode_character) { 50 int unicode_character) {
51 // Chrome will send |keycode| COMPOSITION_KEY_CODE 229 for composition events,
52 // but 229 is also mapped to AKEYCODE_LAST_CHANNEL. Return UNIDENTIFIED if the
aelias_OOO_until_Jul13 2016/03/16 18:51:46 Since 229 can also be a valid keycode, it seems to
chongz 2016/03/16 19:50:15 I think it would be different. For example Hacker'
aelias_OOO_until_Jul13 2016/03/16 20:36:51 I'd just like us to resolve this namespace conflic
53 // key came from soft keyboard.
54 if (keycode == kCompositionKeyCode && !unicode_character &&
55 dom_code == ui::DomCode::NONE)
56 return ui::DomKey::UNIDENTIFIED;
chongz 2016/03/16 15:15:37 Cannot find a keyboard that produce this key, but
57
48 if (!unicode_character && env) { 58 if (!unicode_character && env) {
49 // According to spec |kAllowedModifiers| should be Shift and AltGr, however 59 // According to spec |kAllowedModifiers| should be Shift and AltGr, however
50 // Android doesn't have AltGr key and ImeAdapter::getModifiers won't pass it 60 // Android doesn't have AltGr key and ImeAdapter::getModifiers won't pass it
51 // either. 61 // either.
52 // According to discussion we want to honor CapsLock and possibly NumLock as 62 // According to discussion we want to honor CapsLock and possibly NumLock as
53 // well. https://github.com/w3c/uievents/issues/70 63 // well. https://github.com/w3c/uievents/issues/70
54 const int kAllowedModifiers = 64 const int kAllowedModifiers =
55 WebInputEvent::ShiftKey | WebInputEvent::CapsLockOn; 65 WebInputEvent::ShiftKey | WebInputEvent::CapsLockOn;
56 int fallback_modifiers = 66 int fallback_modifiers =
57 WebInputEventToAndroidModifier(modifiers & kAllowedModifiers); 67 WebInputEventToAndroidModifier(modifiers & kAllowedModifiers);
(...skipping 27 matching lines...) Expand all
85 if (scancode) 95 if (scancode)
86 dom_code = ui::KeycodeConverter::NativeKeycodeToDomCode(scancode); 96 dom_code = ui::KeycodeConverter::NativeKeycodeToDomCode(scancode);
87 result.type = type; 97 result.type = type;
88 result.modifiers = modifiers; 98 result.modifiers = modifiers;
89 result.timeStampSeconds = time_sec; 99 result.timeStampSeconds = time_sec;
90 result.windowsKeyCode = ui::LocatedToNonLocatedKeyboardCode( 100 result.windowsKeyCode = ui::LocatedToNonLocatedKeyboardCode(
91 ui::KeyboardCodeFromAndroidKeyCode(keycode)); 101 ui::KeyboardCodeFromAndroidKeyCode(keycode));
92 result.modifiers |= DomCodeToWebInputEventModifiers(dom_code); 102 result.modifiers |= DomCodeToWebInputEventModifiers(dom_code);
93 result.nativeKeyCode = keycode; 103 result.nativeKeyCode = keycode;
94 result.domCode = static_cast<int>(dom_code); 104 result.domCode = static_cast<int>(dom_code);
95 result.domKey = GetDomKeyFromEvent(env, android_key_event, keycode, modifiers, 105 result.domKey = GetDomKeyFromEvent(env, android_key_event, keycode, dom_code,
96 unicode_character); 106 modifiers, unicode_character);
97 result.unmodifiedText[0] = unicode_character; 107 result.unmodifiedText[0] = unicode_character;
98 if (result.windowsKeyCode == ui::VKEY_RETURN) { 108 if (result.windowsKeyCode == ui::VKEY_RETURN) {
99 // This is the same behavior as GTK: 109 // This is the same behavior as GTK:
100 // We need to treat the enter key as a key press of character \r. This 110 // We need to treat the enter key as a key press of character \r. This
101 // is apparently just how webkit handles it and what it expects. 111 // is apparently just how webkit handles it and what it expects.
102 result.unmodifiedText[0] = '\r'; 112 result.unmodifiedText[0] = '\r';
103 } 113 }
104 result.text[0] = result.unmodifiedText[0]; 114 result.text[0] = result.unmodifiedText[0];
105 result.isSystemKey = is_system_key; 115 result.isSystemKey = is_system_key;
106 result.setKeyIdentifierFromWindowsKeyCode(); 116 result.setKeyIdentifierFromWindowsKeyCode();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 result.type = type; 183 result.type = type;
174 result.x = x; 184 result.x = x;
175 result.y = y; 185 result.y = y;
176 result.timeStampSeconds = time_sec; 186 result.timeStampSeconds = time_sec;
177 result.sourceDevice = blink::WebGestureDeviceTouchscreen; 187 result.sourceDevice = blink::WebGestureDeviceTouchscreen;
178 188
179 return result; 189 return result;
180 } 190 }
181 191
182 } // namespace content 192 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/input/web_input_event_builders_android_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698