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

Unified Diff: content/browser/renderer_host/ime_adapter_android.cc

Issue 2206053002: Use KeyDown instead of RawKeyDown for Android key events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove alt-left test case and rename assert method Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/ime_adapter_android.cc
diff --git a/content/browser/renderer_host/ime_adapter_android.cc b/content/browser/renderer_host/ime_adapter_android.cc
index 47a060f50313db29773fb95e2fdf0e6a6c8e3f64..dc4022618bad2347d2407ccd4dfaa3115e8d31a9 100644
--- a/content/browser/renderer_host/ime_adapter_android.cc
+++ b/content/browser/renderer_host/ime_adapter_android.cc
@@ -42,30 +42,24 @@ namespace {
// Maps a java KeyEvent into a NativeWebKeyboardEvent.
// |java_key_event| is used to maintain a globalref for KeyEvent.
-// |action| will help determine the WebInputEvent type.
+// |type| will determine the WebInputEvent type.
// type, |modifiers|, |time_ms|, |key_code|, |unicode_char| is used to create
// WebKeyboardEvent. |key_code| is also needed ad need to treat the enter key
// as a key press of character \r.
NativeWebKeyboardEvent NativeWebKeyboardEventFromKeyEvent(
JNIEnv* env,
const base::android::JavaRef<jobject>& java_key_event,
- int action,
+ int type,
int modifiers,
long time_ms,
int key_code,
int scan_code,
bool is_system_key,
int unicode_char) {
- blink::WebInputEvent::Type type = blink::WebInputEvent::Undefined;
- if (action == AKEY_EVENT_ACTION_DOWN)
- type = blink::WebInputEvent::RawKeyDown;
- else if (action == AKEY_EVENT_ACTION_UP)
- type = blink::WebInputEvent::KeyUp;
- else
- NOTREACHED() << "Invalid Android key event action: " << action;
- return NativeWebKeyboardEvent(env, java_key_event, type, modifiers,
- time_ms / 1000.0, key_code, scan_code,
- unicode_char, is_system_key);
+ return NativeWebKeyboardEvent(env, java_key_event,
+ static_cast<blink::WebInputEvent::Type>(type),
+ modifiers, time_ms / 1000.0, key_code,
+ scan_code, unicode_char, is_system_key);
}
} // anonymous namespace
@@ -127,25 +121,11 @@ ImeAdapterAndroid::~ImeAdapterAndroid() {
Java_ImeAdapter_detach(env, obj.obj());
}
-bool ImeAdapterAndroid::SendSyntheticKeyEvent(JNIEnv*,
- const JavaParamRef<jobject>&,
- int type,
- long time_ms,
- int key_code,
- int modifiers,
- int text) {
- NativeWebKeyboardEvent event(static_cast<blink::WebInputEvent::Type>(type),
- modifiers, time_ms / 1000.0, key_code, 0,
- text, false /* is_system_key */);
- rwhva_->SendKeyEvent(event);
- return true;
-}
-
bool ImeAdapterAndroid::SendKeyEvent(
JNIEnv* env,
const JavaParamRef<jobject>&,
const JavaParamRef<jobject>& original_key_event,
- int action,
+ int type,
int modifiers,
long time_ms,
int key_code,
@@ -153,25 +133,9 @@ bool ImeAdapterAndroid::SendKeyEvent(
bool is_system_key,
int unicode_char) {
NativeWebKeyboardEvent event = NativeWebKeyboardEventFromKeyEvent(
- env, original_key_event, action, modifiers,
- time_ms, key_code, scan_code, is_system_key, unicode_char);
- bool key_down_text_insertion =
- event.type == blink::WebInputEvent::RawKeyDown && event.text[0];
- // If we are going to follow up with a synthetic Char event, then that's the
- // one we expect to test if it's handled or unhandled, so skip handling the
- // "real" event in the browser.
- event.skip_in_browser = key_down_text_insertion;
+ env, original_key_event, type, modifiers,
+ time_ms / 1000.0, key_code, scan_code, is_system_key, unicode_char);
rwhva_->SendKeyEvent(event);
- if (key_down_text_insertion) {
- // Send a Char event, but without an os_event since we don't want to
- // roundtrip back to java such synthetic event.
- NativeWebKeyboardEvent char_event(blink::WebInputEvent::Char, modifiers,
- time_ms / 1000.0, key_code, scan_code,
- unicode_char,
- is_system_key);
- char_event.skip_in_browser = key_down_text_insertion;
- rwhva_->SendKeyEvent(char_event);
- }
return true;
}

Powered by Google App Engine
This is Rietveld 408576698