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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java

Issue 834293002: Fix problem with accents caused by race condition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java b/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java
index 3e2f111591977e37911cac8ff8d64883b2087f06..600af6833d497c231748c83fdb95969f1cf5c741 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java
@@ -391,6 +391,14 @@ public class AdapterInputConnection extends BaseInputConnection {
return mImeAdapter.translateAndSendNativeEvents(event, NO_ACCENT);
}
+ // Some keys we just want to pass events straight through. This allows
+ // proper "repeating key" behavior with physical keyboards.
+ int eventKeyCode = event.getKeyCode();
+ if (eventKeyCode == KeyEvent.KEYCODE_DEL || eventKeyCode == KeyEvent.KEYCODE_FORWARD_DEL) {
+ mPendingAccent = 0;
+ return mImeAdapter.translateAndSendNativeEvents(event, NO_ACCENT);
+ }
+
int unicodeChar = event.getUnicodeChar();
// If this is a key-up, and backspace/del or if the key has a character representation,
@@ -429,7 +437,6 @@ public class AdapterInputConnection extends BaseInputConnection {
return true;
}
}
- mImeAdapter.translateAndSendNativeEvents(event, mPendingAccent);
// Physical keyboards also have their events come through here though not
// by BaseInputConnection. In order to support "accent" key sequences
@@ -440,9 +447,11 @@ public class AdapterInputConnection extends BaseInputConnection {
// Copy class variable to local because class version may get indirectly
// cleared by the deleteSurroundingText() call below.
int pendingAccent = mPendingAccent;
+ int nextAccent = mPendingAccent;
if ((unicodeChar & KeyCharacterMap.COMBINING_ACCENT) != 0) {
- pendingAccent = unicodeChar & KeyCharacterMap.COMBINING_ACCENT_MASK;
+ pendingAccent = NO_ACCENT;
+ nextAccent = unicodeChar & KeyCharacterMap.COMBINING_ACCENT_MASK;
} else if (pendingAccent != NO_ACCENT) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
int combined = KeyEvent.getDeadChar(pendingAccent, unicodeChar);
@@ -456,16 +465,18 @@ public class AdapterInputConnection extends BaseInputConnection {
// Previous accent doesn't combine with this character
// so assume both are completely independent.
pendingAccent = NO_ACCENT;
+ nextAccent = NO_ACCENT;
}
}
if (event.getAction() == KeyEvent.ACTION_UP) {
// Forget accent after release of key being accented.
- pendingAccent = NO_ACCENT;
+ nextAccent = NO_ACCENT;
}
}
- mPendingAccent = pendingAccent;
+ mImeAdapter.translateAndSendNativeEvents(event, pendingAccent);
+ mPendingAccent = nextAccent;
return true;
}

Powered by Google App Engine
This is Rietveld 408576698