Index: content/public/android/java/src/org/chromium/content/browser/input/ImeUtils.java
|
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/ImeUtils.java b/content/public/android/java/src/org/chromium/content/browser/input/ImeUtils.java
|
index 49726776c49baedb8e0e14ee3e365a438b160e87..d8081dac1bd598375292f78e16a71c0cb63d9823 100644
|
--- a/content/public/android/java/src/org/chromium/content/browser/input/ImeUtils.java
|
+++ b/content/public/android/java/src/org/chromium/content/browser/input/ImeUtils.java
|
@@ -46,10 +46,10 @@ public class ImeUtils {
|
}
|
|
int imeAction = 0;
|
+ boolean enterKeyAction = false;
|
if (inputMode == WebTextInputMode.DEFAULT) {
|
if (inputType == TextInputType.TEXT) {
|
// Normal text field
|
- imeAction = EditorInfo.IME_ACTION_GO;
|
if ((inputFlags & WebTextInputFlags.AUTOCORRECT_OFF) == 0) {
|
outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
|
}
|
@@ -59,33 +59,27 @@ public class ImeUtils {
|
if ((inputFlags & WebTextInputFlags.AUTOCORRECT_OFF) == 0) {
|
outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
|
}
|
- imeAction = EditorInfo.IME_ACTION_NONE;
|
} else if (inputType == TextInputType.PASSWORD) {
|
outAttrs.inputType =
|
InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD;
|
- imeAction = EditorInfo.IME_ACTION_GO;
|
} else if (inputType == TextInputType.SEARCH) {
|
imeAction = EditorInfo.IME_ACTION_SEARCH;
|
} else if (inputType == TextInputType.URL) {
|
outAttrs.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
|
- imeAction = EditorInfo.IME_ACTION_GO;
|
} else if (inputType == TextInputType.EMAIL) {
|
// Email
|
outAttrs.inputType =
|
InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS;
|
- imeAction = EditorInfo.IME_ACTION_GO;
|
} else if (inputType == TextInputType.TELEPHONE) {
|
// Telephone
|
// Number and telephone do not have both a Tab key and an
|
// action in default OSK, so set the action to NEXT
|
outAttrs.inputType = InputType.TYPE_CLASS_PHONE;
|
- imeAction = EditorInfo.IME_ACTION_NEXT;
|
} else if (inputType == TextInputType.NUMBER) {
|
// Number
|
outAttrs.inputType = InputType.TYPE_CLASS_NUMBER
|
| InputType.TYPE_NUMBER_VARIATION_NORMAL
|
| InputType.TYPE_NUMBER_FLAG_DECIMAL;
|
- imeAction = EditorInfo.IME_ACTION_NEXT;
|
}
|
} else {
|
switch (inputMode) {
|
@@ -128,6 +122,27 @@ public class ImeUtils {
|
}
|
|
outAttrs.imeOptions |= imeAction;
|
+
|
+ // For multiline text or any text input with key event listeners, ENTER key is needed.
|
+ if ((outAttrs.inputType & EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE) != 0) {
|
+ // For textarea that sends you to another webpage on enter key press using
|
+ // JavaScript, we will only show ENTER.
|
+ outAttrs.imeOptions |= EditorInfo.IME_ACTION_NONE;
|
+ enterKeyAction = true;
|
+ }
|
+
|
+ // If ENTER key is already applied, then don't apply NEXT as it can result display issues in
|
+ // IME
|
+ if (!enterKeyAction) {
|
+ if ((inputFlags & WebTextInputFlags.HAVE_NEXT_FOCUSABLE_ELEMENT) != 0) {
|
+ outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
|
+ } else if ((inputFlags & WebTextInputFlags.HAVE_PREVIOUS_FOCUSABLE_ELEMENT) != 0) {
|
+ // If ENTER/NEXT key is already applied, then don't apply PREVIOUS as it can result
|
+ // display issues in IME
|
+ outAttrs.imeOptions |= EditorInfo.IME_ACTION_PREVIOUS;
|
+ }
|
+ }
|
+
|
// Handling of autocapitalize. Blink will send the flag taking into account the element's
|
// type. This is not using AutocapitalizeNone because Android does not autocapitalize by
|
// default and there is no way to express no capitalization.
|
|