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

Side by Side Diff: content/browser/renderer_host/ime_adapter_android.cc

Issue 1378583003: Unstrangle unhandled key event callback for webview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changed variable names and comments Created 5 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ime_adapter_android.h" 5 #include "content/browser/renderer_host/ime_adapter_android.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <android/input.h> 8 #include <android/input.h>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 int action, 144 int action,
145 int modifiers, 145 int modifiers,
146 long time_ms, 146 long time_ms,
147 int key_code, 147 int key_code,
148 int scan_code, 148 int scan_code,
149 bool is_system_key, 149 bool is_system_key,
150 int unicode_char) { 150 int unicode_char) {
151 NativeWebKeyboardEvent event = NativeWebKeyboardEventFromKeyEvent( 151 NativeWebKeyboardEvent event = NativeWebKeyboardEventFromKeyEvent(
152 env, original_key_event, action, modifiers, 152 env, original_key_event, action, modifiers,
153 time_ms, key_code, scan_code, is_system_key, unicode_char); 153 time_ms, key_code, scan_code, is_system_key, unicode_char);
154 bool key_down_text_insertion = 154 bool create_char_event =
155 event.type == blink::WebInputEvent::RawKeyDown && event.text[0]; 155 event.type == blink::WebInputEvent::RawKeyDown && event.text[0];
156 // If we are going to follow up with a synthetic Char event, then that's the 156 // Even when we don't consume this event, we should not propagate it to
157 // one we expect to test if it's handled or unhandled, so skip handling the 157 // onUnhandledKeyEvent() because char event can still be consumed.
158 // "real" event in the browser. 158 event.skip_in_browser = create_char_event;
159 event.skip_in_browser = key_down_text_insertion;
160 rwhva_->SendKeyEvent(event); 159 rwhva_->SendKeyEvent(event);
161 if (key_down_text_insertion) { 160 if (create_char_event) {
162 // Send a Char event, but without an os_event since we don't want to 161 NativeWebKeyboardEvent char_event(
163 // roundtrip back to java such synthetic event. 162 original_key_event, blink::WebInputEvent::Char, modifiers,
164 NativeWebKeyboardEvent char_event(blink::WebInputEvent::Char, modifiers, 163 time_ms / 1000.0, key_code, scan_code, unicode_char, is_system_key);
165 time_ms / 1000.0, key_code, scan_code,
166 unicode_char,
167 is_system_key);
168 char_event.skip_in_browser = key_down_text_insertion;
169 rwhva_->SendKeyEvent(char_event); 164 rwhva_->SendKeyEvent(char_event);
170 } 165 }
171 return true; 166 return true;
172 } 167 }
173 168
174 void ImeAdapterAndroid::SetComposingText(JNIEnv* env, 169 void ImeAdapterAndroid::SetComposingText(JNIEnv* env,
175 const JavaParamRef<jobject>& obj, 170 const JavaParamRef<jobject>& obj,
176 const JavaParamRef<jobject>& text, 171 const JavaParamRef<jobject>& text,
177 const JavaParamRef<jstring>& text_str, 172 const JavaParamRef<jstring>& text_str,
178 int new_cursor_pos) { 173 int new_cursor_pos) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 315 }
321 316
322 WebContents* ImeAdapterAndroid::GetWebContents() { 317 WebContents* ImeAdapterAndroid::GetWebContents() {
323 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl(); 318 RenderWidgetHostImpl* rwh = GetRenderWidgetHostImpl();
324 if (!rwh) 319 if (!rwh)
325 return nullptr; 320 return nullptr;
326 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh)); 321 return WebContents::FromRenderViewHost(RenderViewHost::From(rwh));
327 } 322 }
328 323
329 } // namespace content 324 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698