Bug 1634779 - pt 2. Partially revert Bug 1603006 r=kmag
[gecko.git] / dom / webidl / HTMLInputElement.webidl
blobae3614dc79595d212dd7e33dcb422c5cb66cdebf
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4  * You can obtain one at http://mozilla.org/MPL/2.0/.
5  *
6  * The origin of this IDL file is
7  * http://www.whatwg.org/specs/web-apps/current-work/#the-input-element
8  * http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
9  * https://wicg.github.io/entries-api/#idl-index
10  *
11  * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
12  * Opera Software ASA. You are granted a license to use, reproduce
13  * and create derivative works of this document.
14  */
16 enum SelectionMode {
17   "select",
18   "start",
19   "end",
20   "preserve",
23 interface XULControllers;
25 [Exposed=Window]
26 interface HTMLInputElement : HTMLElement {
27   [HTMLConstructor] constructor();
29   [CEReactions, Pure, SetterThrows]
30            attribute DOMString accept;
31   [CEReactions, Pure, SetterThrows]
32            attribute DOMString alt;
33   [CEReactions, Pure, SetterThrows]
34            attribute DOMString autocomplete;
35   [CEReactions, Pure, SetterThrows]
36            attribute boolean autofocus;
37   [CEReactions, Pure, SetterThrows, Pref="dom.capture.enabled"]
38            attribute DOMString capture;
39   [CEReactions, Pure, SetterThrows]
40            attribute boolean defaultChecked;
41   [Pure]
42            attribute boolean checked;
43            // Bug 850337 - attribute DOMString dirName;
44   [CEReactions, Pure, SetterThrows]
45            attribute boolean disabled;
46   readonly attribute HTMLFormElement? form;
47   [Pure]
48            attribute FileList? files;
49   [CEReactions, Pure, SetterThrows]
50            attribute DOMString formAction;
51   [CEReactions, Pure, SetterThrows]
52            attribute DOMString formEnctype;
53   [CEReactions, Pure, SetterThrows]
54            attribute DOMString formMethod;
55   [CEReactions, Pure, SetterThrows]
56            attribute boolean formNoValidate;
57   [CEReactions, Pure, SetterThrows]
58            attribute DOMString formTarget;
59   [CEReactions, Pure, SetterThrows]
60            attribute unsigned long height;
61   [Pure]
62            attribute boolean indeterminate;
63   [Pure]
64   readonly attribute HTMLElement? list;
65   [CEReactions, Pure, SetterThrows]
66            attribute DOMString max;
67   [CEReactions, Pure, SetterThrows]
68            attribute long maxLength;
69   [CEReactions, Pure, SetterThrows]
70            attribute DOMString min;
71   [CEReactions, Pure, SetterThrows]
72            attribute long minLength;
73   [CEReactions, Pure, SetterThrows]
74            attribute boolean multiple;
75   [CEReactions, Pure, SetterThrows]
76            attribute DOMString name;
77   [CEReactions, Pure, SetterThrows]
78            attribute DOMString pattern;
79   [CEReactions, Pure, SetterThrows]
80            attribute DOMString placeholder;
81   [CEReactions, Pure, SetterThrows]
82            attribute boolean readOnly;
83   [CEReactions, Pure, SetterThrows]
84            attribute boolean required;
85   [CEReactions, Pure, SetterThrows]
86            attribute unsigned long size;
87   [CEReactions, Pure, SetterNeedsSubjectPrincipal=NonSystem, SetterThrows]
88            attribute DOMString src;
89   [CEReactions, Pure, SetterThrows]
90            attribute DOMString step;
91   [CEReactions, Pure, SetterThrows]
92            attribute DOMString type;
93   [CEReactions, Pure, SetterThrows]
94            attribute DOMString defaultValue;
95   [CEReactions, Pure, SetterThrows, NeedsCallerType]
96            attribute [TreatNullAs=EmptyString] DOMString value;
97   [Throws, Func="HTMLInputElement::ValueAsDateEnabled"]
98            attribute object? valueAsDate;
99   [Pure, SetterThrows]
100            attribute unrestricted double valueAsNumber;
101   [CEReactions, SetterThrows]
102            attribute unsigned long width;
104   [Throws]
105   void stepUp(optional long n = 1);
106   [Throws]
107   void stepDown(optional long n = 1);
109   [Pure]
110   readonly attribute boolean willValidate;
111   [Pure]
112   readonly attribute ValidityState validity;
113   [Throws]
114   readonly attribute DOMString validationMessage;
115   boolean checkValidity();
116   boolean reportValidity();
117   void setCustomValidity(DOMString error);
119   readonly attribute NodeList? labels;
121   void select();
123   [Throws]
124            attribute unsigned long? selectionStart;
125   [Throws]
126            attribute unsigned long? selectionEnd;
127   [Throws]
128            attribute DOMString? selectionDirection;
129   [Throws]
130   void setRangeText(DOMString replacement);
131   [Throws]
132   void setRangeText(DOMString replacement, unsigned long start,
133     unsigned long end, optional SelectionMode selectionMode = "preserve");
134   [Throws]
135   void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction);
137   // also has obsolete members
140 partial interface HTMLInputElement {
141   [CEReactions, Pure, SetterThrows]
142            attribute DOMString align;
143   [CEReactions, Pure, SetterThrows]
144            attribute DOMString useMap;
147 // Mozilla extensions
149 partial interface HTMLInputElement {
150   [GetterThrows, ChromeOnly]
151   readonly attribute XULControllers?       controllers;
152   // Binaryname because we have a FragmentOrElement function named "TextLength()".
153   [NeedsCallerType, BinaryName="inputTextLength"]
154   readonly attribute long                  textLength;
156   [Throws, ChromeOnly]
157   sequence<DOMString> mozGetFileNameArray();
159   [ChromeOnly, Throws]
160   void mozSetFileNameArray(sequence<DOMString> fileNames);
162   [ChromeOnly]
163   void mozSetFileArray(sequence<File> files);
165   // This method is meant to use for testing only.
166   [ChromeOnly, Throws]
167   void mozSetDirectory(DOMString directoryPath);
169   // This method is meant to use for testing only.
170   [ChromeOnly]
171   void mozSetDndFilesAndDirectories(sequence<(File or Directory)> list);
173   boolean mozIsTextField(boolean aExcludePassword);
175   [ChromeOnly]
176   readonly attribute boolean hasBeenTypePassword;
178   [ChromeOnly]
179   attribute DOMString previewValue;
181   [ChromeOnly]
182   // This function will return null if @autocomplete is not defined for the
183   // current @type
184   AutocompleteInfo? getAutocompleteInfo();
187 interface mixin MozEditableElement {
188   // Returns an nsIEditor instance which is associated with the element.
189   // If the element can be associated with an editor but not yet created,
190   // this creates new one automatically.
191   [Pure, ChromeOnly, BinaryName="editorForBindings"]
192   readonly attribute nsIEditor? editor;
194   // Returns true if an nsIEditor instance has already been associated with
195   // the element.
196   [Pure, ChromeOnly]
197   readonly attribute boolean hasEditor;
199   // This is set to true if "input" event should be fired with InputEvent on
200   // the element.  Otherwise, i.e., if "input" event should be fired with
201   // Event, set to false.
202   [ChromeOnly]
203   readonly attribute boolean isInputEventTarget;
205   // This is similar to set .value on nsIDOMInput/TextAreaElements, but handling
206   // of the value change is closer to the normal user input, so 'change' event
207   // for example will be dispatched when focusing out the element.
208   [Func="IsChromeOrUAWidget", NeedsSubjectPrincipal]
209   void setUserInput(DOMString input);
212 HTMLInputElement includes MozEditableElement;
214 partial interface HTMLInputElement {
215   [Pref="dom.input.dirpicker", SetterThrows]
216   attribute boolean allowdirs;
218   [Pref="dom.input.dirpicker"]
219   readonly attribute boolean isFilesAndDirectoriesSupported;
221   [Throws, Pref="dom.input.dirpicker"]
222   Promise<sequence<(File or Directory)>> getFilesAndDirectories();
224   [Throws, Pref="dom.input.dirpicker"]
225   Promise<sequence<File>> getFiles(optional boolean recursiveFlag = false);
227   [Throws, Pref="dom.input.dirpicker"]
228   void chooseDirectory();
231 HTMLInputElement includes MozImageLoadingContent;
233 // https://wicg.github.io/entries-api/#idl-index
234 partial interface HTMLInputElement {
235   [Pref="dom.webkitBlink.filesystem.enabled", Frozen, Cached, Pure]
236   readonly attribute sequence<FileSystemEntry> webkitEntries;
238   [Pref="dom.webkitBlink.dirPicker.enabled", BinaryName="WebkitDirectoryAttr", SetterThrows]
239           attribute boolean webkitdirectory;
242 dictionary DateTimeValue {
243   long hour;
244   long minute;
245   long year;
246   long month;
247   long day;
250 partial interface HTMLInputElement {
251   [Pref="dom.forms.datetime", ChromeOnly]
252   DateTimeValue getDateTimeInputBoxValue();
254   [Pref="dom.forms.datetime", ChromeOnly]
255   readonly attribute Element? dateTimeBoxElement;
257   [Pref="dom.forms.datetime", ChromeOnly,
258    BinaryName="getMinimumAsDouble"]
259   double getMinimum();
261   [Pref="dom.forms.datetime", ChromeOnly,
262    BinaryName="getMaximumAsDouble"]
263   double getMaximum();
265   [Pref="dom.forms.datetime", Func="IsChromeOrUAWidget"]
266   void openDateTimePicker(optional DateTimeValue initialValue = {});
268   [Pref="dom.forms.datetime", Func="IsChromeOrUAWidget"]
269   void updateDateTimePicker(optional DateTimeValue value = {});
271   [Pref="dom.forms.datetime", Func="IsChromeOrUAWidget"]
272   void closeDateTimePicker();
274   [Pref="dom.forms.datetime", Func="IsChromeOrUAWidget"]
275   void setFocusState(boolean aIsFocused);
277   [Pref="dom.forms.datetime", Func="IsChromeOrUAWidget"]
278   void updateValidityState();
280   [Pref="dom.forms.datetime", Func="IsChromeOrUAWidget",
281    BinaryName="getStepAsDouble"]
282   double getStep();
284   [Pref="dom.forms.datetime", Func="IsChromeOrUAWidget",
285    BinaryName="getStepBaseAsDouble"]
286   double getStepBase();