Bug 768727 - Send '&' as composition string because some Gingerbread VKBs incorrectly map '&' key events. r=blassey
authorChris Peterson <cpeterson@mozilla.com>
Fri, 29 Jun 2012 12:06:03 -0700
changeset 97974 edd37b3c169d794dce5cb2c03f1d785d176f9ff6
parent 97973 f69ae9bc7c14f4fd19a2c98eb7f2ea509ba256e9
child 97975 b3d91c0e323ba37003151f55e41b27120e1b5060
push id11314
push usercpeterson@mozilla.com
push dateFri, 29 Jun 2012 22:37:04 +0000
treeherdermozilla-inbound@edd37b3c169d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey
bugs768727
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 768727 - Send '&' as composition string because some Gingerbread VKBs incorrectly map '&' key events. r=blassey
mobile/android/base/GeckoInputConnection.java
--- a/mobile/android/base/GeckoInputConnection.java
+++ b/mobile/android/base/GeckoInputConnection.java
@@ -634,22 +634,22 @@ public class GeckoInputConnection
         return sentKeyEvents;
     }
 
     private KeyEvent[] synthesizeKeyEvents(char inputChar) {
         // Some symbol characters produce unusual key events on Froyo and Gingerbread.
         if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
             switch (inputChar) {
                 case '&':
-                    // Gingerbread's KeyCharacterMap would return ALT+7, but we want SHIFT+7.
-                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
-                        return createKeyDownKeyUpEvents(KeyEvent.KEYCODE_7, KeyEvent.META_SHIFT_ON);
-                    }
-                    // Froyo's KeyCharacterMap will return the correct '&' key events below.
-                    break;
+                    // Some Gingerbread devices' KeyCharacterMaps return ALT+7 instead of SHIFT+7,
+                    // but some devices like the Droid Bionic treat SHIFT+7 as '7'. So just return
+                    // null and onTextChanged() will send "&" as a composition string instead of
+                    // KEY_DOWN + KEY_UP event pair. This may break web content listening for '&'
+                    // key events, but they will still receive "&" input event.
+                    return null;
 
                 case '<':
                 case '>':
                     // We can't synthesize KeyEvents for '<' or '>' because Froyo and Gingerbread
                     // return incorrect shifted char codes from KeyEvent.getUnicodeChar().
                     // Send these characters as composition strings, not key events.
                     return null;