Bug 1490661 - Part 1. Support HTML.enterKeyHint in Nighly. r=webidl,smaug,hsivonen

On mobile platform, "ENTER" key on software keyboard key can sometimes
change to "Next" and etc. Although Firefox OS/Firefox Android have
`mozactionhint` attribute for its behaviour, This is standardized version
of it.

Chrome and Safari already support it now, so I would like to support this
on Firefox/GeckoView Nightly.

Differential Revision: https://phabricator.services.mozilla.com/D79641
This commit is contained in:
Makoto Kato 2020-06-23 06:37:20 +00:00
Родитель 7686c6ddbd
Коммит f8d53560e0
7 изменённых файлов: 40 добавлений и 351 удалений

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

@ -122,6 +122,24 @@ static const nsAttrValue::EnumTable kInputmodeTable[] = {
{"search", NS_INPUTMODE_SEARCH},
{nullptr, 0}};
static const uint8_t NS_ENTERKEYHINT_ENTER = 1;
static const uint8_t NS_ENTERKEYHINT_DONE = 2;
static const uint8_t NS_ENTERKEYHINT_GO = 3;
static const uint8_t NS_ENTERKEYHINT_NEXT = 4;
static const uint8_t NS_ENTERKEYHINT_PREVIOUS = 5;
static const uint8_t NS_ENTERKEYHINT_SEARCH = 6;
static const uint8_t NS_ENTERKEYHINT_SEND = 7;
static const nsAttrValue::EnumTable kEnterKeyHintTable[] = {
{"enter", NS_ENTERKEYHINT_ENTER},
{"done", NS_ENTERKEYHINT_DONE},
{"go", NS_ENTERKEYHINT_GO},
{"next", NS_ENTERKEYHINT_NEXT},
{"previous", NS_ENTERKEYHINT_PREVIOUS},
{"search", NS_ENTERKEYHINT_SEARCH},
{"send", NS_ENTERKEYHINT_SEND},
{nullptr, 0}};
nsresult nsGenericHTMLElement::CopyInnerTo(Element* aDst) {
MOZ_ASSERT(!aDst->GetUncomposedDoc(),
"Should not CopyInnerTo an Element in a document");
@ -857,6 +875,10 @@ bool nsGenericHTMLElement::ParseAttribute(int32_t aNamespaceID,
if (aAttribute == nsGkAtoms::inputmode) {
return aResult.ParseEnumValue(aValue, kInputmodeTable, false);
}
if (aAttribute == nsGkAtoms::enterkeyhint) {
return aResult.ParseEnumValue(aValue, kEnterKeyHintTable, false);
}
}
return nsGenericHTMLElementBase::ParseAttribute(

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

@ -180,6 +180,13 @@ class nsGenericHTMLElement : public nsGenericHTMLElementBase {
SetHTMLAttr(nsGkAtoms::inputmode, aValue, aRv);
}
void GetEnterKeyHint(nsAString& aValue) {
GetEnumAttr(nsGkAtoms::enterkeyhint, nullptr, aValue);
}
void SetEnterKeyHint(const nsAString& aValue, ErrorResult& aRv) {
SetHTMLAttr(nsGkAtoms::enterkeyhint, aValue, aRv);
}
/**
* Determine whether an attribute is an event (onclick, etc.)
* @param aName the attribute

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

@ -52,6 +52,8 @@ interface HTMLElement : Element {
attribute boolean spellcheck;
[CEReactions, Pure, SetterThrows, Pref="dom.forms.inputmode"]
attribute DOMString inputMode;
[CEReactions, Pure, SetterThrows, Pref="dom.forms.enterkeyhint"]
attribute DOMString enterKeyHint;
attribute DOMString nonce;

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

@ -2026,6 +2026,12 @@
value: @IS_ANDROID@
mirror: always
# Is support for HTMLElement.enterKeyHint enabled?
- name: dom.forms.enterkeyhint
type: bool
value: @IS_NIGHTLY_BUILD@
mirror: always
# Is support for HTMLElement.inputMode enabled?
- name: dom.forms.inputmode
type: bool

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

@ -1,4 +1,4 @@
prefs: [dom.security.featurePolicy.enabled:true, dom.security.featurePolicy.experimental.enabled:true, dom.security.featurePolicy.header.enabled:true, dom.security.featurePolicy.webidl.enabled:true, dom.webcomponents.elementInternals.enabled:true, dom.forms.requestsubmit.enabled:true, dom.forms.inputmode:true]
prefs: [dom.security.featurePolicy.enabled:true, dom.security.featurePolicy.experimental.enabled:true, dom.security.featurePolicy.header.enabled:true, dom.security.featurePolicy.webidl.enabled:true, dom.webcomponents.elementInternals.enabled:true, dom.forms.requestsubmit.enabled:true, dom.forms.inputmode:true, dom.forms.enterkeyhint:true]
[idlharness.https.html?exclude=(Document|Window|HTML.*)]
[OffscreenCanvasRenderingContext2D interface: operation lineTo(unrestricted double, unrestricted double)]
expected: FAIL
@ -885,9 +885,6 @@ prefs: [dom.security.featurePolicy.enabled:true, dom.security.featurePolicy.expe
[HTMLInputElement interface: createInput("search") must inherit property "dirName" with the proper type]
expected: FAIL
[HTMLElement interface: attribute enterKeyHint]
expected: FAIL
[HTMLInputElement interface: createInput("checkbox") must inherit property "dirName" with the proper type]
expected: FAIL
@ -942,9 +939,6 @@ prefs: [dom.security.featurePolicy.enabled:true, dom.security.featurePolicy.expe
[HTMLInputElement interface: document.createElement("input") must inherit property "dirName" with the proper type]
expected: FAIL
[HTMLElement interface: document.createElement("noscript") must inherit property "enterKeyHint" with the proper type]
expected: FAIL
[HTMLMediaElement interface: new Audio() must inherit property "videoTracks" with the proper type]
expected: FAIL

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

@ -1,5 +1,5 @@
[reflection-misc.html]
prefs: [dom.dialog_element.enabled:true, dom.forms.inputmode:true]
prefs: [dom.dialog_element.enabled:true, dom.forms.inputmode:true, dom.forms.enterkeyhint:true]
[script.nonce: IDL set to ""]
expected: FAIL
@ -51,330 +51,6 @@
[script.nonce: IDL set to object "test-toString"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "send\\0"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to null]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to ""]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to true]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "go"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "o"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "revious"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to null]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "go\\0"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "nter"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "xgo"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "next"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to Infinity]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to object "test-valueOf"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "enter"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to NaN]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "ENTER"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "NEXT"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "SEARCH"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "xgo"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "next\\0"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "DONE"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to Infinity]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "send"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "enter\\0"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "done\\0"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "PREVIOUS"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "nter"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "GO"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "search"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "NEXT"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "next\\0"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "xsend"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "\\0"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "SEARCH"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "done"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "ext"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "previous\\0"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "xsearch"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "xenter"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "SEND"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to false]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "GO"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "send"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "xprevious"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to object "test-valueOf"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "PREVIOUS"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to undefined]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "enter\\0"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "earch"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo "]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to ""]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "go"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "search\\0"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to -Infinity]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to undefined]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "send\\0"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to 7]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "\\0"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "done\\0"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "end"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "ENTER"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "previous"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "xsend"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL get with DOM attribute unset]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "SEND"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "previous"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "xprevious"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to 1.5]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "5%"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "+100"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to ".5"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to 1.5]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "5%"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "+100"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to ".5"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "next"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to -Infinity]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo "]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "one"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "earch"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "xnext"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "xnext"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "enter"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "xdone"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "DONE"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "o"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "xsearch"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "search\\0"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "end"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to false]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "one"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "xenter"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "go\\0"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to true]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "ext"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "search"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to object "test-toString"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to 7]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "xdone"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to object "[object Object\]"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to object "[object Object\]"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to object "test-toString"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to NaN]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "previous\\0"]
expected: FAIL
[undefinedelement.enterKeyHint: typeof IDL attribute]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "done"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "revious"]
expected: FAIL
[script.autofocus: setAttribute() to NaN]
expected: FAIL
@ -1742,22 +1418,3 @@
[summary.autofocus: typeof IDL attribute]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "previouſ"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "ſearch"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "ſend"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "ſend"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "ſearch"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "previouſ"]
expected: FAIL

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

@ -410,6 +410,7 @@ STATIC_ATOMS = [
Atom("enctype", "enctype"),
Atom("end", "end"),
Atom("endEvent", "endEvent"),
Atom("enterkeyhint", "enterkeyhint"),
Atom("equalsize", "equalsize"),
Atom("error", "error"),
Atom("ethiopic_numeric", "ethiopic-numeric"),