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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java

Issue 842493004: [Clank IME] Make keyCode detection sensitive to autocomplete=on|off. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix modifiers and directly check autocomplete instead. Created 5 years, 11 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 package org.chromium.content.browser.input; 5 package org.chromium.content.browser.input;
6 6
7 import android.os.Handler; 7 import android.os.Handler;
8 import android.os.ResultReceiver; 8 import android.os.ResultReceiver;
9 import android.os.SystemClock; 9 import android.os.SystemClock;
10 import android.text.Editable; 10 import android.text.Editable;
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 mViewEmbedder.onImeEvent(); 412 mViewEmbedder.onImeEvent();
413 413
414 String textStr = text.toString(); 414 String textStr = text.toString();
415 int keyCode = shouldSendKeyEventWithKeyCode(textStr); 415 int keyCode = shouldSendKeyEventWithKeyCode(textStr);
416 long timeStampMs = SystemClock.uptimeMillis(); 416 long timeStampMs = SystemClock.uptimeMillis();
417 417
418 if (keyCode != COMPOSITION_KEY_CODE) { 418 if (keyCode != COMPOSITION_KEY_CODE) {
419 sendKeyEventWithKeyCode(keyCode, 419 sendKeyEventWithKeyCode(keyCode,
420 KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE) ; 420 KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE) ;
421 } else { 421 } else {
422 KeyEvent keyEvent = getTypedKeyEventGuess(mLastComposeText, textStr) ; 422 KeyEvent keyEvent = null;
423 // If autocomplete off then use heuristic to compute keyEvent.
bcwhite 2015/01/12 20:46:54 You don't need this change. Always call Guess so
huangs 2015/01/12 20:52:37 Done.
424 if ((mTextInputFlags & sTextInputFlagAutocompleteOff) != 0) {
425 keyEvent = getTypedKeyEventGuess(mLastComposeText, textStr);
426 }
423 int modifiers = 0; 427 int modifiers = 0;
424 if (keyEvent != null) { 428 if (keyEvent != null) {
425 keyCode = keyEvent.getKeyCode(); 429 keyCode = keyEvent.getKeyCode();
426 modifiers = getModifiers(keyEvent.getMetaState()); 430 modifiers = getModifiers(keyEvent.getMetaState());
427 } else if (!textStr.equals(mLastComposeText)) { 431 } else if (!textStr.equals(mLastComposeText)) {
428 keyCode = KeyEvent.KEYCODE_UNKNOWN; 432 keyCode = KeyEvent.KEYCODE_UNKNOWN;
429 } else { 433 } else {
430 keyCode = -1; 434 keyCode = -1;
431 } 435 }
432 436
433 // If this is a commit with no previous composition, then treat it a s a native 437 // If this is a commit with no previous composition, then treat it a s a native
434 // KeyDown/KeyUp pair with no composition rather than a synthetic pa ir with 438 // KeyDown/KeyUp pair with no composition rather than a synthetic pa ir with
435 // composition below. 439 // composition below.
436 if (keyCode > 0 && isCommit && mLastComposeText == null) { 440 if (keyCode > 0 && isCommit && mLastComposeText == null) {
437 mLastSyntheticKeyCode = keyCode; 441 mLastSyntheticKeyCode = keyCode;
438 return translateAndSendNativeEvents(keyEvent, 0) 442 return translateAndSendNativeEvents(keyEvent, 0)
439 && translateAndSendNativeEvents( 443 && translateAndSendNativeEvents(
440 KeyEvent.changeAction(keyEvent, KeyEvent.ACTION_ UP), 0); 444 KeyEvent.changeAction(keyEvent, KeyEvent.ACTION_ UP), 0);
441 } 445 }
442 446
447 if ((mTextInputFlags & sTextInputFlagAutocompleteOff) == 0) {
bcwhite 2015/01/12 20:46:54 Comment above stating why with reference to the is
huangs 2015/01/12 20:52:37 Done.
448 keyCode = COMPOSITION_KEY_CODE;
449 modifiers = 0;
450 }
451
443 // When typing, there is no issue sending KeyDown and KeyUp events a round the 452 // When typing, there is no issue sending KeyDown and KeyUp events a round the
444 // composition event because those key events do nothing (other than call JS 453 // composition event because those key events do nothing (other than call JS
445 // handlers). Typing does not cause changes outside of a KeyPress e vent which 454 // handlers). Typing does not cause changes outside of a KeyPress e vent which
446 // we don't call here. However, if the key-code is a control key su ch as 455 // we don't call here. However, if the key-code is a control key su ch as
447 // KEYCODE_DEL then there never is an associated KeyPress event and the KeyDown 456 // KEYCODE_DEL then there never is an associated KeyPress event and the KeyDown
448 // event itself causes the action. The net result below is that the Renderer calls 457 // event itself causes the action. The net result below is that the Renderer calls
449 // cancelComposition() and then Android starts anew with setComposin gRegion(). 458 // cancelComposition() and then Android starts anew with setComposin gRegion().
450 // This stopping and restarting of composition could be a source of problems 459 // This stopping and restarting of composition could be a source of problems
451 // with 3rd party keyboards. 460 // with 3rd party keyboards.
452 // 461 //
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid , 719 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid ,
711 int before, int after); 720 int before, int after);
712 721
713 private native void nativeUnselect(long nativeImeAdapterAndroid); 722 private native void nativeUnselect(long nativeImeAdapterAndroid);
714 private native void nativeSelectAll(long nativeImeAdapterAndroid); 723 private native void nativeSelectAll(long nativeImeAdapterAndroid);
715 private native void nativeCut(long nativeImeAdapterAndroid); 724 private native void nativeCut(long nativeImeAdapterAndroid);
716 private native void nativeCopy(long nativeImeAdapterAndroid); 725 private native void nativeCopy(long nativeImeAdapterAndroid);
717 private native void nativePaste(long nativeImeAdapterAndroid); 726 private native void nativePaste(long nativeImeAdapterAndroid);
718 private native void nativeResetImeAdapter(long nativeImeAdapterAndroid); 727 private native void nativeResetImeAdapter(long nativeImeAdapterAndroid);
719 } 728 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698