Bug 1387889 - Don't pass along metastate of synthesized keys. r=esawin, a=gchang
authorJim Chen <nchen@mozilla.com>
Tue, 29 Aug 2017 00:06:30 -0400
changeset 423876 2b4f305aed0addd8ebc65ba0b4667db9a81754b2
parent 423875 346027fa6dc3beaa9b336a107276fbbd8d175005
child 423877 234a1abc97dd5c39c5ba8fecdee115fcdfbd4520
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin, gchang
Bug 1387889 - Don't pass along metastate of synthesized keys. r=esawin, a=gchang Some key events synthesized from strings can have modifier metastates. For example, from the sharp S character, we synthesize an S key with Alt metastate. However, we don't actually want to pass the Alt metastate to Gecko because the Alt meta key is not actually pressed in this case. MozReview-Commit-ID: 5XYheyAgqdn
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoEditable.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoEditable.java
@@ -117,18 +117,26 @@ final class GeckoEditable extends IGecko
                 unicodeChar >= ' '               ? unicodeChar :
                 unmodifiedMetaState != metaState ? unmodifiedUnicodeChar : 0;
         // If a modifier (e.g. meta key) caused a different character to be entered, we
         // drop that modifier from the metastate for the generated keypress event.
         final int keyPressMetaState = (unicodeChar >= ' ' &&
                 unicodeChar != unmodifiedUnicodeChar) ? unmodifiedMetaState : metaState;
+        // For synthesized keys, ignore modifier metastates from the synthesized event,
+        // because the synthesized modifier metastates don't reflect the actual state of
+        // the meta keys (bug 1387889). For example, the Latin sharp S (U+00DF) is
+        // synthesized as Alt+S, but we don't want the Alt metastate because the Alt key
+        // is not actually pressed in this case.
+        final int keyUpDownMetaState =
+                isSynthesizedImeKey ? (unmodifiedMetaState | savedMetaState) : metaState;
         child.onKeyEvent(action, event.getKeyCode(), event.getScanCode(),
-                   metaState, keyPressMetaState, event.getEventTime(),
+                   keyUpDownMetaState, keyPressMetaState, event.getEventTime(),
                    domPrintableKeyValue, event.getRepeatCount(), event.getFlags(),
                    isSynthesizedImeKey, event);
      * Class that encapsulates asynchronous text editing. There are two copies of the
      * text, a current copy and a shadow copy. Both can be modified independently through
      * the current*** and shadow*** methods, respectively. The current copy can only be