1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
/*
* This file is part of the KDE libraries
* Copyright (C) 2000 Harri Porten (porten@kde.org)
* Copyright (C) 2003 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _KJS_DOM_H_
#define _KJS_DOM_H_
#include "dom/dom_node.h"
#include "dom/dom_doc.h"
#include "dom/dom_element.h"
#include "dom/dom_xml.h"
#include "ecma/kjs_binding.h"
namespace KJS {
class DOMNode : public DOMObject {
public:
// Build a DOMNode
DOMNode(ExecState *exec, const DOM::Node& n);
// Constructor for inherited classes
DOMNode(const Object& proto, const DOM::Node& n);
~DOMNode();
virtual bool toBoolean(ExecState *) const;
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
void putValueProperty(ExecState *exec, int token, const Value& value, int attr);
virtual DOM::Node toNode() const { return node; }
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
virtual Value toPrimitive(ExecState *exec, Type preferred = UndefinedType) const;
virtual UString toString(ExecState *exec) const;
void setListener(ExecState *exec, int eventId, const Value& func) const;
Value getListener(int eventId) const;
virtual void pushEventHandlerScope(ExecState *exec, ScopeChain &scope) const;
enum { NodeName, NodeValue, NodeType, ParentNode, ParentElement,
ChildNodes, FirstChild, LastChild, PreviousSibling, NextSibling, Item,
Attributes, NamespaceURI, Prefix, LocalName, OwnerDocument, InsertBefore,
ReplaceChild, RemoveChild, AppendChild, HasAttributes, HasChildNodes,
CloneNode, Normalize, IsSupported, AddEventListener, RemoveEventListener,
DispatchEvent, Contains, InsertAdjacentHTML,
OnAbort, OnBlur, OnChange, OnClick, OnDblClick, OnDragDrop, OnError,
OnFocus, OnKeyDown, OnKeyPress, OnKeyUp, OnLoad, OnMouseDown,
OnMouseMove, OnMouseOut, OnMouseOver, OnMouseUp, OnMove, OnReset,
OnResize, OnSelect, OnSubmit, OnUnload,
OffsetLeft, OffsetTop, OffsetWidth, OffsetHeight, OffsetParent,
ClientWidth, ClientHeight, ScrollLeft, ScrollTop,
ScrollWidth, ScrollHeight, SourceIndex, TextContent };
protected:
DOM::Node node;
};
DEFINE_CONSTANT_TABLE(DOMNodeConstants)
KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE(DOMNodeProto, DOMNodeConstants)
DEFINE_PSEUDO_CONSTRUCTOR(NodeConstructor)
class DOMNodeList : public DOMObject {
public:
DOMNodeList(ExecState *, const DOM::NodeList& l);
~DOMNodeList();
virtual bool hasProperty(ExecState *exec, const Identifier &p) const;
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
virtual Value call(ExecState *exec, Object &thisObj, const List&args);
virtual Value tryCall(ExecState *exec, Object &thisObj, const List&args);
virtual bool implementsCall() const { return true; }
virtual ReferenceList propList(ExecState *exec, bool recursive);
// no put - all read-only
virtual const ClassInfo* classInfo() const { return &info; }
virtual bool toBoolean(ExecState *) const { return true; }
static const ClassInfo info;
DOM::NodeList nodeList() const { return list; }
enum { Item, NamedItem };
private:
DOM::NodeList list;
};
class DOMDocument : public DOMNode {
public:
// Build a DOMDocument
DOMDocument(ExecState *exec, const DOM::Document& d);
// Constructor for inherited classes
DOMDocument(const Object& proto, const DOM::Document& d);
virtual ~DOMDocument();
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
void putValueProperty(ExecState *exec, int token, const Value& value, int attr);
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { DocType, Implementation, DocumentElement, CharacterSet,
// Functions
CreateElement, CreateDocumentFragment, CreateTextNode, CreateComment,
CreateCDATASection, CreateProcessingInstruction, CreateAttribute,
CreateEntityReference, GetElementsByTagName, ImportNode, CreateElementNS,
CreateAttributeNS, GetElementsByTagNameNS, GetElementById,
CreateRange, CreateNodeIterator, CreateTreeWalker, DefaultView,
CreateEvent, StyleSheets, GetOverrideStyle, Abort, Load, LoadXML,
PreferredStylesheetSet, SelectedStylesheetSet, ReadyState, Async };
};
KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE(DOMDocumentProto, DOMNodeProto)
DEFINE_PSEUDO_CONSTRUCTOR(DocumentPseudoCtor)
class DOMAttr : public DOMNode {
public:
DOMAttr(ExecState *exec, const DOM::Attr& a) : DOMNode(exec, a) { }
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
Value getValueProperty(ExecState *exec, int token) const;
void putValueProperty(ExecState *exec, int token, const Value& value, int attr);
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { Name, Specified, ValueProperty, OwnerElement };
};
class DOMElement : public DOMNode {
public:
// Build a DOMElement
DOMElement(ExecState *exec, const DOM::Element& e);
// Constructor for inherited classes
DOMElement(const Object& proto, const DOM::Element& e);
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
// no put - all read-only
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { TagName, Style,
GetAttribute, SetAttribute, RemoveAttribute, GetAttributeNode,
SetAttributeNode, RemoveAttributeNode, GetElementsByTagName,
GetAttributeNS, SetAttributeNS, RemoveAttributeNS, GetAttributeNodeNS,
SetAttributeNodeNS, GetElementsByTagNameNS, HasAttribute, HasAttributeNS };
};
KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE(DOMElementProto, DOMNodeProto)
DEFINE_PSEUDO_CONSTRUCTOR(ElementPseudoCtor)
class DOMDOMImplementation : public DOMObject {
public:
// Build a DOMDOMImplementation
DOMDOMImplementation(ExecState *, const DOM::DOMImplementation& i);
~DOMDOMImplementation();
// no put - all functions
virtual const ClassInfo* classInfo() const { return &info; }
virtual bool toBoolean(ExecState *) const { return true; }
static const ClassInfo info;
enum { HasFeature, CreateDocumentType, CreateDocument, CreateCSSStyleSheet, CreateHTMLDocument };
DOM::DOMImplementation toImplementation() const { return implementation; }
private:
DOM::DOMImplementation implementation;
};
class DOMDocumentType : public DOMNode {
public:
// Build a DOMDocumentType
DOMDocumentType(ExecState *exec, const DOM::DocumentType& dt);
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
// no put - all read-only
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { Name, Entities, Notations, PublicId, SystemId, InternalSubset };
};
class DOMNamedNodeMap : public DOMObject {
public:
DOMNamedNodeMap(ExecState *, const DOM::NamedNodeMap& m);
~DOMNamedNodeMap();
virtual bool hasProperty(ExecState *exec, const Identifier &p) const;
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
// no put - all read-only
virtual const ClassInfo* classInfo() const { return &info; }
virtual bool toBoolean(ExecState *) const { return true; }
static const ClassInfo info;
enum { GetNamedItem, SetNamedItem, RemoveNamedItem, Item, Length,
GetNamedItemNS, SetNamedItemNS, RemoveNamedItemNS };
DOM::NamedNodeMap toMap() const { return map; }
private:
DOM::NamedNodeMap map;
};
class DOMProcessingInstruction : public DOMNode {
public:
DOMProcessingInstruction(ExecState *exec, const DOM::ProcessingInstruction& pi) : DOMNode(exec, pi) { }
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { Target, Data, Sheet };
};
class DOMNotation : public DOMNode {
public:
DOMNotation(ExecState *exec, const DOM::Notation& n) : DOMNode(exec, n) { }
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
// no put - all read-only
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { PublicId, SystemId };
};
class DOMEntity : public DOMNode {
public:
DOMEntity(ExecState *exec, const DOM::Entity& e) : DOMNode(exec, e) { }
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
// no put - all read-only
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { PublicId, SystemId, NotationName };
};
// Constructor for DOMException - constructor stuff not implemented yet
class DOMExceptionConstructor : public DOMObject {
public:
DOMExceptionConstructor(ExecState *);
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
// no put - all read-only
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
};
bool checkNodeSecurity(ExecState *exec, const DOM::Node& n);
KDE_EXPORT Value getDOMNode(ExecState *exec, const DOM::Node& n);
Value getDOMNamedNodeMap(ExecState *exec, const DOM::NamedNodeMap& m);
Value getDOMNodeList(ExecState *exec, const DOM::NodeList& l);
Value getDOMDOMImplementation(ExecState *exec, const DOM::DOMImplementation& i);
Object getDOMExceptionConstructor(ExecState *exec);
// Internal class, used for the collection return by e.g. document.forms.myinput
// when multiple nodes have the same name.
class DOMNamedNodesCollection : public DOMObject {
public:
DOMNamedNodesCollection(ExecState *exec, const TQValueList<DOM::Node>& nodes );
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
const TQValueList<DOM::Node>& nodes() const { return m_nodes; }
enum { Length };
private:
TQValueList<DOM::Node> m_nodes;
};
class DOMCharacterData : public DOMNode {
public:
// Build a DOMCharacterData
DOMCharacterData(ExecState *exec, const DOM::CharacterData& d);
// Constructor for inherited classes
DOMCharacterData(const Object& proto, const DOM::CharacterData& d);
virtual Value tryGet(ExecState *exec,const Identifier &propertyName) const;
Value getValueProperty(ExecState *, int token) const;
virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
DOM::CharacterData toData() const { return static_cast<DOM::CharacterData>(node); }
enum { Data, Length,
SubstringData, AppendData, InsertData, DeleteData, ReplaceData };
};
class DOMText : public DOMCharacterData {
public:
DOMText(ExecState *exec, const DOM::Text& t);
virtual Value tryGet(ExecState *exec,const Identifier &propertyName) const;
Value getValueProperty(ExecState *, int token) const;
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
DOM::Text toText() const { return static_cast<DOM::Text>(node); }
enum { SplitText };
};
} // namespace
#endif
|