HTMLInputElement.webidl (9743B)
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 */ 15 16 enum SelectionMode { 17 "select", 18 "start", 19 "end", 20 "preserve", 21 }; 22 23 interface XULControllers; 24 25 [Exposed=Window] 26 interface HTMLInputElement : HTMLElement { 27 [HTMLConstructor] constructor(); 28 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, Pref="dom.capture.enabled"] 36 attribute DOMString capture; 37 [CEReactions, Pure, SetterThrows] 38 attribute boolean defaultChecked; 39 [Pure] 40 attribute boolean checked; 41 [CEReactions, Pure, SetterThrows] 42 attribute DOMString dirName; 43 [CEReactions, Pure, SetterThrows] 44 attribute boolean disabled; 45 readonly attribute HTMLFormElement? form; 46 [Pure] 47 attribute FileList? files; 48 [CEReactions, Pure, SetterThrows] 49 attribute DOMString formAction; 50 [CEReactions, Pure, SetterThrows] 51 attribute DOMString formEnctype; 52 [CEReactions, Pure, SetterThrows] 53 attribute DOMString formMethod; 54 [CEReactions, Pure, SetterThrows] 55 attribute boolean formNoValidate; 56 [CEReactions, Pure, SetterThrows] 57 attribute DOMString formTarget; 58 [CEReactions, Pure, SetterThrows] 59 attribute unsigned long height; 60 [Pure] 61 attribute boolean indeterminate; 62 [Pure] 63 readonly attribute HTMLDataListElement? list; 64 [CEReactions, Pure, SetterThrows] 65 attribute DOMString max; 66 [CEReactions, Pure, SetterThrows] 67 attribute long maxLength; 68 [CEReactions, Pure, SetterThrows] 69 attribute DOMString min; 70 [CEReactions, Pure, SetterThrows] 71 attribute long minLength; 72 [CEReactions, Pure, SetterThrows] 73 attribute boolean multiple; 74 [CEReactions, Pure, SetterThrows] 75 attribute DOMString name; 76 [CEReactions, Pure, SetterThrows] 77 attribute DOMString pattern; 78 [CEReactions, Pure, SetterThrows] 79 attribute DOMString placeholder; 80 [CEReactions, Pure, SetterThrows] 81 attribute boolean readOnly; 82 [CEReactions, Pure, SetterThrows] 83 attribute boolean required; 84 [CEReactions, Pure, SetterThrows] 85 attribute unsigned long size; 86 [CEReactions, Pure, SetterNeedsSubjectPrincipal=NonSystem, SetterThrows] 87 attribute DOMString src; 88 [CEReactions, Pure, SetterThrows] 89 attribute DOMString step; 90 [CEReactions, Pure, SetterThrows] 91 attribute DOMString type; 92 [CEReactions, Pure, SetterThrows] 93 attribute DOMString defaultValue; 94 [CEReactions, Pure, SetterThrows, NeedsCallerType] 95 attribute [LegacyNullToEmptyString] DOMString value; 96 [Throws] 97 attribute object? valueAsDate; 98 [Pure, SetterThrows] 99 attribute unrestricted double valueAsNumber; 100 [CEReactions, SetterThrows] 101 attribute unsigned long width; 102 103 [Throws] 104 undefined stepUp(optional long n = 1); 105 [Throws] 106 undefined stepDown(optional long n = 1); 107 108 [Pure] 109 readonly attribute boolean willValidate; 110 [Pure] 111 readonly attribute ValidityState validity; 112 [Throws] 113 readonly attribute DOMString validationMessage; 114 boolean checkValidity(); 115 boolean reportValidity(); 116 undefined setCustomValidity(DOMString error); 117 118 readonly attribute NodeList? labels; 119 120 undefined select(); 121 122 [Throws] 123 attribute unsigned long? selectionStart; 124 [Throws] 125 attribute unsigned long? selectionEnd; 126 [Throws] 127 attribute DOMString? selectionDirection; 128 [Throws] 129 undefined setRangeText(DOMString replacement); 130 [Throws] 131 undefined setRangeText(DOMString replacement, unsigned long start, 132 unsigned long end, optional SelectionMode selectionMode = "preserve"); 133 [Throws] 134 undefined setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction); 135 136 [Throws] 137 undefined showPicker(); 138 139 // also has obsolete members 140 }; 141 142 partial interface HTMLInputElement { 143 [CEReactions, Pure, SetterThrows] 144 attribute DOMString align; 145 [CEReactions, Pure, SetterThrows] 146 attribute DOMString useMap; 147 }; 148 149 // Mozilla extensions 150 151 partial interface HTMLInputElement { 152 [GetterThrows, ChromeOnly] 153 readonly attribute XULControllers? controllers; 154 // Binaryname because we have a FragmentOrElement function named "TextLength()". 155 [NeedsCallerType, BinaryName="inputTextLength"] 156 readonly attribute long textLength; 157 158 [Throws, ChromeOnly] 159 sequence<DOMString> mozGetFileNameArray(); 160 161 [ChromeOnly, Throws] 162 undefined mozSetFileNameArray(sequence<DOMString> fileNames); 163 164 [ChromeOnly] 165 undefined mozSetFileArray(sequence<File> files); 166 167 // This method is meant to use for testing only. 168 [ChromeOnly, Throws] 169 undefined mozSetDirectory(DOMString directoryPath); 170 171 // This method is meant to use for testing only. 172 [ChromeOnly] 173 undefined mozSetDndFilesAndDirectories(sequence<(File or Directory)> list); 174 175 // This method is meant to use for testing only. 176 [ChromeOnly, NewObject] 177 Promise<sequence<(File or Directory)>> getFilesAndDirectories(); 178 179 [ChromeOnly] 180 boolean mozIsTextField(boolean aExcludePassword); 181 182 [ChromeOnly] 183 readonly attribute boolean hasBeenTypePassword; 184 185 [ChromeOnly] 186 attribute DOMString previewValue; 187 188 // A string indicating that the value of the element has been autofilled: 189 // either "filled", "preview" or "". 190 [ChromeOnly] 191 attribute DOMString autofillState; 192 193 // Last value entered by the user, not by a script. 194 // NOTE(emilio): As of right now some execCommand triggered changes might be 195 // considered interactive. 196 [ChromeOnly] 197 readonly attribute DOMString lastInteractiveValue; 198 199 [ChromeOnly] 200 // This function will return null if @autocomplete is not defined for the 201 // current @type 202 AutocompleteInfo? getAutocompleteInfo(); 203 204 [ChromeOnly] 205 // The reveal password state for a type=password control. 206 attribute boolean revealPassword; 207 }; 208 209 interface mixin MozEditableElement { 210 // Returns an nsIEditor instance which is associated with the element. 211 // If the element can be associated with an editor but not yet created, 212 // this creates new one automatically. 213 [Pure, ChromeOnly, BinaryName="editorForBindings"] 214 readonly attribute nsIEditor? editor; 215 216 // Returns true if an nsIEditor instance has already been associated with 217 // the element. 218 [Pure, ChromeOnly] 219 readonly attribute boolean hasEditor; 220 221 // This is set to true if "input" event should be fired with InputEvent on 222 // the element. Otherwise, i.e., if "input" event should be fired with 223 // Event, set to false. 224 [ChromeOnly] 225 readonly attribute boolean isInputEventTarget; 226 227 // This is similar to set .value on nsIDOMInput/TextAreaElements, but handling 228 // of the value change is closer to the normal user input, so 'change' event 229 // for example will be dispatched when focusing out the element. 230 [Func="IsChromeOrUAWidget", NeedsSubjectPrincipal] 231 undefined setUserInput(DOMString input); 232 }; 233 234 HTMLInputElement includes MozEditableElement; 235 236 HTMLInputElement includes MozImageLoadingContent; 237 238 HTMLInputElement includes PopoverInvokerElement; 239 240 // https://wicg.github.io/entries-api/#idl-index 241 partial interface HTMLInputElement { 242 [Pref="dom.webkitBlink.filesystem.enabled", Frozen, Cached, Pure] 243 readonly attribute sequence<FileSystemEntry> webkitEntries; 244 245 [Pref="dom.webkitBlink.dirPicker.enabled", BinaryName="WebkitDirectoryAttr", SetterThrows] 246 attribute boolean webkitdirectory; 247 }; 248 249 // Chrome-only functions for datetime picker 250 251 dictionary DateTimeValue { 252 long hour; 253 long minute; 254 long year; 255 long month; 256 long day; 257 }; 258 259 partial interface HTMLInputElement { 260 [ChromeOnly] 261 DateTimeValue getDateTimeInputBoxValue(); 262 263 [ChromeOnly] 264 readonly attribute Element? dateTimeBoxElement; 265 266 [ChromeOnly, BinaryName="getMinimumAsDouble"] 267 double getMinimum(); 268 269 [ChromeOnly, BinaryName="getMaximumAsDouble"] 270 double getMaximum(); 271 272 [Func="IsChromeOrUAWidget"] 273 undefined openDateTimePicker(optional DateTimeValue initialValue = {}); 274 275 [Func="IsChromeOrUAWidget"] 276 undefined closeDateTimePicker(); 277 278 [Func="IsChromeOrUAWidget"] 279 undefined setOpenState(boolean aIsOpen); 280 281 [Func="IsChromeOrUAWidget"] 282 undefined setFocusState(boolean aIsFocused); 283 284 [Func="IsChromeOrUAWidget"] 285 undefined updateValidityState(); 286 287 [Func="IsChromeOrUAWidget", BinaryName="getStepAsDouble"] 288 double getStep(); 289 290 [Func="IsChromeOrUAWidget", BinaryName="getStepBaseAsDouble"] 291 double getStepBase(); 292 }; 293 294 // Chrome-only functions for color picker 295 296 dictionary InputPickerColor { 297 required float component1; 298 required float component2; 299 required float component3; 300 301 // bug 1919718 302 // required float alpha; 303 // required InputColorSpace colorSpace; 304 }; 305 306 partial interface HTMLInputElement { 307 [Func="IsChromeOrUAWidget"] 308 InputPickerColor getColor(); 309 310 [Func="IsChromeOrUAWidget"] 311 undefined setUserInputColor(InputPickerColor aColor); 312 };