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

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: Updating unittest. 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
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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 int modifiers = 0; 423 int modifiers = 0;
424 if (keyEvent != null) { 424 if (keyEvent != null) {
425 keyCode = keyEvent.getKeyCode(); 425 keyCode = keyEvent.getKeyCode();
426 modifiers = getModifiers(keyEvent.getMetaState()); 426 modifiers = getModifiers(keyEvent.getMetaState());
427 } else if (!textStr.equals(mLastComposeText)) { 427 } else if (!textStr.equals(mLastComposeText)) {
428 keyCode = KeyEvent.KEYCODE_UNKNOWN; 428 keyCode = KeyEvent.KEYCODE_UNKNOWN;
429 } else { 429 } else {
430 keyCode = -1; 430 keyCode = -1;
431 } 431 }
432 432
433 // If this is a commit with no previous composition, then treat it a s a native 433 // If this is a single-character commit with no previous composition , then treat it as
434 // KeyDown/KeyUp pair with no composition rather than a synthetic pa ir with 434 // a native KeyDown/KeyUp pair with no composition rather than a syn thetic pair with
435 // composition below. 435 // composition below.
436 if (keyCode > 0 && isCommit && mLastComposeText == null) { 436 if (keyCode > 0 && isCommit && mLastComposeText == null && textStr.l ength() == 1) {
437 mLastSyntheticKeyCode = keyCode; 437 mLastSyntheticKeyCode = keyCode;
438 return translateAndSendNativeEvents(keyEvent, 0) 438 return translateAndSendNativeEvents(keyEvent, 0)
439 && translateAndSendNativeEvents( 439 && translateAndSendNativeEvents(
440 KeyEvent.changeAction(keyEvent, KeyEvent.ACTION_ UP), 0); 440 KeyEvent.changeAction(keyEvent, KeyEvent.ACTION_ UP), 0);
441 } 441 }
442 442
443 // FIXME: Use WebTextInputFlags.AutocompleteOff. We need this hack t o enable merge into
bcwhite 2015/01/13 15:32:08 Dev should have used WebTextInputFlags.Autocomplet
444 // into Beta to fix http://crbug.com/422685 .
445 final int textInputFlagAutocompleteOff = 1 << 1;
446
447 // If we do not have autocomplete=off, then always send compose even ts rather than a
448 // guessed keyCode. This addresses http://crbug.com/422685 .
449 if ((mTextInputFlags & textInputFlagAutocompleteOff) == 0) {
450 keyCode = COMPOSITION_KEY_CODE;
451 modifiers = 0;
452 }
453
443 // When typing, there is no issue sending KeyDown and KeyUp events a round the 454 // 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 455 // 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 456 // 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 457 // 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 458 // 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 459 // event itself causes the action. The net result below is that the Renderer calls
449 // cancelComposition() and then Android starts anew with setComposin gRegion(). 460 // cancelComposition() and then Android starts anew with setComposin gRegion().
450 // This stopping and restarting of composition could be a source of problems 461 // This stopping and restarting of composition could be a source of problems
451 // with 3rd party keyboards. 462 // with 3rd party keyboards.
452 // 463 //
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid , 721 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid ,
711 int before, int after); 722 int before, int after);
712 723
713 private native void nativeUnselect(long nativeImeAdapterAndroid); 724 private native void nativeUnselect(long nativeImeAdapterAndroid);
714 private native void nativeSelectAll(long nativeImeAdapterAndroid); 725 private native void nativeSelectAll(long nativeImeAdapterAndroid);
715 private native void nativeCut(long nativeImeAdapterAndroid); 726 private native void nativeCut(long nativeImeAdapterAndroid);
716 private native void nativeCopy(long nativeImeAdapterAndroid); 727 private native void nativeCopy(long nativeImeAdapterAndroid);
717 private native void nativePaste(long nativeImeAdapterAndroid); 728 private native void nativePaste(long nativeImeAdapterAndroid);
718 private native void nativeResetImeAdapter(long nativeImeAdapterAndroid); 729 private native void nativeResetImeAdapter(long nativeImeAdapterAndroid);
719 } 730 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698