Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsIDOMNode.idl" |
michael@0 | 7 | |
michael@0 | 8 | interface nsIDOMMozNamedAttrMap; |
michael@0 | 9 | |
michael@0 | 10 | /** |
michael@0 | 11 | * The nsIDOMElement interface represents an element in an HTML or |
michael@0 | 12 | * XML document. |
michael@0 | 13 | * |
michael@0 | 14 | * For more information on this interface please see |
michael@0 | 15 | * http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-element |
michael@0 | 16 | */ |
michael@0 | 17 | |
michael@0 | 18 | [scriptable, uuid(989422ef-120d-4d29-8a56-6aa2505a8b02)] |
michael@0 | 19 | interface nsIDOMElement : nsIDOMNode |
michael@0 | 20 | { |
michael@0 | 21 | readonly attribute DOMString tagName; |
michael@0 | 22 | |
michael@0 | 23 | /** |
michael@0 | 24 | * Returns a DOMTokenList object reflecting the class attribute. |
michael@0 | 25 | */ |
michael@0 | 26 | readonly attribute nsISupports classList; |
michael@0 | 27 | |
michael@0 | 28 | readonly attribute nsIDOMMozNamedAttrMap attributes; |
michael@0 | 29 | DOMString getAttribute(in DOMString name); |
michael@0 | 30 | DOMString getAttributeNS(in DOMString namespaceURI, |
michael@0 | 31 | in DOMString localName); |
michael@0 | 32 | void setAttribute(in DOMString name, |
michael@0 | 33 | in DOMString value); |
michael@0 | 34 | void setAttributeNS(in DOMString namespaceURI, |
michael@0 | 35 | in DOMString qualifiedName, |
michael@0 | 36 | in DOMString value); |
michael@0 | 37 | void removeAttribute(in DOMString name); |
michael@0 | 38 | void removeAttributeNS(in DOMString namespaceURI, |
michael@0 | 39 | in DOMString localName); |
michael@0 | 40 | boolean hasAttribute(in DOMString name); |
michael@0 | 41 | boolean hasAttributeNS(in DOMString namespaceURI, |
michael@0 | 42 | in DOMString localName); |
michael@0 | 43 | |
michael@0 | 44 | // Obsolete methods. |
michael@0 | 45 | nsIDOMAttr getAttributeNode(in DOMString name); |
michael@0 | 46 | nsIDOMAttr setAttributeNode(in nsIDOMAttr newAttr); |
michael@0 | 47 | nsIDOMAttr removeAttributeNode(in nsIDOMAttr oldAttr); |
michael@0 | 48 | nsIDOMAttr getAttributeNodeNS(in DOMString namespaceURI, |
michael@0 | 49 | in DOMString localName); |
michael@0 | 50 | nsIDOMAttr setAttributeNodeNS(in nsIDOMAttr newAttr) |
michael@0 | 51 | raises(DOMException); |
michael@0 | 52 | |
michael@0 | 53 | nsIDOMHTMLCollection getElementsByTagName(in DOMString name); |
michael@0 | 54 | nsIDOMHTMLCollection getElementsByTagNameNS(in DOMString namespaceURI, |
michael@0 | 55 | in DOMString localName); |
michael@0 | 56 | /** |
michael@0 | 57 | * Retrieve elements matching all classes listed in a |
michael@0 | 58 | * space-separated string. |
michael@0 | 59 | */ |
michael@0 | 60 | nsIDOMHTMLCollection getElementsByClassName(in DOMString classes); |
michael@0 | 61 | |
michael@0 | 62 | /** |
michael@0 | 63 | * Returns a live nsIDOMNodeList of the current child elements. |
michael@0 | 64 | */ |
michael@0 | 65 | [binaryname(ChildElements)] |
michael@0 | 66 | readonly attribute nsIDOMNodeList children; |
michael@0 | 67 | /** |
michael@0 | 68 | * Similar as the attributes on nsIDOMNode, but navigates just elements |
michael@0 | 69 | * rather than all nodes. |
michael@0 | 70 | */ |
michael@0 | 71 | readonly attribute nsIDOMElement firstElementChild; |
michael@0 | 72 | readonly attribute nsIDOMElement lastElementChild; |
michael@0 | 73 | readonly attribute nsIDOMElement previousElementSibling; |
michael@0 | 74 | readonly attribute nsIDOMElement nextElementSibling; |
michael@0 | 75 | /** |
michael@0 | 76 | * Returns the number of child nodes that are nsIDOMElements. |
michael@0 | 77 | */ |
michael@0 | 78 | readonly attribute unsigned long childElementCount; |
michael@0 | 79 | |
michael@0 | 80 | [binaryname(MozRemove)] |
michael@0 | 81 | void remove(); |
michael@0 | 82 | |
michael@0 | 83 | // CSSOM View |
michael@0 | 84 | /** |
michael@0 | 85 | * Retrieve a list of rectangles, one for each CSS border-box associated with |
michael@0 | 86 | * the element. The coordinates are in CSS pixels, and relative to |
michael@0 | 87 | * the top-left of the document's viewport, unless the document |
michael@0 | 88 | * has an SVG foreignobject ancestor, in which case the coordinates are |
michael@0 | 89 | * relative to the top-left of the content box of the nearest SVG foreignobject |
michael@0 | 90 | * ancestor. The coordinates are calculated as if every scrollable element |
michael@0 | 91 | * is scrolled to its default position. |
michael@0 | 92 | * |
michael@0 | 93 | * Note: the boxes of overflowing children do not affect these rectangles. |
michael@0 | 94 | * Note: some elements have empty CSS boxes. Those return empty rectangles, |
michael@0 | 95 | * but the coordinates may still be meaningful. |
michael@0 | 96 | * Note: some elements have no CSS boxes (including display:none elements, |
michael@0 | 97 | * HTML AREA elements, and SVG elements that do not render). Those return |
michael@0 | 98 | * an empty list. |
michael@0 | 99 | */ |
michael@0 | 100 | nsIDOMClientRectList getClientRects(); |
michael@0 | 101 | |
michael@0 | 102 | /** |
michael@0 | 103 | * Returns the union of all rectangles in the getClientRects() list. Empty |
michael@0 | 104 | * rectangles are ignored, except that if all rectangles are empty, |
michael@0 | 105 | * we return an empty rectangle positioned at the top-left of the first |
michael@0 | 106 | * rectangle in getClientRects(). |
michael@0 | 107 | */ |
michael@0 | 108 | nsIDOMClientRect getBoundingClientRect(); |
michael@0 | 109 | |
michael@0 | 110 | /** |
michael@0 | 111 | * The vertical scroll position of the element, or 0 if the element is not |
michael@0 | 112 | * scrollable. This property may be assigned a value to change the |
michael@0 | 113 | * vertical scroll position. |
michael@0 | 114 | */ |
michael@0 | 115 | attribute long scrollTop; |
michael@0 | 116 | |
michael@0 | 117 | /** |
michael@0 | 118 | * The horizontal scroll position of the element, or 0 if the element is not |
michael@0 | 119 | * scrollable. This property may be assigned a value to change the |
michael@0 | 120 | * horizontal scroll position. |
michael@0 | 121 | */ |
michael@0 | 122 | attribute long scrollLeft; |
michael@0 | 123 | |
michael@0 | 124 | /** |
michael@0 | 125 | * The width of the scrollable area of the element. If the element is not |
michael@0 | 126 | * scrollable, scrollWidth is equivalent to the offsetWidth. |
michael@0 | 127 | */ |
michael@0 | 128 | readonly attribute long scrollWidth; |
michael@0 | 129 | |
michael@0 | 130 | /** |
michael@0 | 131 | * The height of the scrollable area of the element. If the element is not |
michael@0 | 132 | * scrollable, scrollHeight is equivalent to the offsetHeight. |
michael@0 | 133 | */ |
michael@0 | 134 | readonly attribute long scrollHeight; |
michael@0 | 135 | |
michael@0 | 136 | /** |
michael@0 | 137 | * The height in CSS pixels of the element's top border. |
michael@0 | 138 | */ |
michael@0 | 139 | readonly attribute long clientTop; |
michael@0 | 140 | |
michael@0 | 141 | /** |
michael@0 | 142 | * The width in CSS pixels of the element's left border and scrollbar |
michael@0 | 143 | * if it is present on the left side. |
michael@0 | 144 | */ |
michael@0 | 145 | readonly attribute long clientLeft; |
michael@0 | 146 | |
michael@0 | 147 | /** |
michael@0 | 148 | * The height in CSS pixels of the element's padding box. If the element is |
michael@0 | 149 | * scrollable, the scroll bars are included inside this width. |
michael@0 | 150 | */ |
michael@0 | 151 | readonly attribute long clientWidth; |
michael@0 | 152 | |
michael@0 | 153 | /** |
michael@0 | 154 | * The width in CSS pixels of the element's padding box. If the element is |
michael@0 | 155 | * scrollable, the scroll bars are included inside this height. |
michael@0 | 156 | */ |
michael@0 | 157 | readonly attribute long clientHeight; |
michael@0 | 158 | |
michael@0 | 159 | /* The maximum offset that the element can be scrolled to |
michael@0 | 160 | (i.e., the value that scrollLeft/scrollTop would be clamped to if they were |
michael@0 | 161 | set to arbitrarily large values. */ |
michael@0 | 162 | readonly attribute long scrollLeftMax; |
michael@0 | 163 | readonly attribute long scrollTopMax; |
michael@0 | 164 | |
michael@0 | 165 | |
michael@0 | 166 | // Selectors API |
michael@0 | 167 | /** |
michael@0 | 168 | * Returns whether this element would be selected by the given selector |
michael@0 | 169 | * string. |
michael@0 | 170 | * |
michael@0 | 171 | * See <http://dev.w3.org/2006/webapi/selectors-api2/#matchesselector> |
michael@0 | 172 | */ |
michael@0 | 173 | boolean mozMatchesSelector([Null(Stringify)] in DOMString selector); |
michael@0 | 174 | |
michael@0 | 175 | |
michael@0 | 176 | // Proprietary extensions |
michael@0 | 177 | /** |
michael@0 | 178 | * Set this during a mousedown event to grab and retarget all mouse events |
michael@0 | 179 | * to this element until the mouse button is released or releaseCapture is |
michael@0 | 180 | * called. If retargetToElement is true, then all events are targetted at |
michael@0 | 181 | * this element. If false, events can also fire at descendants of this |
michael@0 | 182 | * element. |
michael@0 | 183 | * |
michael@0 | 184 | */ |
michael@0 | 185 | void setCapture([optional] in boolean retargetToElement); |
michael@0 | 186 | |
michael@0 | 187 | /** |
michael@0 | 188 | * If this element has captured the mouse, release the capture. If another |
michael@0 | 189 | * element has captured the mouse, this method has no effect. |
michael@0 | 190 | */ |
michael@0 | 191 | void releaseCapture(); |
michael@0 | 192 | |
michael@0 | 193 | // Mozilla extensions |
michael@0 | 194 | /** |
michael@0 | 195 | * Requests that this element be made the full-screen element, as per the DOM |
michael@0 | 196 | * full-screen api. |
michael@0 | 197 | * |
michael@0 | 198 | * @see <https://wiki.mozilla.org/index.php?title=Gecko:FullScreenAPI> |
michael@0 | 199 | */ |
michael@0 | 200 | void mozRequestFullScreen(); |
michael@0 | 201 | |
michael@0 | 202 | /** |
michael@0 | 203 | * Requests that this element be made the pointer-locked element, as per the DOM |
michael@0 | 204 | * pointer lock api. |
michael@0 | 205 | * |
michael@0 | 206 | * @see <http://dvcs.w3.org/hg/pointerlock/raw-file/default/index.html> |
michael@0 | 207 | */ |
michael@0 | 208 | void mozRequestPointerLock(); |
michael@0 | 209 | |
michael@0 | 210 | /** |
michael@0 | 211 | * Return nodes that match a given CSS selector. |
michael@0 | 212 | * |
michael@0 | 213 | * @see <http://dev.w3.org/2006/webapi/selectors-api/> |
michael@0 | 214 | */ |
michael@0 | 215 | nsIDOMElement querySelector([Null(Stringify)] in DOMString selectors); |
michael@0 | 216 | nsIDOMNodeList querySelectorAll([Null(Stringify)] in DOMString selectors); |
michael@0 | 217 | }; |