Bug 1618759 - Part 3. Allow inputmode for non-input element. r=masayuki

Current WHATWG spec is that `inputmode` attribute supports non-input element.
I would like to remove input element check for bug 142484 that is
contenteditable support.

Microsoft IME, Google IME and etc refer 1st input scope that they support, so
we will add both input scopes from `type` and `inputmode`.

Depends on D68313

Differential Revision: https://phabricator.services.mozilla.com/D68314

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Makoto Kato 2020-04-07 22:30:30 +00:00
Родитель 3b55303417
Коммит 5010b729b6
2 изменённых файлов: 34 добавлений и 23 удалений

Просмотреть файл

@ -3966,17 +3966,14 @@ void TSFTextStore::SetInputScope(const nsString& aHTMLInputType,
bool aInPrivateBrowsing) {
mInputScopes.Clear();
// IME may refer only first input scope, but we will append inputmode's
// input scopes too like Chrome since IME may refer it.
IMEHandler::AppendInputScopeFromType(aHTMLInputType, mInputScopes);
IMEHandler::AppendInputScopeFromInputmode(aHTMLInputInputMode, mInputScopes);
if (aInPrivateBrowsing) {
mInputScopes.AppendElement(IS_PRIVATE);
}
if (aHTMLInputType.IsEmpty() || aHTMLInputType.EqualsLiteral("text")) {
IMEHandler::AppendInputScopeFromInputmode(aHTMLInputInputMode,
mInputScopes);
return;
}
IMEHandler::AppendInputScopeFromType(aHTMLInputType, mInputScopes);
}
int32_t TSFTextStore::GetRequestedAttrIndex(const TS_ATTRID& aAttrID) {

Просмотреть файл

@ -643,17 +643,15 @@ void IMEHandler::SetInputScopeForIMM32(nsWindow* aWindow,
}
AutoTArray<InputScope, 3> scopes;
// IME may refer only first input scope, but we will append inputmode's
// input scopes since IME may refer it like Chrome.
AppendInputScopeFromType(aHTMLInputType, scopes);
AppendInputScopeFromInputmode(aHTMLInputInputmode, scopes);
if (aInPrivateBrowsing) {
scopes.AppendElement(IS_PRIVATE);
}
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html
if (aHTMLInputType.IsEmpty() || aHTMLInputType.EqualsLiteral("text")) {
AppendInputScopeFromInputmode(aHTMLInputInputmode, scopes);
} else {
AppendInputScopeFromType(aHTMLInputType, scopes);
}
if (scopes.IsEmpty()) {
// At least, 1 item is necessary.
scopes.AppendElement(IS_DEFAULT);
@ -687,34 +685,50 @@ void IMEHandler::AppendInputScopeFromInputmode(const nsAString& aInputmode,
return;
}
// Don't append IS_SEARCH here for showing on-screen keyboard for URL.
aScopes.AppendElement(IS_URL);
if (!aScopes.Contains(IS_URL)) {
aScopes.AppendElement(IS_URL);
}
return;
}
// https://html.spec.whatwg.org/dev/interaction.html#attr-inputmode
if (aInputmode.EqualsLiteral("url")) {
aScopes.AppendElement(IS_URL);
if (!aScopes.Contains(IS_SEARCH)) {
aScopes.AppendElement(IS_URL);
}
return;
}
if (aInputmode.EqualsLiteral("email")) {
aScopes.AppendElement(IS_EMAIL_SMTPEMAILADDRESS);
if (!aScopes.Contains(IS_EMAIL_SMTPEMAILADDRESS)) {
aScopes.AppendElement(IS_EMAIL_SMTPEMAILADDRESS);
}
return;
}
if (aInputmode.EqualsLiteral("tel")) {
aScopes.AppendElement(IS_TELEPHONE_FULLTELEPHONENUMBER);
aScopes.AppendElement(IS_TELEPHONE_LOCALNUMBER);
if (!aScopes.Contains(IS_TELEPHONE_FULLTELEPHONENUMBER)) {
aScopes.AppendElement(IS_TELEPHONE_FULLTELEPHONENUMBER);
}
if (!aScopes.Contains(IS_TELEPHONE_LOCALNUMBER)) {
aScopes.AppendElement(IS_TELEPHONE_LOCALNUMBER);
}
return;
}
if (aInputmode.EqualsLiteral("numeric")) {
aScopes.AppendElement(IS_DIGITS);
if (!aScopes.Contains(IS_DIGITS)) {
aScopes.AppendElement(IS_DIGITS);
}
return;
}
if (aInputmode.EqualsLiteral("decimal")) {
aScopes.AppendElement(IS_NUMBER);
if (!aScopes.Contains(IS_NUMBER)) {
aScopes.AppendElement(IS_NUMBER);
}
return;
}
if (aInputmode.EqualsLiteral("search")) {
aScopes.AppendElement(IS_SEARCH);
if (!aScopes.Contains(IS_SEARCH)) {
aScopes.AppendElement(IS_SEARCH);
}
return;
}
}