OLD | NEW |
---|---|
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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 return androidKeyEventForCharacter(newtext.charAt(0)); | 374 return androidKeyEventForCharacter(newtext.charAt(0)); |
375 } else { | 375 } else { |
376 return null; | 376 return null; |
377 } | 377 } |
378 } | 378 } |
379 | 379 |
380 // The content has grown in length: assume the last character is the key that caused it. | 380 // The content has grown in length: assume the last character is the key that caused it. |
381 if (newtext.length() > oldtext.length() && newtext.startsWith(oldtext)) | 381 if (newtext.length() > oldtext.length() && newtext.startsWith(oldtext)) |
382 return androidKeyEventForCharacter(newtext.charAt(newtext.length() - 1)); | 382 return androidKeyEventForCharacter(newtext.charAt(newtext.length() - 1)); |
383 | 383 |
384 // The content has shrunk in length: assume that backspace was pressed. | 384 // The content has shrunk in length: assume that backspace was pressed, unless a deleted |
385 if (oldtext.length() > newtext.length() && oldtext.startsWith(newtext)) | 385 // character (last element of |oldtext|) has no corresponding key event. This prevents |
386 // Japanese IME compositions from being cleared on backspace (see crbug. com/422685). | |
387 if (oldtext.length() > newtext.length() && oldtext.startsWith(newtext) | |
388 && androidKeyEventForCharacter(oldtext.charAt(oldtext.length() - 1)) != null) | |
bcwhite
2015/01/09 22:52:44
Have you tested this as working? A potential prob
| |
386 return new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL); | 389 return new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL); |
387 | 390 |
388 // The content is unchanged or has undergone a complex change (i.e. not a simple tail | 391 // The content is unchanged or has undergone a complex change (i.e. not a simple tail |
389 // modification) so return an unknown key-code. | 392 // modification) so return an unknown key-code. |
390 return null; | 393 return null; |
391 } | 394 } |
392 | 395 |
393 void sendKeyEventWithKeyCode(int keyCode, int flags) { | 396 void sendKeyEventWithKeyCode(int keyCode, int flags) { |
394 long eventTime = SystemClock.uptimeMillis(); | 397 long eventTime = SystemClock.uptimeMillis(); |
395 mLastSyntheticKeyCode = keyCode; | 398 mLastSyntheticKeyCode = keyCode; |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
710 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid , | 713 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid , |
711 int before, int after); | 714 int before, int after); |
712 | 715 |
713 private native void nativeUnselect(long nativeImeAdapterAndroid); | 716 private native void nativeUnselect(long nativeImeAdapterAndroid); |
714 private native void nativeSelectAll(long nativeImeAdapterAndroid); | 717 private native void nativeSelectAll(long nativeImeAdapterAndroid); |
715 private native void nativeCut(long nativeImeAdapterAndroid); | 718 private native void nativeCut(long nativeImeAdapterAndroid); |
716 private native void nativeCopy(long nativeImeAdapterAndroid); | 719 private native void nativeCopy(long nativeImeAdapterAndroid); |
717 private native void nativePaste(long nativeImeAdapterAndroid); | 720 private native void nativePaste(long nativeImeAdapterAndroid); |
718 private native void nativeResetImeAdapter(long nativeImeAdapterAndroid); | 721 private native void nativeResetImeAdapter(long nativeImeAdapterAndroid); |
719 } | 722 } |
OLD | NEW |