1/*
2 * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB.  If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21[
22    SpecialWrapFor=(HTMLElement,SVGElement),
23] interface Element : Node {
24
25    // DOM Level 1 Core
26
27    readonly attribute DOMString? tagName;
28
29    DOMString? getAttribute(DOMString name);
30    [RaisesException, CustomElementCallbacks] void setAttribute(DOMString name, DOMString value);
31    [CustomElementCallbacks] void removeAttribute(DOMString name);
32    [MeasureAs=ElementGetAttributeNode] Attr getAttributeNode([Default=Undefined] optional DOMString name); // Removed from DOM4.
33    [RaisesException, CustomElementCallbacks, MeasureAs=ElementSetAttributeNode] Attr setAttributeNode([Default=Undefined] optional Attr newAttr); // Removed from DOM4.
34    [RaisesException, CustomElementCallbacks, MeasureAs=ElementRemoveAttributeNode] Attr removeAttributeNode([Default=Undefined] optional Attr oldAttr); // Removed from DOM4.
35    HTMLCollection getElementsByTagName(DOMString name);
36
37    [PerWorldBindings, ImplementedAs=attributesForBindings] readonly attribute NamedNodeMap     attributes;
38    [MeasureAs=HasAttributes] boolean hasAttributes();
39
40    // DOM Level 2 Core
41
42    DOMString? getAttributeNS(DOMString? namespaceURI, DOMString localName);
43    [RaisesException, CustomElementCallbacks] void setAttributeNS(DOMString? namespaceURI, DOMString qualifiedName, DOMString value);
44    [CustomElementCallbacks] void removeAttributeNS(DOMString? namespaceURI, DOMString localName);
45    HTMLCollection getElementsByTagNameNS(DOMString? namespaceURI, DOMString localName);
46    [MeasureAs=ElementGetAttributeNodeNS] Attr getAttributeNodeNS([Default=Undefined] optional DOMString? namespaceURI,
47                                                                  [Default=Undefined] optional DOMString localName); // Removed from DOM4.
48    [RaisesException, CustomElementCallbacks, DeprecateAs=ElementSetAttributeNodeNS] Attr setAttributeNodeNS([Default=Undefined] optional Attr newAttr); // Removed from DOM4.
49    boolean hasAttribute(DOMString name);
50    boolean hasAttributeNS(DOMString? namespaceURI, DOMString localName);
51
52    [PerWorldBindings] readonly attribute CSSStyleDeclaration style;
53
54    // DOM4
55    [Reflect] attribute DOMString id;
56    readonly attribute DOMString? namespaceURI;
57    [RaisesException=Setter] attribute DOMString? prefix;
58    readonly attribute DOMString? localName;
59
60    [RaisesException] boolean matches(DOMString selectors);
61
62    // Common extensions
63
64    readonly attribute long offsetLeft;
65    readonly attribute long offsetTop;
66    readonly attribute long offsetWidth;
67    readonly attribute long offsetHeight;
68    [ImplementedAs=offsetParentForBindings, PerWorldBindings] readonly attribute Element offsetParent;
69    readonly attribute long clientLeft;
70    readonly attribute long clientTop;
71    readonly attribute long clientWidth;
72    readonly attribute long clientHeight;
73
74    // FIXME: should be:
75    // attribute (Dictionary or double) scrollLeft;
76    // attribute (Dictionary or double) scrollTop;
77    // http://crbug.com/240176
78    [Custom=Setter] attribute double scrollLeft;
79    [Custom=Setter] attribute double scrollTop;
80    readonly attribute long scrollWidth;
81    readonly attribute long scrollHeight;
82
83    void focus();
84    void blur();
85    void scrollIntoView(optional boolean alignWithTop);
86
87    // WebKit extensions
88
89    [MeasureAs=ElementScrollIntoViewIfNeeded] void scrollIntoViewIfNeeded(optional boolean centerIfNeeded);
90
91    // HTML 5
92    HTMLCollection getElementsByClassName(DOMString classNames);
93    [TreatNullAs=NullString, CustomElementCallbacks, RaisesException=Setter] attribute DOMString innerHTML;
94    [TreatNullAs=NullString, CustomElementCallbacks, RaisesException=Setter] attribute DOMString outerHTML;
95
96    [RaisesException, CustomElementCallbacks, MeasureAs=InsertAdjacentElement] Element insertAdjacentElement(DOMString where, Element element);
97    [RaisesException, MeasureAs=InsertAdjacentText] void insertAdjacentText(DOMString where, DOMString text);
98    [CustomElementCallbacks, RaisesException, MeasureAs=InsertAdjacentHTML] void insertAdjacentHTML(DOMString where, DOMString html);
99
100    [Reflect=class] attribute DOMString className;
101    [PerWorldBindings] readonly attribute DOMTokenList classList;
102
103    [PerWorldBindings] readonly attribute DOMStringMap dataset;
104
105    // WebKit extension
106    [RaisesException, ImplementedAs=matches, MeasureAs=ElementPrefixedMatchesSelector] boolean webkitMatchesSelector(DOMString selectors);
107
108    // Shadow DOM API
109    [RaisesException, MeasureAs=ElementCreateShadowRoot] ShadowRoot createShadowRoot();
110    [PerWorldBindings] readonly attribute ShadowRoot shadowRoot;
111    NodeList getDestinationInsertionPoints();
112
113    // CSSOM View Module API
114    ClientRectList getClientRects();
115    ClientRect getBoundingClientRect();
116
117    [MeasureAs=ElementRequestPointerLock] void requestPointerLock();
118
119    // Event handler attributes
120    attribute EventHandler onbeforecopy;
121    attribute EventHandler onbeforecut;
122    attribute EventHandler onbeforepaste;
123    attribute EventHandler oncopy;
124    attribute EventHandler oncut;
125    attribute EventHandler onpaste;
126    attribute EventHandler onsearch;
127    attribute EventHandler onselectstart;
128    [RuntimeEnabled=Touch] attribute EventHandler ontouchcancel;
129    [RuntimeEnabled=Touch] attribute EventHandler ontouchend;
130    [RuntimeEnabled=Touch] attribute EventHandler ontouchmove;
131    [RuntimeEnabled=Touch] attribute EventHandler ontouchstart;
132    attribute EventHandler onwheel;
133};
134
135Element implements ParentNode;
136Element implements ChildNode;
137