|
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 "JSHTMLDocument.h" |
|
24 |
|
25 #include <wtf/GetPtr.h> |
|
26 |
|
27 #include "AtomicString.h" |
|
28 #include "Element.h" |
|
29 #include "HTMLCollection.h" |
|
30 #include "HTMLDocument.h" |
|
31 #include "HTMLElement.h" |
|
32 #include "JSElement.h" |
|
33 #include "JSHTMLCollection.h" |
|
34 #include "JSHTMLElement.h" |
|
35 #include "JSNodeList.h" |
|
36 #include "NameNodeList.h" |
|
37 #include "NodeList.h" |
|
38 #include "PlatformString.h" |
|
39 |
|
40 using namespace KJS; |
|
41 |
|
42 namespace WebCore { |
|
43 |
|
44 /* Hash table */ |
|
45 |
|
46 static const HashEntry JSHTMLDocumentTableEntries[] = |
|
47 { |
|
48 { "domain", JSHTMLDocument::DomainAttrNum, DontDelete, 0, &JSHTMLDocumentTableEntries[27] }, |
|
49 { 0, 0, 0, 0, 0 }, |
|
50 { "height", JSHTMLDocument::HeightAttrNum, DontDelete|ReadOnly, 0, &JSHTMLDocumentTableEntries[37] }, |
|
51 { 0, 0, 0, 0, 0 }, |
|
52 { 0, 0, 0, 0, 0 }, |
|
53 { 0, 0, 0, 0, 0 }, |
|
54 { "forms", JSHTMLDocument::FormsAttrNum, DontDelete|ReadOnly, 0, &JSHTMLDocumentTableEntries[29] }, |
|
55 { "applets", JSHTMLDocument::AppletsAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
56 { 0, 0, 0, 0, 0 }, |
|
57 { "cookie", JSHTMLDocument::CookieAttrNum, DontDelete, 0, 0 }, |
|
58 { 0, 0, 0, 0, 0 }, |
|
59 { "designMode", JSHTMLDocument::DesignModeAttrNum, DontDelete, 0, &JSHTMLDocumentTableEntries[36] }, |
|
60 { 0, 0, 0, 0, 0 }, |
|
61 { "URL", JSHTMLDocument::URLAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
62 { 0, 0, 0, 0, 0 }, |
|
63 { "title", JSHTMLDocument::TitleAttrNum, DontDelete, 0, &JSHTMLDocumentTableEntries[31] }, |
|
64 { "scripts", JSHTMLDocument::ScriptsAttrNum, DontDelete|ReadOnly, 0, &JSHTMLDocumentTableEntries[38] }, |
|
65 { "anchors", JSHTMLDocument::AnchorsAttrNum, DontDelete|ReadOnly, 0, &JSHTMLDocumentTableEntries[30] }, |
|
66 { "body", JSHTMLDocument::BodyAttrNum, DontDelete, 0, &JSHTMLDocumentTableEntries[35] }, |
|
67 { "referrer", JSHTMLDocument::ReferrerAttrNum, DontDelete|ReadOnly, 0, &JSHTMLDocumentTableEntries[32] }, |
|
68 { 0, 0, 0, 0, 0 }, |
|
69 { "constructor", JSHTMLDocument::ConstructorAttrNum, DontDelete|DontEnum|ReadOnly, 0, 0 }, |
|
70 { "images", JSHTMLDocument::ImagesAttrNum, DontDelete|ReadOnly, 0, &JSHTMLDocumentTableEntries[33] }, |
|
71 { 0, 0, 0, 0, 0 }, |
|
72 { "bgColor", JSHTMLDocument::BgColorAttrNum, DontDelete, 0, 0 }, |
|
73 { 0, 0, 0, 0, 0 }, |
|
74 { 0, 0, 0, 0, 0 }, |
|
75 { "links", JSHTMLDocument::LinksAttrNum, DontDelete|ReadOnly, 0, &JSHTMLDocumentTableEntries[28] }, |
|
76 { "embeds", JSHTMLDocument::EmbedsAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
77 { "plugins", JSHTMLDocument::PluginsAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
78 { "lastModified", JSHTMLDocument::LastModifiedAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
79 { "all", JSHTMLDocument::AllAttrNum, 0, 0, 0 }, |
|
80 { "location", JSHTMLDocument::LocationAttrNum, DontDelete, 0, 0 }, |
|
81 { "width", JSHTMLDocument::WidthAttrNum, DontDelete|ReadOnly, 0, &JSHTMLDocumentTableEntries[34] }, |
|
82 { "dir", JSHTMLDocument::DirAttrNum, DontDelete, 0, 0 }, |
|
83 { "fgColor", JSHTMLDocument::FgColorAttrNum, DontDelete, 0, 0 }, |
|
84 { "alinkColor", JSHTMLDocument::AlinkColorAttrNum, DontDelete, 0, 0 }, |
|
85 { "linkColor", JSHTMLDocument::LinkColorAttrNum, DontDelete, 0, 0 }, |
|
86 { "vlinkColor", JSHTMLDocument::VlinkColorAttrNum, DontDelete, 0, 0 } |
|
87 }; |
|
88 |
|
89 static const HashTable JSHTMLDocumentTable = |
|
90 { |
|
91 2, 39, JSHTMLDocumentTableEntries, 27 |
|
92 }; |
|
93 |
|
94 /* Hash table for constructor */ |
|
95 |
|
96 static const HashEntry JSHTMLDocumentConstructorTableEntries[] = |
|
97 { |
|
98 { 0, 0, 0, 0, 0 } |
|
99 }; |
|
100 |
|
101 static const HashTable JSHTMLDocumentConstructorTable = |
|
102 { |
|
103 2, 1, JSHTMLDocumentConstructorTableEntries, 1 |
|
104 }; |
|
105 |
|
106 class JSHTMLDocumentConstructor : public DOMObject { |
|
107 public: |
|
108 JSHTMLDocumentConstructor(ExecState* exec) |
|
109 { |
|
110 setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype()); |
|
111 putDirect(exec->propertyNames().prototype, JSHTMLDocumentPrototype::self(exec), None); |
|
112 } |
|
113 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); |
|
114 JSValue* getValueProperty(ExecState*, int token) const; |
|
115 virtual const ClassInfo* classInfo() const { return &info; } |
|
116 static const ClassInfo info; |
|
117 |
|
118 virtual bool implementsHasInstance() const { return true; } |
|
119 }; |
|
120 |
|
121 const ClassInfo JSHTMLDocumentConstructor::info = { "HTMLDocumentConstructor", 0, &JSHTMLDocumentConstructorTable, 0 }; |
|
122 |
|
123 bool JSHTMLDocumentConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
124 { |
|
125 return getStaticValueSlot<JSHTMLDocumentConstructor, DOMObject>(exec, &JSHTMLDocumentConstructorTable, this, propertyName, slot); |
|
126 } |
|
127 |
|
128 JSValue* JSHTMLDocumentConstructor::getValueProperty(ExecState*, int token) const |
|
129 { |
|
130 // The token is the numeric value of its associated constant |
|
131 return jsNumber(token); |
|
132 } |
|
133 |
|
134 /* Hash table for prototype */ |
|
135 |
|
136 static const HashEntry JSHTMLDocumentPrototypeTableEntries[] = |
|
137 { |
|
138 { "close", JSHTMLDocument::CloseFuncNum, DontDelete|Function, 0, &JSHTMLDocumentPrototypeTableEntries[10] }, |
|
139 { 0, 0, 0, 0, 0 }, |
|
140 { 0, 0, 0, 0, 0 }, |
|
141 { "releaseEvents", JSHTMLDocument::ReleaseEventsFuncNum, DontDelete|Function, 0, 0 }, |
|
142 { "clear", JSHTMLDocument::ClearFuncNum, DontDelete|Function, 0, 0 }, |
|
143 { "write", JSHTMLDocument::WriteFuncNum, DontDelete|Function, 1, &JSHTMLDocumentPrototypeTableEntries[9] }, |
|
144 { "open", JSHTMLDocument::OpenFuncNum, DontDelete|Function, 0, 0 }, |
|
145 { "getElementsByName", JSHTMLDocument::GetElementsByNameFuncNum, DontDelete|Function, 1, 0 }, |
|
146 { "getElementById", JSHTMLDocument::GetElementByIdFuncNum, DontDelete|Function, 1, 0 }, |
|
147 { "writeln", JSHTMLDocument::WritelnFuncNum, DontDelete|Function, 1, 0 }, |
|
148 { "captureEvents", JSHTMLDocument::CaptureEventsFuncNum, DontDelete|Function, 0, 0 } |
|
149 }; |
|
150 |
|
151 static const HashTable JSHTMLDocumentPrototypeTable = |
|
152 { |
|
153 2, 11, JSHTMLDocumentPrototypeTableEntries, 9 |
|
154 }; |
|
155 |
|
156 const ClassInfo JSHTMLDocumentPrototype::info = { "HTMLDocumentPrototype", 0, &JSHTMLDocumentPrototypeTable, 0 }; |
|
157 |
|
158 JSObject* JSHTMLDocumentPrototype::self(ExecState* exec) |
|
159 { |
|
160 return KJS::cacheGlobalObject<JSHTMLDocumentPrototype>(exec, "[[JSHTMLDocument.prototype]]"); |
|
161 } |
|
162 |
|
163 bool JSHTMLDocumentPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
164 { |
|
165 return getStaticFunctionSlot<JSHTMLDocumentPrototypeFunction, JSObject>(exec, &JSHTMLDocumentPrototypeTable, this, propertyName, slot); |
|
166 } |
|
167 |
|
168 const ClassInfo JSHTMLDocument::info = { "HTMLDocument", &JSDocument::info, &JSHTMLDocumentTable, 0 }; |
|
169 |
|
170 JSHTMLDocument::JSHTMLDocument(ExecState* exec, HTMLDocument* impl) |
|
171 : JSDocument(exec, impl) |
|
172 { |
|
173 setPrototype(JSHTMLDocumentPrototype::self(exec)); |
|
174 } |
|
175 |
|
176 bool JSHTMLDocument::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
177 { |
|
178 if (canGetItemsForName(exec, static_cast<HTMLDocument*>(impl()), propertyName)) { |
|
179 slot.setCustom(this, nameGetter); |
|
180 return true; |
|
181 } |
|
182 return getStaticValueSlot<JSHTMLDocument, JSDocument>(exec, &JSHTMLDocumentTable, this, propertyName, slot); |
|
183 } |
|
184 |
|
185 JSValue* JSHTMLDocument::getValueProperty(ExecState* exec, int token) const |
|
186 { |
|
187 switch (token) { |
|
188 case TitleAttrNum: { |
|
189 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
190 |
|
191 return jsString(imp->title()); |
|
192 } |
|
193 case ReferrerAttrNum: { |
|
194 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
195 |
|
196 return jsString(imp->referrer()); |
|
197 } |
|
198 case DomainAttrNum: { |
|
199 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
200 |
|
201 return jsString(imp->domain()); |
|
202 } |
|
203 case URLAttrNum: { |
|
204 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
205 |
|
206 return jsString(imp->URL()); |
|
207 } |
|
208 case BodyAttrNum: { |
|
209 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
210 |
|
211 return toJS(exec, WTF::getPtr(imp->body())); |
|
212 } |
|
213 case ImagesAttrNum: { |
|
214 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
215 |
|
216 return toJS(exec, WTF::getPtr(imp->images())); |
|
217 } |
|
218 case AppletsAttrNum: { |
|
219 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
220 |
|
221 return toJS(exec, WTF::getPtr(imp->applets())); |
|
222 } |
|
223 case LinksAttrNum: { |
|
224 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
225 |
|
226 return toJS(exec, WTF::getPtr(imp->links())); |
|
227 } |
|
228 case FormsAttrNum: { |
|
229 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
230 |
|
231 return toJS(exec, WTF::getPtr(imp->forms())); |
|
232 } |
|
233 case AnchorsAttrNum: { |
|
234 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
235 |
|
236 return toJS(exec, WTF::getPtr(imp->anchors())); |
|
237 } |
|
238 case CookieAttrNum: { |
|
239 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
240 |
|
241 return jsString(imp->cookie()); |
|
242 } |
|
243 case EmbedsAttrNum: { |
|
244 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
245 |
|
246 return toJS(exec, WTF::getPtr(imp->embeds())); |
|
247 } |
|
248 case PluginsAttrNum: { |
|
249 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
250 |
|
251 return toJS(exec, WTF::getPtr(imp->plugins())); |
|
252 } |
|
253 case ScriptsAttrNum: { |
|
254 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
255 |
|
256 return toJS(exec, WTF::getPtr(imp->scripts())); |
|
257 } |
|
258 case LastModifiedAttrNum: { |
|
259 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
260 |
|
261 return jsString(imp->lastModified()); |
|
262 } |
|
263 case AllAttrNum: { |
|
264 return all(exec); |
|
265 } |
|
266 case LocationAttrNum: { |
|
267 return location(exec); |
|
268 } |
|
269 case WidthAttrNum: { |
|
270 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
271 |
|
272 return jsNumber(imp->width()); |
|
273 } |
|
274 case HeightAttrNum: { |
|
275 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
276 |
|
277 return jsNumber(imp->height()); |
|
278 } |
|
279 case DirAttrNum: { |
|
280 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
281 |
|
282 return jsString(imp->dir()); |
|
283 } |
|
284 case DesignModeAttrNum: { |
|
285 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
286 |
|
287 return jsString(imp->designMode()); |
|
288 } |
|
289 case BgColorAttrNum: { |
|
290 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
291 |
|
292 return jsString(imp->bgColor()); |
|
293 } |
|
294 case FgColorAttrNum: { |
|
295 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
296 |
|
297 return jsString(imp->fgColor()); |
|
298 } |
|
299 case AlinkColorAttrNum: { |
|
300 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
301 |
|
302 return jsString(imp->alinkColor()); |
|
303 } |
|
304 case LinkColorAttrNum: { |
|
305 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
306 |
|
307 return jsString(imp->linkColor()); |
|
308 } |
|
309 case VlinkColorAttrNum: { |
|
310 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
311 |
|
312 return jsString(imp->vlinkColor()); |
|
313 } |
|
314 case ConstructorAttrNum: |
|
315 return getConstructor(exec); |
|
316 } |
|
317 return 0; |
|
318 } |
|
319 |
|
320 void JSHTMLDocument::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) |
|
321 { |
|
322 lookupPut<JSHTMLDocument, JSDocument>(exec, propertyName, value, attr, &JSHTMLDocumentTable, this); |
|
323 } |
|
324 |
|
325 void JSHTMLDocument::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/) |
|
326 { |
|
327 switch (token) { |
|
328 case TitleAttrNum: { |
|
329 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
330 |
|
331 imp->setTitle(valueToStringWithNullCheck(exec, value)); |
|
332 break; |
|
333 } |
|
334 case DomainAttrNum: { |
|
335 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
336 |
|
337 imp->setDomain(value->toString(exec)); |
|
338 break; |
|
339 } |
|
340 case BodyAttrNum: { |
|
341 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
342 |
|
343 ExceptionCode ec = 0; |
|
344 imp->setBody(toHTMLElement(value), ec); |
|
345 setDOMException(exec, ec); |
|
346 break; |
|
347 } |
|
348 case CookieAttrNum: { |
|
349 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
350 |
|
351 imp->setCookie(valueToStringWithNullCheck(exec, value)); |
|
352 break; |
|
353 } |
|
354 case AllAttrNum: { |
|
355 setAll(exec, value); |
|
356 break; |
|
357 } |
|
358 case LocationAttrNum: { |
|
359 setLocation(exec, value); |
|
360 break; |
|
361 } |
|
362 case DirAttrNum: { |
|
363 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
364 |
|
365 imp->setDir(valueToStringWithNullCheck(exec, value)); |
|
366 break; |
|
367 } |
|
368 case DesignModeAttrNum: { |
|
369 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
370 |
|
371 imp->setDesignMode(valueToStringWithNullCheck(exec, value)); |
|
372 break; |
|
373 } |
|
374 case BgColorAttrNum: { |
|
375 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
376 |
|
377 imp->setBgColor(valueToStringWithNullCheck(exec, value)); |
|
378 break; |
|
379 } |
|
380 case FgColorAttrNum: { |
|
381 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
382 |
|
383 imp->setFgColor(valueToStringWithNullCheck(exec, value)); |
|
384 break; |
|
385 } |
|
386 case AlinkColorAttrNum: { |
|
387 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
388 |
|
389 imp->setAlinkColor(valueToStringWithNullCheck(exec, value)); |
|
390 break; |
|
391 } |
|
392 case LinkColorAttrNum: { |
|
393 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
394 |
|
395 imp->setLinkColor(valueToStringWithNullCheck(exec, value)); |
|
396 break; |
|
397 } |
|
398 case VlinkColorAttrNum: { |
|
399 HTMLDocument* imp = static_cast<HTMLDocument*>(impl()); |
|
400 |
|
401 imp->setVlinkColor(valueToStringWithNullCheck(exec, value)); |
|
402 break; |
|
403 } |
|
404 } |
|
405 } |
|
406 |
|
407 JSValue* JSHTMLDocument::getConstructor(ExecState* exec) |
|
408 { |
|
409 return KJS::cacheGlobalObject<JSHTMLDocumentConstructor>(exec, "[[HTMLDocument.constructor]]"); |
|
410 } |
|
411 JSValue* JSHTMLDocumentPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) |
|
412 { |
|
413 if (!thisObj->inherits(&JSHTMLDocument::info)) |
|
414 return throwError(exec, TypeError); |
|
415 |
|
416 HTMLDocument* imp = static_cast<HTMLDocument*>(static_cast<JSHTMLDocument*>(thisObj)->impl()); |
|
417 |
|
418 switch (id) { |
|
419 case JSHTMLDocument::OpenFuncNum: { |
|
420 return static_cast<JSHTMLDocument*>(thisObj)->open(exec, args); |
|
421 } |
|
422 case JSHTMLDocument::CloseFuncNum: { |
|
423 |
|
424 imp->close(); |
|
425 return jsUndefined(); |
|
426 } |
|
427 case JSHTMLDocument::WriteFuncNum: { |
|
428 return static_cast<JSHTMLDocument*>(thisObj)->write(exec, args); |
|
429 } |
|
430 case JSHTMLDocument::WritelnFuncNum: { |
|
431 return static_cast<JSHTMLDocument*>(thisObj)->writeln(exec, args); |
|
432 } |
|
433 case JSHTMLDocument::GetElementsByNameFuncNum: { |
|
434 String elementName = args[0]->toString(exec); |
|
435 |
|
436 |
|
437 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->getElementsByName(elementName))); |
|
438 return result; |
|
439 } |
|
440 case JSHTMLDocument::GetElementByIdFuncNum: { |
|
441 String elementId = args[0]->toString(exec); |
|
442 |
|
443 |
|
444 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->getElementById(elementId))); |
|
445 return result; |
|
446 } |
|
447 case JSHTMLDocument::ClearFuncNum: { |
|
448 return static_cast<JSHTMLDocument*>(thisObj)->clear(exec, args); |
|
449 } |
|
450 case JSHTMLDocument::CaptureEventsFuncNum: { |
|
451 |
|
452 imp->captureEvents(); |
|
453 return jsUndefined(); |
|
454 } |
|
455 case JSHTMLDocument::ReleaseEventsFuncNum: { |
|
456 |
|
457 imp->releaseEvents(); |
|
458 return jsUndefined(); |
|
459 } |
|
460 } |
|
461 return 0; |
|
462 } |
|
463 |
|
464 } |