mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 746142 - Part 1 - Add inputmode attribute to HTMLInputElement. r=mounir sr=smaug
This commit is contained in:
parent
63c4bd58bc
commit
e96e9dacf5
@ -445,6 +445,7 @@ GK_ATOM(inherits, "inherits")
|
||||
GK_ATOM(inheritstyle, "inheritstyle")
|
||||
GK_ATOM(initial_scale, "initial-scale")
|
||||
GK_ATOM(input, "input")
|
||||
GK_ATOM(inputmode, "inputmode")
|
||||
GK_ATOM(ins, "ins")
|
||||
GK_ATOM(insertafter, "insertafter")
|
||||
GK_ATOM(insertbefore, "insertbefore")
|
||||
|
@ -147,6 +147,28 @@ static const nsAttrValue::EnumTable kInputAutocompleteTable[] = {
|
||||
// Default autocomplete value is "".
|
||||
static const nsAttrValue::EnumTable* kInputDefaultAutocomplete = &kInputAutocompleteTable[0];
|
||||
|
||||
static const uint8_t NS_INPUT_INPUTMODE_AUTO = 0;
|
||||
static const uint8_t NS_INPUT_INPUTMODE_NUMERIC = 1;
|
||||
static const uint8_t NS_INPUT_INPUTMODE_DIGIT = 2;
|
||||
static const uint8_t NS_INPUT_INPUTMODE_UPPERCASE = 3;
|
||||
static const uint8_t NS_INPUT_INPUTMODE_LOWERCASE = 4;
|
||||
static const uint8_t NS_INPUT_INPUTMODE_TITLECASE = 5;
|
||||
static const uint8_t NS_INPUT_INPUTMODE_AUTOCAPITALIZED = 6;
|
||||
|
||||
static const nsAttrValue::EnumTable kInputInputmodeTable[] = {
|
||||
{ "auto", NS_INPUT_INPUTMODE_AUTO },
|
||||
{ "numeric", NS_INPUT_INPUTMODE_NUMERIC },
|
||||
{ "digit", NS_INPUT_INPUTMODE_DIGIT },
|
||||
{ "uppercase", NS_INPUT_INPUTMODE_UPPERCASE },
|
||||
{ "lowercase", NS_INPUT_INPUTMODE_LOWERCASE },
|
||||
{ "titlecase", NS_INPUT_INPUTMODE_TITLECASE },
|
||||
{ "autocapitalized", NS_INPUT_INPUTMODE_AUTOCAPITALIZED },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
// Default inputmode value is "auto".
|
||||
static const nsAttrValue::EnumTable* kInputDefaultInputmode = &kInputInputmodeTable[0];
|
||||
|
||||
const double nsHTMLInputElement::kDefaultStepBase = 0;
|
||||
const double nsHTMLInputElement::kStepAny = 0;
|
||||
|
||||
@ -866,6 +888,8 @@ NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLInputElement, FormMethod, formmethod,
|
||||
kFormDefaultMethod->tag)
|
||||
NS_IMPL_BOOL_ATTR(nsHTMLInputElement, FormNoValidate, formnovalidate)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLInputElement, FormTarget, formtarget)
|
||||
NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLInputElement, Inputmode, inputmode,
|
||||
kInputDefaultInputmode->tag)
|
||||
NS_IMPL_BOOL_ATTR(nsHTMLInputElement, Multiple, multiple)
|
||||
NS_IMPL_NON_NEGATIVE_INT_ATTR(nsHTMLInputElement, MaxLength, maxlength)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLInputElement, Name, name)
|
||||
@ -2741,6 +2765,9 @@ nsHTMLInputElement::ParseAttribute(int32_t aNamespaceID,
|
||||
if (aAttribute == nsGkAtoms::autocomplete) {
|
||||
return aResult.ParseEnumValue(aValue, kInputAutocompleteTable, false);
|
||||
}
|
||||
if (aAttribute == nsGkAtoms::inputmode) {
|
||||
return aResult.ParseEnumValue(aValue, kInputInputmodeTable, false);
|
||||
}
|
||||
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
|
||||
// We have to call |ParseImageAttribute| unconditionally since we
|
||||
// don't know if we're going to have a type="image" attribute yet,
|
||||
|
@ -110,6 +110,15 @@ reflectUnsignedInt({
|
||||
|
||||
// .indeterminate doesn't reflect a content attribute.
|
||||
|
||||
// .inputmode
|
||||
reflectLimitedEnumerated({
|
||||
element: document.createElement("input"),
|
||||
attribute: "inputmode",
|
||||
validValues: [ "numeric", "digit", "uppercase", "lowercase", "titlecase", "autocapitalized", "auto" ],
|
||||
invalidValues: [ "", "foo", "tulip" ],
|
||||
defaultValue: "auto"
|
||||
});
|
||||
|
||||
// TODO: list (HTMLElement)
|
||||
|
||||
// .max
|
||||
|
@ -20,7 +20,7 @@ interface nsIDOMValidityState;
|
||||
* http://www.whatwg.org/specs/web-apps/current-work/
|
||||
*/
|
||||
|
||||
[scriptable, uuid(c12471c8-155f-4368-9e8b-13a231e85f3b)]
|
||||
[scriptable, uuid(83984fd0-b0b2-11e1-afa6-0800200c9a66)]
|
||||
interface nsIDOMHTMLInputElement : nsIDOMHTMLElement
|
||||
{
|
||||
attribute DOMString accept;
|
||||
@ -43,6 +43,8 @@ interface nsIDOMHTMLInputElement : nsIDOMHTMLElement
|
||||
attribute unsigned long height;
|
||||
attribute boolean indeterminate;
|
||||
|
||||
attribute DOMString inputmode;
|
||||
|
||||
readonly attribute nsIDOMHTMLElement list;
|
||||
attribute DOMString max;
|
||||
attribute long maxLength;
|
||||
|
Loading…
Reference in New Issue
Block a user