Commit 08cf965c authored by Changwan Ryu's avatar Changwan Ryu Committed by Commit Bot

Enable numeric password for Chrome and WebView

Currently <input type='password' inputmode='numeric'> shows normal
password type virtual keyboard. With this change, it will show
numeric password type keyboard.

Bug: 1068182
Change-Id: I04f85ff240678b3f8854a84ad9227e1437b3300d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2139355
Commit-Queue: Changwan Ryu <changwan@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757537}
parent 53ffbe9d
...@@ -75,7 +75,6 @@ public class ImeUtils { ...@@ -75,7 +75,6 @@ public class ImeUtils {
} else if (inputType == TextInputType.NUMBER) { } else if (inputType == TextInputType.NUMBER) {
// Number // Number
outAttrs.inputType = InputType.TYPE_CLASS_NUMBER outAttrs.inputType = InputType.TYPE_CLASS_NUMBER
| InputType.TYPE_NUMBER_VARIATION_NORMAL
| InputType.TYPE_NUMBER_FLAG_DECIMAL; | InputType.TYPE_NUMBER_FLAG_DECIMAL;
} }
} else { } else {
...@@ -101,8 +100,10 @@ public class ImeUtils { ...@@ -101,8 +100,10 @@ public class ImeUtils {
| InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS; | InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS;
break; break;
case WebTextInputMode.NUMERIC: case WebTextInputMode.NUMERIC:
outAttrs.inputType = outAttrs.inputType = InputType.TYPE_CLASS_NUMBER;
InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_NORMAL; if (inputType == TextInputType.PASSWORD) {
outAttrs.inputType |= InputType.TYPE_NUMBER_VARIATION_PASSWORD;
}
break; break;
case WebTextInputMode.DECIMAL: case WebTextInputMode.DECIMAL:
outAttrs.inputType = outAttrs.inputType =
...@@ -126,7 +127,8 @@ public class ImeUtils { ...@@ -126,7 +127,8 @@ public class ImeUtils {
outAttrs.inputType |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; outAttrs.inputType |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
} }
if ((inputFlags & WebTextInputFlags.HAS_BEEN_PASSWORD_FIELD) != 0) { if ((inputFlags & WebTextInputFlags.HAS_BEEN_PASSWORD_FIELD) != 0
&& (outAttrs.inputType & InputType.TYPE_NUMBER_VARIATION_PASSWORD) == 0) {
outAttrs.inputType = outAttrs.inputType =
InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD; InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD;
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package org.chromium.content.browser.input; package org.chromium.content.browser.input;
import android.support.test.filters.SmallTest; import android.support.test.filters.SmallTest;
import android.text.InputType;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import org.junit.Assert; import org.junit.Assert;
...@@ -31,6 +32,22 @@ public class ImeInputModeTest { ...@@ -31,6 +32,22 @@ public class ImeInputModeTest {
mRule.setUpForUrl(ImeActivityTestRule.INPUT_MODE_HTML); mRule.setUpForUrl(ImeActivityTestRule.INPUT_MODE_HTML);
} }
@Test
@SmallTest
@Feature({"TextInput"})
public void testNumericPassword() throws Exception {
mRule.focusElement("input_numeric_password", true /* shouldShowKeyboard */);
mRule.waitForKeyboardStates(1, 0, 1, new Integer[] {TextInputType.PASSWORD},
new Integer[] {WebTextInputMode.NUMERIC});
Assert.assertNotNull(mRule.getInputMethodManagerWrapper().getInputConnection());
Assert.assertTrue(
(mRule.getConnectionFactory().getOutAttrs().inputType
& (InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD))
!= 0);
}
@Test @Test
@SmallTest @SmallTest
@Feature({"TextInput"}) @Feature({"TextInput"})
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
<div id="contenteditable_numeric" contenteditable inputMode="numeric"></div> <div id="contenteditable_numeric" contenteditable inputMode="numeric"></div>
<div id="contenteditable_decimal" contenteditable inputMode="decimal"></div> <div id="contenteditable_decimal" contenteditable inputMode="decimal"></div>
<div id="contenteditable_search" contenteditable inputMode="search"></div> <div id="contenteditable_search" contenteditable inputMode="search"></div>
<input type="password" inputMode="numeric" id="input_numeric_password" />
</body> </body>
<script> <script>
......
...@@ -200,4 +200,9 @@ void PasswordInputType::HandleKeydownEvent(KeyboardEvent& event) { ...@@ -200,4 +200,9 @@ void PasswordInputType::HandleKeydownEvent(KeyboardEvent& event) {
if (!event.DefaultHandled()) if (!event.DefaultHandled())
BaseTextInputType::HandleKeydownEvent(event); BaseTextInputType::HandleKeydownEvent(event);
} }
bool PasswordInputType::SupportsInputModeAttribute() const {
return true;
}
} // namespace blink } // namespace blink
...@@ -62,6 +62,7 @@ class PasswordInputType final : public BaseTextInputType { ...@@ -62,6 +62,7 @@ class PasswordInputType final : public BaseTextInputType {
void HandleBeforeTextInsertedEvent(BeforeTextInsertedEvent&) override; void HandleBeforeTextInsertedEvent(BeforeTextInsertedEvent&) override;
void HandleBlurEvent() override; void HandleBlurEvent() override;
bool SupportsInputModeAttribute() const override;
bool should_show_reveal_button_ = false; bool should_show_reveal_button_ = false;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment