0550789ffddfad788daf7474f69b03b918c827bf
[WebKit-https.git] / Source / WebCore / dom / Node.idl
1 /*
2  * Copyright (C) 2006, 2007, 2008, 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     JSCustomHeader,
23     JSCustomMarkFunction,
24     JSCustomPushEventHandlerScope,
25     CustomIsReachable,
26     JSCustomFinalize,
27     CustomToJSObject,
28     EventTarget,
29     JSGenerateToNativeObject,
30     JSInlineGetOwnPropertySlot,
31     ObjCPolymorphic,
32 ] interface Node
33 #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
34     : Object, EventTarget
35 #endif /* defined(LANGUAGE_OBJECTIVE_C) */
36  {
37     // NodeType
38     const unsigned short      ELEMENT_NODE                   = 1;
39     const unsigned short      ATTRIBUTE_NODE                 = 2;
40     const unsigned short      TEXT_NODE                      = 3;
41     const unsigned short      CDATA_SECTION_NODE             = 4;
42     const unsigned short      ENTITY_REFERENCE_NODE          = 5;
43     const unsigned short      ENTITY_NODE                    = 6;
44     const unsigned short      PROCESSING_INSTRUCTION_NODE    = 7;
45     const unsigned short      COMMENT_NODE                   = 8;
46     const unsigned short      DOCUMENT_NODE                  = 9;
47     const unsigned short      DOCUMENT_TYPE_NODE             = 10;
48     const unsigned short      DOCUMENT_FRAGMENT_NODE         = 11;
49     const unsigned short      NOTATION_NODE                  = 12;
50
51     readonly attribute [TreatReturnedNullStringAs=Null] DOMString        nodeName;
52
53              // FIXME: the spec says this can also raise on retrieval.
54              attribute [TreatReturnedNullStringAs=Null, TreatNullAs=NullString] DOMString        nodeValue
55                  setter raises(DOMException);
56
57     readonly attribute unsigned short   nodeType;
58     readonly attribute Node             parentNode;
59     readonly attribute NodeList         childNodes;
60     readonly attribute Node             firstChild;
61     readonly attribute Node             lastChild;
62     readonly attribute Node             previousSibling;
63     readonly attribute Node             nextSibling;
64     readonly attribute Document         ownerDocument;
65
66     [ObjCLegacyUnnamedParameters, Custom] Node insertBefore([CustomReturn] Node newChild,
67                                                             Node refChild)
68         raises(DOMException);
69     [ObjCLegacyUnnamedParameters, Custom] Node replaceChild(Node newChild,
70                                                             [CustomReturn] Node oldChild)
71         raises(DOMException);
72     [Custom] Node removeChild([CustomReturn] Node oldChild)
73         raises(DOMException);
74     [Custom] Node appendChild([CustomReturn] Node newChild)
75         raises(DOMException);
76
77     boolean            hasChildNodes();
78     Node               cloneNode([Default=Undefined] optional boolean deep);
79     void               normalize();
80
81     // Introduced in DOM Level 2:
82
83     [ObjCLegacyUnnamedParameters] boolean isSupported([Default=Undefined] optional DOMString feature, 
84                                        [TreatNullAs=NullString,Default=Undefined] optional DOMString version);
85
86     readonly attribute [TreatReturnedNullStringAs=Null] DOMString        namespaceURI;
87              attribute [TreatReturnedNullStringAs=Null, TreatNullAs=NullString] DOMString        prefix
88                  setter raises(DOMException);
89     readonly attribute [TreatReturnedNullStringAs=Null] DOMString        localName;
90
91 #if defined(LANGUAGE_OBJECTIVE_C)
92     readonly attribute NamedNodeMap     attributes;
93     boolean            hasAttributes();
94 #endif
95
96
97     // Introduced in DOM Level 3:
98
99     readonly attribute [TreatReturnedNullStringAs=Null] DOMString       baseURI;
100
101              // FIXME: the spec says this can also raise on retrieval.
102              attribute [TreatReturnedNullStringAs=Null, TreatNullAs=NullString] DOMString       textContent
103                  setter raises(DOMException);
104
105     boolean            isSameNode([Default=Undefined] optional Node other);
106     boolean            isEqualNode([Default=Undefined] optional Node other);
107     [TreatReturnedNullStringAs=Null] DOMString          lookupPrefix([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI);
108     boolean            isDefaultNamespace([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI);
109     [TreatReturnedNullStringAs=Null] DOMString          lookupNamespaceURI([TreatNullAs=NullString,Default=Undefined] optional DOMString prefix);
110
111     // DocumentPosition
112     const unsigned short      DOCUMENT_POSITION_DISCONNECTED = 0x01;
113     const unsigned short      DOCUMENT_POSITION_PRECEDING    = 0x02;
114     const unsigned short      DOCUMENT_POSITION_FOLLOWING    = 0x04;
115     const unsigned short      DOCUMENT_POSITION_CONTAINS     = 0x08;
116     const unsigned short      DOCUMENT_POSITION_CONTAINED_BY = 0x10;
117     const unsigned short      DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;
118
119     unsigned short     compareDocumentPosition([Default=Undefined] optional Node other);
120
121     // Introduced in DOM4
122     boolean contains([Default=Undefined] optional Node other);
123
124     // IE extensions
125     readonly attribute Element          parentElement;
126
127 #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
128     // Objective-C extensions
129     readonly attribute boolean          isContentEditable;
130
131     void inspect();
132 #endif /* defined(LANGUAGE_OBJECTIVE_C) */
133
134 #if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP
135 #if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C
136     void addEventListener(DOMString type, 
137                           EventListener listener, 
138                           optional boolean useCapture);
139     void removeEventListener(DOMString type, 
140                              EventListener listener, 
141                              optional boolean useCapture);
142     boolean dispatchEvent(Event event)
143         raises(EventException);
144 #endif
145 #endif
146
147 #if defined(LANGUAGE_CPP) && LANGUAGE_CPP
148     [Custom] void addEventListener(DOMString type, 
149                                       EventListener listener, 
150                                       boolean useCapture);
151     [Custom] void removeEventListener(DOMString type, 
152                                          EventListener listener, 
153                                          boolean useCapture);
154     boolean dispatchEvent(Event event)
155         raises(EventException);
156 #endif
157
158 };
159