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