michael@0: /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsIDOMNode.idl" michael@0: michael@0: interface nsIDOMMozNamedAttrMap; michael@0: michael@0: /** michael@0: * The nsIDOMElement interface represents an element in an HTML or michael@0: * XML document. michael@0: * michael@0: * For more information on this interface please see michael@0: * http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-element michael@0: */ michael@0: michael@0: [scriptable, uuid(989422ef-120d-4d29-8a56-6aa2505a8b02)] michael@0: interface nsIDOMElement : nsIDOMNode michael@0: { michael@0: readonly attribute DOMString tagName; michael@0: michael@0: /** michael@0: * Returns a DOMTokenList object reflecting the class attribute. michael@0: */ michael@0: readonly attribute nsISupports classList; michael@0: michael@0: readonly attribute nsIDOMMozNamedAttrMap attributes; michael@0: DOMString getAttribute(in DOMString name); michael@0: DOMString getAttributeNS(in DOMString namespaceURI, michael@0: in DOMString localName); michael@0: void setAttribute(in DOMString name, michael@0: in DOMString value); michael@0: void setAttributeNS(in DOMString namespaceURI, michael@0: in DOMString qualifiedName, michael@0: in DOMString value); michael@0: void removeAttribute(in DOMString name); michael@0: void removeAttributeNS(in DOMString namespaceURI, michael@0: in DOMString localName); michael@0: boolean hasAttribute(in DOMString name); michael@0: boolean hasAttributeNS(in DOMString namespaceURI, michael@0: in DOMString localName); michael@0: michael@0: // Obsolete methods. michael@0: nsIDOMAttr getAttributeNode(in DOMString name); michael@0: nsIDOMAttr setAttributeNode(in nsIDOMAttr newAttr); michael@0: nsIDOMAttr removeAttributeNode(in nsIDOMAttr oldAttr); michael@0: nsIDOMAttr getAttributeNodeNS(in DOMString namespaceURI, michael@0: in DOMString localName); michael@0: nsIDOMAttr setAttributeNodeNS(in nsIDOMAttr newAttr) michael@0: raises(DOMException); michael@0: michael@0: nsIDOMHTMLCollection getElementsByTagName(in DOMString name); michael@0: nsIDOMHTMLCollection getElementsByTagNameNS(in DOMString namespaceURI, michael@0: in DOMString localName); michael@0: /** michael@0: * Retrieve elements matching all classes listed in a michael@0: * space-separated string. michael@0: */ michael@0: nsIDOMHTMLCollection getElementsByClassName(in DOMString classes); michael@0: michael@0: /** michael@0: * Returns a live nsIDOMNodeList of the current child elements. michael@0: */ michael@0: [binaryname(ChildElements)] michael@0: readonly attribute nsIDOMNodeList children; michael@0: /** michael@0: * Similar as the attributes on nsIDOMNode, but navigates just elements michael@0: * rather than all nodes. michael@0: */ michael@0: readonly attribute nsIDOMElement firstElementChild; michael@0: readonly attribute nsIDOMElement lastElementChild; michael@0: readonly attribute nsIDOMElement previousElementSibling; michael@0: readonly attribute nsIDOMElement nextElementSibling; michael@0: /** michael@0: * Returns the number of child nodes that are nsIDOMElements. michael@0: */ michael@0: readonly attribute unsigned long childElementCount; michael@0: michael@0: [binaryname(MozRemove)] michael@0: void remove(); michael@0: michael@0: // CSSOM View michael@0: /** michael@0: * Retrieve a list of rectangles, one for each CSS border-box associated with michael@0: * the element. The coordinates are in CSS pixels, and relative to michael@0: * the top-left of the document's viewport, unless the document michael@0: * has an SVG foreignobject ancestor, in which case the coordinates are michael@0: * relative to the top-left of the content box of the nearest SVG foreignobject michael@0: * ancestor. The coordinates are calculated as if every scrollable element michael@0: * is scrolled to its default position. michael@0: * michael@0: * Note: the boxes of overflowing children do not affect these rectangles. michael@0: * Note: some elements have empty CSS boxes. Those return empty rectangles, michael@0: * but the coordinates may still be meaningful. michael@0: * Note: some elements have no CSS boxes (including display:none elements, michael@0: * HTML AREA elements, and SVG elements that do not render). Those return michael@0: * an empty list. michael@0: */ michael@0: nsIDOMClientRectList getClientRects(); michael@0: michael@0: /** michael@0: * Returns the union of all rectangles in the getClientRects() list. Empty michael@0: * rectangles are ignored, except that if all rectangles are empty, michael@0: * we return an empty rectangle positioned at the top-left of the first michael@0: * rectangle in getClientRects(). michael@0: */ michael@0: nsIDOMClientRect getBoundingClientRect(); michael@0: michael@0: /** michael@0: * The vertical scroll position of the element, or 0 if the element is not michael@0: * scrollable. This property may be assigned a value to change the michael@0: * vertical scroll position. michael@0: */ michael@0: attribute long scrollTop; michael@0: michael@0: /** michael@0: * The horizontal scroll position of the element, or 0 if the element is not michael@0: * scrollable. This property may be assigned a value to change the michael@0: * horizontal scroll position. michael@0: */ michael@0: attribute long scrollLeft; michael@0: michael@0: /** michael@0: * The width of the scrollable area of the element. If the element is not michael@0: * scrollable, scrollWidth is equivalent to the offsetWidth. michael@0: */ michael@0: readonly attribute long scrollWidth; michael@0: michael@0: /** michael@0: * The height of the scrollable area of the element. If the element is not michael@0: * scrollable, scrollHeight is equivalent to the offsetHeight. michael@0: */ michael@0: readonly attribute long scrollHeight; michael@0: michael@0: /** michael@0: * The height in CSS pixels of the element's top border. michael@0: */ michael@0: readonly attribute long clientTop; michael@0: michael@0: /** michael@0: * The width in CSS pixels of the element's left border and scrollbar michael@0: * if it is present on the left side. michael@0: */ michael@0: readonly attribute long clientLeft; michael@0: michael@0: /** michael@0: * The height in CSS pixels of the element's padding box. If the element is michael@0: * scrollable, the scroll bars are included inside this width. michael@0: */ michael@0: readonly attribute long clientWidth; michael@0: michael@0: /** michael@0: * The width in CSS pixels of the element's padding box. If the element is michael@0: * scrollable, the scroll bars are included inside this height. michael@0: */ michael@0: readonly attribute long clientHeight; michael@0: michael@0: /* The maximum offset that the element can be scrolled to michael@0: (i.e., the value that scrollLeft/scrollTop would be clamped to if they were michael@0: set to arbitrarily large values. */ michael@0: readonly attribute long scrollLeftMax; michael@0: readonly attribute long scrollTopMax; michael@0: michael@0: michael@0: // Selectors API michael@0: /** michael@0: * Returns whether this element would be selected by the given selector michael@0: * string. michael@0: * michael@0: * See michael@0: */ michael@0: boolean mozMatchesSelector([Null(Stringify)] in DOMString selector); michael@0: michael@0: michael@0: // Proprietary extensions michael@0: /** michael@0: * Set this during a mousedown event to grab and retarget all mouse events michael@0: * to this element until the mouse button is released or releaseCapture is michael@0: * called. If retargetToElement is true, then all events are targetted at michael@0: * this element. If false, events can also fire at descendants of this michael@0: * element. michael@0: * michael@0: */ michael@0: void setCapture([optional] in boolean retargetToElement); michael@0: michael@0: /** michael@0: * If this element has captured the mouse, release the capture. If another michael@0: * element has captured the mouse, this method has no effect. michael@0: */ michael@0: void releaseCapture(); michael@0: michael@0: // Mozilla extensions michael@0: /** michael@0: * Requests that this element be made the full-screen element, as per the DOM michael@0: * full-screen api. michael@0: * michael@0: * @see michael@0: */ michael@0: void mozRequestFullScreen(); michael@0: michael@0: /** michael@0: * Requests that this element be made the pointer-locked element, as per the DOM michael@0: * pointer lock api. michael@0: * michael@0: * @see michael@0: */ michael@0: void mozRequestPointerLock(); michael@0: michael@0: /** michael@0: * Return nodes that match a given CSS selector. michael@0: * michael@0: * @see michael@0: */ michael@0: nsIDOMElement querySelector([Null(Stringify)] in DOMString selectors); michael@0: nsIDOMNodeList querySelectorAll([Null(Stringify)] in DOMString selectors); michael@0: };