Bug 1490661 - Part 5. Implement current spec of enterkeyhint on Android backend. r=geckoview-reviewers,agi
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Tue, 23 Jun 2020 06:38:10 +0000
changeset 536753 e3090704a024058cf6e6c2016887f8c251ff8964
parent 536752 bd285002fe0c3e392c8679b46020cd731df8ba4e
child 536754 2e38bb7fa4712e0cf4f599cfad0cf6a251eecef2
push id119658
push userm_kato@ga2.so-net.ne.jp
push dateTue, 23 Jun 2020 07:01:50 +0000
treeherderautoland@2e38bb7fa471 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgeckoview-reviewers, agi
bugs1490661
milestone79.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 1490661 - Part 5. Implement current spec of enterkeyhint on Android backend. r=geckoview-reviewers,agi When using `enterkeyhint` attribute, key event must be be fired as enter key. So by previous changeset, I change action type to `maybenext` if inferring action type without `enterkeyhint`. Also, `enterkeyhint` can have additional values (enter and previous), so Android back end should support it. Differential Revision: https://phabricator.services.mozilla.com/D79646
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoEditable.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoInputConnection.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoEditable.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoEditable.java
@@ -1653,26 +1653,30 @@ import android.view.inputmethod.EditorIn
                         InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE;
                 if (!typeHint.equalsIgnoreCase("text")) {
                     // auto-capitalized mode is the default for types other than text (bug 871884)
                     outAttrs.inputType |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
                 }
             }
         }
 
-        if (actionHint.equalsIgnoreCase("go")) {
+        if (actionHint.equals("enter")) {
+            outAttrs.imeOptions = EditorInfo.IME_ACTION_NONE;
+        } else if (actionHint.equals("go")) {
             outAttrs.imeOptions = EditorInfo.IME_ACTION_GO;
-        } else if (actionHint.equalsIgnoreCase("done")) {
+        } else if (actionHint.equals("done")) {
             outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE;
-        } else if (actionHint.equalsIgnoreCase("next")) {
+        } else if (actionHint.equals("next") || actionHint.equals("maybenext")) {
             outAttrs.imeOptions = EditorInfo.IME_ACTION_NEXT;
-        } else if (actionHint.equalsIgnoreCase("search") ||
-                typeHint.equalsIgnoreCase("search")) {
+        } else if (actionHint.equals("previous")) {
+            outAttrs.imeOptions = EditorInfo.IME_ACTION_PREVIOUS;
+        } else if (actionHint.equals("search") ||
+                typeHint.equals("search")) {
             outAttrs.imeOptions = EditorInfo.IME_ACTION_SEARCH;
-        } else if (actionHint.equalsIgnoreCase("send")) {
+        } else if (actionHint.equals("send")) {
             outAttrs.imeOptions = EditorInfo.IME_ACTION_SEND;
         } else if (actionHint.length() > 0) {
             if (DEBUG)
                 Log.w(LOGTAG, "Unexpected actionHint=\"" + actionHint + "\"");
             outAttrs.actionLabel = actionHint;
         }
 
         if ((flags & SessionTextInput.EditableListener.IME_FLAG_PRIVATE_BROWSING) != 0) {
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoInputConnection.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoInputConnection.java
@@ -224,17 +224,18 @@ import java.lang.reflect.Proxy;
                 Clipboard.setText(view.getContext(), copiedText);
                 break;
         }
         return true;
     }
 
     @Override
     public boolean performEditorAction(final int editorAction) {
-        if (editorAction == EditorInfo.IME_ACTION_PREVIOUS) {
+        if (editorAction == EditorInfo.IME_ACTION_PREVIOUS &&
+            !mIMEActionHint.equals("previous")) {
             // This action is [Previous] key on FireTV's keyboard.
             // [Previous] closes software keyboard, and don't generate any keyboard event.
             getView().post(new Runnable() {
                 @Override
                 public void run() {
                     getInputDelegate().hideSoftInput(mSession);
                 }
             });
@@ -634,17 +635,19 @@ import java.lang.reflect.Proxy;
         mEditableClient.sendKeyEvent(getView(), event.getAction(), translatedEvent);
         return false; // seems to always return false
     }
 
     private KeyEvent translateKey(final int keyCode, final @NonNull KeyEvent event) {
         switch (keyCode) {
             case KeyEvent.KEYCODE_ENTER:
                 if ((event.getFlags() & KeyEvent.FLAG_EDITOR_ACTION) != 0 &&
-                        mIMEActionHint.equalsIgnoreCase("next")) {
+                        mIMEActionHint.equals("maybenext")) {
+                    // XXX It is not good to dispatch tab key for web compatibility.
+                    // See https://github.com/w3c/uievents/issues/253 and bug 1600540.
                     return new KeyEvent(event.getDownTime(), event.getEventTime(), event.getAction(), KeyEvent.KEYCODE_TAB, 0);
                 }
                 break;
         }
         return event;
     }
 
     // Called by OnDefaultKeyEvent handler, up from Gecko