|
1 /* |
|
2 This file is part of the WebKit open source project. |
|
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
|
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 #include "config.h" |
|
22 |
|
23 #include "JSDocument.h" |
|
24 |
|
25 #include <wtf/GetPtr.h> |
|
26 |
|
27 #include "Attr.h" |
|
28 #include "CDATASection.h" |
|
29 #include "CSSMutableStyleDeclaration.h" |
|
30 #include "CSSStyleDeclaration.h" |
|
31 #include "Comment.h" |
|
32 #include "DOMImplementation.h" |
|
33 #include "Document.h" |
|
34 #include "DocumentFragment.h" |
|
35 #include "DocumentType.h" |
|
36 #include "Element.h" |
|
37 #include "EntityReference.h" |
|
38 #include "Event.h" |
|
39 #include "ExceptionCode.h" |
|
40 #include "JSAttr.h" |
|
41 #include "JSCDATASection.h" |
|
42 #include "JSCSSStyleDeclaration.h" |
|
43 #include "JSComment.h" |
|
44 #include "JSDOMImplementation.h" |
|
45 #include "JSDocumentFragment.h" |
|
46 #include "JSDocumentType.h" |
|
47 #include "JSElement.h" |
|
48 #include "JSEntityReference.h" |
|
49 #include "JSEvent.h" |
|
50 #include "JSNode.h" |
|
51 #include "JSNodeFilter.h" |
|
52 #include "JSNodeIterator.h" |
|
53 #include "JSNodeList.h" |
|
54 #include "JSProcessingInstruction.h" |
|
55 #include "JSRange.h" |
|
56 #include "JSText.h" |
|
57 #include "JSTreeWalker.h" |
|
58 #include "NameNodeList.h" |
|
59 #include "Node.h" |
|
60 #include "NodeIterator.h" |
|
61 #include "NodeList.h" |
|
62 #include "PlatformString.h" |
|
63 #include "ProcessingInstruction.h" |
|
64 #include "Range.h" |
|
65 #include "StyleSheetList.h" |
|
66 #include "Text.h" |
|
67 #include "TreeWalker.h" |
|
68 #include "kjs_css.h" |
|
69 #include "kjs_window.h" |
|
70 |
|
71 using namespace KJS; |
|
72 |
|
73 namespace WebCore { |
|
74 |
|
75 /* Hash table */ |
|
76 |
|
77 static const HashEntry JSDocumentTableEntries[] = |
|
78 { |
|
79 { "documentElement", JSDocument::DocumentElementAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
80 { "doctype", JSDocument::DoctypeAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
81 { "selectedStylesheetSet", JSDocument::SelectedStylesheetSetAttrNum, DontDelete, 0, 0 }, |
|
82 { "preferredStylesheetSet", JSDocument::PreferredStylesheetSetAttrNum, DontDelete|ReadOnly, 0, &JSDocumentTableEntries[20] }, |
|
83 { "xmlVersion", JSDocument::XMLVersionAttrNum, DontDelete, 0, 0 }, |
|
84 { "defaultView", JSDocument::DefaultViewAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
85 { "readyState", JSDocument::ReadyStateAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
86 { "xmlStandalone", JSDocument::XMLStandaloneAttrNum, DontDelete, 0, 0 }, |
|
87 { "inputEncoding", JSDocument::InputEncodingAttrNum, DontDelete|ReadOnly, 0, &JSDocumentTableEntries[18] }, |
|
88 { 0, 0, 0, 0, 0 }, |
|
89 { "documentURI", JSDocument::DocumentURIAttrNum, DontDelete, 0, 0 }, |
|
90 { "implementation", JSDocument::ImplementationAttrNum, DontDelete|ReadOnly, 0, &JSDocumentTableEntries[19] }, |
|
91 { 0, 0, 0, 0, 0 }, |
|
92 { "URL", JSDocument::URLAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
93 { "xmlEncoding", JSDocument::XMLEncodingAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
94 { 0, 0, 0, 0, 0 }, |
|
95 { "charset", JSDocument::CharsetAttrNum, DontDelete, 0, 0 }, |
|
96 { "defaultCharset", JSDocument::DefaultCharsetAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
97 { "styleSheets", JSDocument::StyleSheetsAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
98 { "characterSet", JSDocument::CharacterSetAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
99 { "constructor", JSDocument::ConstructorAttrNum, DontDelete|DontEnum|ReadOnly, 0, 0 } |
|
100 }; |
|
101 |
|
102 static const HashTable JSDocumentTable = |
|
103 { |
|
104 2, 21, JSDocumentTableEntries, 18 |
|
105 }; |
|
106 |
|
107 /* Hash table for constructor */ |
|
108 |
|
109 static const HashEntry JSDocumentConstructorTableEntries[] = |
|
110 { |
|
111 { 0, 0, 0, 0, 0 } |
|
112 }; |
|
113 |
|
114 static const HashTable JSDocumentConstructorTable = |
|
115 { |
|
116 2, 1, JSDocumentConstructorTableEntries, 1 |
|
117 }; |
|
118 |
|
119 class JSDocumentConstructor : public DOMObject { |
|
120 public: |
|
121 JSDocumentConstructor(ExecState* exec) |
|
122 { |
|
123 setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype()); |
|
124 putDirect(exec->propertyNames().prototype, JSDocumentPrototype::self(exec), None); |
|
125 } |
|
126 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); |
|
127 JSValue* getValueProperty(ExecState*, int token) const; |
|
128 virtual const ClassInfo* classInfo() const { return &info; } |
|
129 static const ClassInfo info; |
|
130 |
|
131 virtual bool implementsHasInstance() const { return true; } |
|
132 }; |
|
133 |
|
134 const ClassInfo JSDocumentConstructor::info = { "DocumentConstructor", 0, &JSDocumentConstructorTable, 0 }; |
|
135 |
|
136 bool JSDocumentConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
137 { |
|
138 return getStaticValueSlot<JSDocumentConstructor, DOMObject>(exec, &JSDocumentConstructorTable, this, propertyName, slot); |
|
139 } |
|
140 |
|
141 JSValue* JSDocumentConstructor::getValueProperty(ExecState*, int token) const |
|
142 { |
|
143 // The token is the numeric value of its associated constant |
|
144 return jsNumber(token); |
|
145 } |
|
146 |
|
147 /* Hash table for prototype */ |
|
148 |
|
149 static const HashEntry JSDocumentPrototypeTableEntries[] = |
|
150 { |
|
151 { 0, 0, 0, 0, 0 }, |
|
152 { "elementFromPoint", JSDocument::ElementFromPointFuncNum, DontDelete|Function, 2, 0 }, |
|
153 { "createRange", JSDocument::CreateRangeFuncNum, DontDelete|Function, 0, 0 }, |
|
154 { "createComment", JSDocument::CreateCommentFuncNum, DontDelete|Function, 1, 0 }, |
|
155 { "queryCommandIndeterm", JSDocument::QueryCommandIndetermFuncNum, DontDelete|Function, 1, 0 }, |
|
156 { "createTextNode", JSDocument::CreateTextNodeFuncNum, DontDelete|Function, 1, &JSDocumentPrototypeTableEntries[29] }, |
|
157 { 0, 0, 0, 0, 0 }, |
|
158 { "queryCommandEnabled", JSDocument::QueryCommandEnabledFuncNum, DontDelete|Function, 1, 0 }, |
|
159 { "getElementById", JSDocument::GetElementByIdFuncNum, DontDelete|Function, 1, &JSDocumentPrototypeTableEntries[33] }, |
|
160 { "createAttribute", JSDocument::CreateAttributeFuncNum, DontDelete|Function, 1, &JSDocumentPrototypeTableEntries[35] }, |
|
161 { "createElementNS", JSDocument::CreateElementNSFuncNum, DontDelete|Function, 2, 0 }, |
|
162 { 0, 0, 0, 0, 0 }, |
|
163 { "createNodeIterator", JSDocument::CreateNodeIteratorFuncNum, DontDelete|Function, 4, 0 }, |
|
164 { "importNode", JSDocument::ImportNodeFuncNum, DontDelete|Function, 2, 0 }, |
|
165 { "createEntityReference", JSDocument::CreateEntityReferenceFuncNum, DontDelete|Function, 1, &JSDocumentPrototypeTableEntries[31] }, |
|
166 { 0, 0, 0, 0, 0 }, |
|
167 { 0, 0, 0, 0, 0 }, |
|
168 { "createAttributeNS", JSDocument::CreateAttributeNSFuncNum, DontDelete|Function, 2, &JSDocumentPrototypeTableEntries[34] }, |
|
169 { "adoptNode", JSDocument::AdoptNodeFuncNum, DontDelete|Function, 1, &JSDocumentPrototypeTableEntries[32] }, |
|
170 { 0, 0, 0, 0, 0 }, |
|
171 { "createDocumentFragment", JSDocument::CreateDocumentFragmentFuncNum, DontDelete|Function, 0, 0 }, |
|
172 { 0, 0, 0, 0, 0 }, |
|
173 { "getElementsByTagName", JSDocument::GetElementsByTagNameFuncNum, DontDelete|Function, 1, 0 }, |
|
174 { 0, 0, 0, 0, 0 }, |
|
175 { "createTreeWalker", JSDocument::CreateTreeWalkerFuncNum, DontDelete|Function, 4, 0 }, |
|
176 { 0, 0, 0, 0, 0 }, |
|
177 { "createElement", JSDocument::CreateElementFuncNum, DontDelete|Function, 1, &JSDocumentPrototypeTableEntries[27] }, |
|
178 { "createCDATASection", JSDocument::CreateCDATASectionFuncNum, DontDelete|Function, 1, &JSDocumentPrototypeTableEntries[28] }, |
|
179 { "createProcessingInstruction", JSDocument::CreateProcessingInstructionFuncNum, DontDelete|Function, 2, 0 }, |
|
180 { "getElementsByTagNameNS", JSDocument::GetElementsByTagNameNSFuncNum, DontDelete|Function, 2, &JSDocumentPrototypeTableEntries[30] }, |
|
181 { "createEvent", JSDocument::CreateEventFuncNum, DontDelete|Function, 1, 0 }, |
|
182 { "getOverrideStyle", JSDocument::GetOverrideStyleFuncNum, DontDelete|Function, 2, 0 }, |
|
183 { "execCommand", JSDocument::ExecCommandFuncNum, DontDelete|Function, 3, 0 }, |
|
184 { "queryCommandState", JSDocument::QueryCommandStateFuncNum, DontDelete|Function, 1, 0 }, |
|
185 { "queryCommandSupported", JSDocument::QueryCommandSupportedFuncNum, DontDelete|Function, 1, 0 }, |
|
186 { "queryCommandValue", JSDocument::QueryCommandValueFuncNum, DontDelete|Function, 1, 0 } |
|
187 }; |
|
188 |
|
189 static const HashTable JSDocumentPrototypeTable = |
|
190 { |
|
191 2, 36, JSDocumentPrototypeTableEntries, 27 |
|
192 }; |
|
193 |
|
194 const ClassInfo JSDocumentPrototype::info = { "DocumentPrototype", 0, &JSDocumentPrototypeTable, 0 }; |
|
195 |
|
196 JSObject* JSDocumentPrototype::self(ExecState* exec) |
|
197 { |
|
198 return KJS::cacheGlobalObject<JSDocumentPrototype>(exec, "[[JSDocument.prototype]]"); |
|
199 } |
|
200 |
|
201 bool JSDocumentPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
202 { |
|
203 return getStaticFunctionSlot<JSDocumentPrototypeFunction, JSObject>(exec, &JSDocumentPrototypeTable, this, propertyName, slot); |
|
204 } |
|
205 |
|
206 const ClassInfo JSDocument::info = { "Document", &JSEventTargetNode::info, &JSDocumentTable, 0 }; |
|
207 |
|
208 JSDocument::JSDocument(ExecState* exec, Document* impl) |
|
209 : JSEventTargetNode(exec, impl) |
|
210 { |
|
211 setPrototype(JSDocumentPrototype::self(exec)); |
|
212 } |
|
213 |
|
214 JSDocument::~JSDocument() |
|
215 { |
|
216 ScriptInterpreter::forgetDOMObject(static_cast<Document*>(impl())); |
|
217 } |
|
218 |
|
219 bool JSDocument::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
220 { |
|
221 return getStaticValueSlot<JSDocument, JSEventTargetNode>(exec, &JSDocumentTable, this, propertyName, slot); |
|
222 } |
|
223 |
|
224 JSValue* JSDocument::getValueProperty(ExecState* exec, int token) const |
|
225 { |
|
226 switch (token) { |
|
227 case DoctypeAttrNum: { |
|
228 Document* imp = static_cast<Document*>(impl()); |
|
229 |
|
230 return toJS(exec, WTF::getPtr(imp->doctype())); |
|
231 } |
|
232 case ImplementationAttrNum: { |
|
233 Document* imp = static_cast<Document*>(impl()); |
|
234 |
|
235 return toJS(exec, WTF::getPtr(imp->implementation())); |
|
236 } |
|
237 case DocumentElementAttrNum: { |
|
238 Document* imp = static_cast<Document*>(impl()); |
|
239 |
|
240 return toJS(exec, WTF::getPtr(imp->documentElement())); |
|
241 } |
|
242 case InputEncodingAttrNum: { |
|
243 Document* imp = static_cast<Document*>(impl()); |
|
244 |
|
245 return jsStringOrNull(imp->inputEncoding()); |
|
246 } |
|
247 case XMLEncodingAttrNum: { |
|
248 Document* imp = static_cast<Document*>(impl()); |
|
249 |
|
250 return jsStringOrNull(imp->xmlEncoding()); |
|
251 } |
|
252 case XMLVersionAttrNum: { |
|
253 Document* imp = static_cast<Document*>(impl()); |
|
254 |
|
255 return jsStringOrNull(imp->xmlVersion()); |
|
256 } |
|
257 case XMLStandaloneAttrNum: { |
|
258 Document* imp = static_cast<Document*>(impl()); |
|
259 |
|
260 return jsBoolean(imp->xmlStandalone()); |
|
261 } |
|
262 case DocumentURIAttrNum: { |
|
263 Document* imp = static_cast<Document*>(impl()); |
|
264 |
|
265 return jsStringOrNull(imp->documentURI()); |
|
266 } |
|
267 case DefaultViewAttrNum: { |
|
268 Document* imp = static_cast<Document*>(impl()); |
|
269 |
|
270 return toJS(exec, WTF::getPtr(imp->defaultView())); |
|
271 } |
|
272 case StyleSheetsAttrNum: { |
|
273 Document* imp = static_cast<Document*>(impl()); |
|
274 |
|
275 return toJS(exec, WTF::getPtr(imp->styleSheets()), imp); |
|
276 } |
|
277 case URLAttrNum: { |
|
278 Document* imp = static_cast<Document*>(impl()); |
|
279 |
|
280 return jsString(imp->URL()); |
|
281 } |
|
282 case CharsetAttrNum: { |
|
283 Document* imp = static_cast<Document*>(impl()); |
|
284 |
|
285 return jsStringOrUndefined(imp->charset()); |
|
286 } |
|
287 case DefaultCharsetAttrNum: { |
|
288 Document* imp = static_cast<Document*>(impl()); |
|
289 |
|
290 return jsStringOrUndefined(imp->defaultCharset()); |
|
291 } |
|
292 case ReadyStateAttrNum: { |
|
293 Document* imp = static_cast<Document*>(impl()); |
|
294 |
|
295 return jsStringOrUndefined(imp->readyState()); |
|
296 } |
|
297 case CharacterSetAttrNum: { |
|
298 Document* imp = static_cast<Document*>(impl()); |
|
299 |
|
300 return jsStringOrNull(imp->characterSet()); |
|
301 } |
|
302 case PreferredStylesheetSetAttrNum: { |
|
303 Document* imp = static_cast<Document*>(impl()); |
|
304 |
|
305 return jsStringOrNull(imp->preferredStylesheetSet()); |
|
306 } |
|
307 case SelectedStylesheetSetAttrNum: { |
|
308 Document* imp = static_cast<Document*>(impl()); |
|
309 |
|
310 return jsStringOrNull(imp->selectedStylesheetSet()); |
|
311 } |
|
312 case ConstructorAttrNum: |
|
313 return getConstructor(exec); |
|
314 } |
|
315 return 0; |
|
316 } |
|
317 |
|
318 void JSDocument::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) |
|
319 { |
|
320 lookupPut<JSDocument, JSEventTargetNode>(exec, propertyName, value, attr, &JSDocumentTable, this); |
|
321 } |
|
322 |
|
323 void JSDocument::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/) |
|
324 { |
|
325 switch (token) { |
|
326 case XMLVersionAttrNum: { |
|
327 Document* imp = static_cast<Document*>(impl()); |
|
328 |
|
329 ExceptionCode ec = 0; |
|
330 imp->setXMLVersion(valueToStringWithNullCheck(exec, value), ec); |
|
331 setDOMException(exec, ec); |
|
332 break; |
|
333 } |
|
334 case XMLStandaloneAttrNum: { |
|
335 Document* imp = static_cast<Document*>(impl()); |
|
336 |
|
337 ExceptionCode ec = 0; |
|
338 imp->setXMLStandalone(value->toBoolean(exec), ec); |
|
339 setDOMException(exec, ec); |
|
340 break; |
|
341 } |
|
342 case DocumentURIAttrNum: { |
|
343 Document* imp = static_cast<Document*>(impl()); |
|
344 |
|
345 imp->setDocumentURI(valueToStringWithNullCheck(exec, value)); |
|
346 break; |
|
347 } |
|
348 case CharsetAttrNum: { |
|
349 Document* imp = static_cast<Document*>(impl()); |
|
350 |
|
351 imp->setCharset(valueToStringWithNullCheck(exec, value)); |
|
352 break; |
|
353 } |
|
354 case SelectedStylesheetSetAttrNum: { |
|
355 Document* imp = static_cast<Document*>(impl()); |
|
356 |
|
357 imp->setSelectedStylesheetSet(valueToStringWithNullCheck(exec, value)); |
|
358 break; |
|
359 } |
|
360 } |
|
361 } |
|
362 |
|
363 JSValue* JSDocument::getConstructor(ExecState* exec) |
|
364 { |
|
365 return KJS::cacheGlobalObject<JSDocumentConstructor>(exec, "[[Document.constructor]]"); |
|
366 } |
|
367 JSValue* JSDocumentPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) |
|
368 { |
|
369 if (!thisObj->inherits(&JSDocument::info)) |
|
370 return throwError(exec, TypeError); |
|
371 |
|
372 Document* imp = static_cast<Document*>(static_cast<JSDocument*>(thisObj)->impl()); |
|
373 |
|
374 switch (id) { |
|
375 case JSDocument::CreateElementFuncNum: { |
|
376 ExceptionCode ec = 0; |
|
377 String tagName = args[0]->toString(exec); |
|
378 |
|
379 |
|
380 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createElement(tagName, ec))); |
|
381 setDOMException(exec, ec); |
|
382 return result; |
|
383 } |
|
384 case JSDocument::CreateDocumentFragmentFuncNum: { |
|
385 |
|
386 |
|
387 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createDocumentFragment())); |
|
388 return result; |
|
389 } |
|
390 case JSDocument::CreateTextNodeFuncNum: { |
|
391 String data = args[0]->toString(exec); |
|
392 |
|
393 |
|
394 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createTextNode(data))); |
|
395 return result; |
|
396 } |
|
397 case JSDocument::CreateCommentFuncNum: { |
|
398 String data = args[0]->toString(exec); |
|
399 |
|
400 |
|
401 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createComment(data))); |
|
402 return result; |
|
403 } |
|
404 case JSDocument::CreateCDATASectionFuncNum: { |
|
405 ExceptionCode ec = 0; |
|
406 String data = args[0]->toString(exec); |
|
407 |
|
408 |
|
409 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createCDATASection(data, ec))); |
|
410 setDOMException(exec, ec); |
|
411 return result; |
|
412 } |
|
413 case JSDocument::CreateProcessingInstructionFuncNum: { |
|
414 ExceptionCode ec = 0; |
|
415 String target = args[0]->toString(exec); |
|
416 String data = args[1]->toString(exec); |
|
417 |
|
418 |
|
419 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createProcessingInstruction(target, data, ec))); |
|
420 setDOMException(exec, ec); |
|
421 return result; |
|
422 } |
|
423 case JSDocument::CreateAttributeFuncNum: { |
|
424 ExceptionCode ec = 0; |
|
425 String name = args[0]->toString(exec); |
|
426 |
|
427 |
|
428 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createAttribute(name, ec))); |
|
429 setDOMException(exec, ec); |
|
430 return result; |
|
431 } |
|
432 case JSDocument::CreateEntityReferenceFuncNum: { |
|
433 ExceptionCode ec = 0; |
|
434 String name = args[0]->toString(exec); |
|
435 |
|
436 |
|
437 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createEntityReference(name, ec))); |
|
438 setDOMException(exec, ec); |
|
439 return result; |
|
440 } |
|
441 case JSDocument::GetElementsByTagNameFuncNum: { |
|
442 String tagname = args[0]->toString(exec); |
|
443 |
|
444 |
|
445 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->getElementsByTagName(tagname))); |
|
446 return result; |
|
447 } |
|
448 case JSDocument::ImportNodeFuncNum: { |
|
449 ExceptionCode ec = 0; |
|
450 Node* importedNode = toNode(args[0]); |
|
451 bool deep = args[1]->toBoolean(exec); |
|
452 |
|
453 |
|
454 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->importNode(importedNode, deep, ec))); |
|
455 setDOMException(exec, ec); |
|
456 return result; |
|
457 } |
|
458 case JSDocument::CreateElementNSFuncNum: { |
|
459 ExceptionCode ec = 0; |
|
460 String namespaceURI = valueToStringWithNullCheck(exec, args[0]); |
|
461 String qualifiedName = args[1]->toString(exec); |
|
462 |
|
463 |
|
464 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createElementNS(namespaceURI, qualifiedName, ec))); |
|
465 setDOMException(exec, ec); |
|
466 return result; |
|
467 } |
|
468 case JSDocument::CreateAttributeNSFuncNum: { |
|
469 ExceptionCode ec = 0; |
|
470 String namespaceURI = valueToStringWithNullCheck(exec, args[0]); |
|
471 String qualifiedName = args[1]->toString(exec); |
|
472 |
|
473 |
|
474 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createAttributeNS(namespaceURI, qualifiedName, ec))); |
|
475 setDOMException(exec, ec); |
|
476 return result; |
|
477 } |
|
478 case JSDocument::GetElementsByTagNameNSFuncNum: { |
|
479 String namespaceURI = valueToStringWithNullCheck(exec, args[0]); |
|
480 String localName = args[1]->toString(exec); |
|
481 |
|
482 |
|
483 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->getElementsByTagNameNS(namespaceURI, localName))); |
|
484 return result; |
|
485 } |
|
486 case JSDocument::GetElementByIdFuncNum: { |
|
487 String elementId = args[0]->toString(exec); |
|
488 |
|
489 |
|
490 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->getElementById(elementId))); |
|
491 return result; |
|
492 } |
|
493 case JSDocument::AdoptNodeFuncNum: { |
|
494 ExceptionCode ec = 0; |
|
495 Node* source = toNode(args[0]); |
|
496 |
|
497 |
|
498 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->adoptNode(source, ec))); |
|
499 setDOMException(exec, ec); |
|
500 return result; |
|
501 } |
|
502 case JSDocument::CreateEventFuncNum: { |
|
503 ExceptionCode ec = 0; |
|
504 String eventType = args[0]->toString(exec); |
|
505 |
|
506 |
|
507 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createEvent(eventType, ec))); |
|
508 setDOMException(exec, ec); |
|
509 return result; |
|
510 } |
|
511 case JSDocument::CreateRangeFuncNum: { |
|
512 |
|
513 |
|
514 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createRange())); |
|
515 return result; |
|
516 } |
|
517 case JSDocument::CreateNodeIteratorFuncNum: { |
|
518 ExceptionCode ec = 0; |
|
519 Node* root = toNode(args[0]); |
|
520 bool whatToShowOk; |
|
521 unsigned whatToShow = args[1]->toInt32(exec, whatToShowOk); |
|
522 if (!whatToShowOk) { |
|
523 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
524 return jsUndefined(); |
|
525 } |
|
526 NodeFilter* filter = toNodeFilter(args[2]); |
|
527 bool entityReferenceExpansion = args[3]->toBoolean(exec); |
|
528 |
|
529 |
|
530 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createNodeIterator(root, whatToShow, filter, entityReferenceExpansion, ec))); |
|
531 setDOMException(exec, ec); |
|
532 return result; |
|
533 } |
|
534 case JSDocument::CreateTreeWalkerFuncNum: { |
|
535 ExceptionCode ec = 0; |
|
536 Node* root = toNode(args[0]); |
|
537 bool whatToShowOk; |
|
538 unsigned whatToShow = args[1]->toInt32(exec, whatToShowOk); |
|
539 if (!whatToShowOk) { |
|
540 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
541 return jsUndefined(); |
|
542 } |
|
543 NodeFilter* filter = toNodeFilter(args[2]); |
|
544 bool entityReferenceExpansion = args[3]->toBoolean(exec); |
|
545 |
|
546 |
|
547 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createTreeWalker(root, whatToShow, filter, entityReferenceExpansion, ec))); |
|
548 setDOMException(exec, ec); |
|
549 return result; |
|
550 } |
|
551 case JSDocument::GetOverrideStyleFuncNum: { |
|
552 Element* element = toElement(args[0]); |
|
553 String pseudoElement = args[1]->toString(exec); |
|
554 |
|
555 |
|
556 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->getOverrideStyle(element, pseudoElement))); |
|
557 return result; |
|
558 } |
|
559 case JSDocument::ExecCommandFuncNum: { |
|
560 String command = args[0]->toString(exec); |
|
561 bool userInterface = args[1]->toBoolean(exec); |
|
562 String value = valueToStringWithUndefinedOrNullCheck(exec, args[2]); |
|
563 |
|
564 |
|
565 KJS::JSValue* result = jsBoolean(imp->execCommand(command, userInterface, value)); |
|
566 return result; |
|
567 } |
|
568 case JSDocument::QueryCommandEnabledFuncNum: { |
|
569 String command = args[0]->toString(exec); |
|
570 |
|
571 |
|
572 KJS::JSValue* result = jsBoolean(imp->queryCommandEnabled(command)); |
|
573 return result; |
|
574 } |
|
575 case JSDocument::QueryCommandIndetermFuncNum: { |
|
576 String command = args[0]->toString(exec); |
|
577 |
|
578 |
|
579 KJS::JSValue* result = jsBoolean(imp->queryCommandIndeterm(command)); |
|
580 return result; |
|
581 } |
|
582 case JSDocument::QueryCommandStateFuncNum: { |
|
583 String command = args[0]->toString(exec); |
|
584 |
|
585 |
|
586 KJS::JSValue* result = jsBoolean(imp->queryCommandState(command)); |
|
587 return result; |
|
588 } |
|
589 case JSDocument::QueryCommandSupportedFuncNum: { |
|
590 String command = args[0]->toString(exec); |
|
591 |
|
592 |
|
593 KJS::JSValue* result = jsBoolean(imp->queryCommandSupported(command)); |
|
594 return result; |
|
595 } |
|
596 case JSDocument::QueryCommandValueFuncNum: { |
|
597 String command = args[0]->toString(exec); |
|
598 |
|
599 |
|
600 KJS::JSValue* result = jsStringOrFalse(imp->queryCommandValue(command)); |
|
601 return result; |
|
602 } |
|
603 case JSDocument::ElementFromPointFuncNum: { |
|
604 bool xOk; |
|
605 int x = args[0]->toInt32(exec, xOk); |
|
606 if (!xOk) { |
|
607 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
608 return jsUndefined(); |
|
609 } |
|
610 bool yOk; |
|
611 int y = args[1]->toInt32(exec, yOk); |
|
612 if (!yOk) { |
|
613 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
614 return jsUndefined(); |
|
615 } |
|
616 |
|
617 |
|
618 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->elementFromPoint(x, y))); |
|
619 return result; |
|
620 } |
|
621 } |
|
622 return 0; |
|
623 } |
|
624 |
|
625 } |