1 /*
2 * This file is part of the HTML DOM implementation for KDE.
3 *
4 * Copyright (C) 2005 Apple Computer, Inc.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #include "config.h"
24 #include "HTMLElementFactory.h"
25
26 #include "HTMLAnchorElement.h"
27 #include "HTMLAppletElement.h"
28 #include "HTMLAreaElement.h"
29 #include "HTMLAudioElement.h"
30 #include "HTMLBRElement.h"
31 #include "HTMLBaseElement.h"
32 #include "HTMLBaseFontElement.h"
33 #include "HTMLBlockquoteElement.h"
34 #include "HTMLBodyElement.h"
35 #include "HTMLButtonElement.h"
36 #include "HTMLCanvasElement.h"
37 #include "HTMLDListElement.h"
38 #include "HTMLDirectoryElement.h"
39 #include "HTMLDivElement.h"
40 #include "HTMLDocument.h"
41 #include "HTMLEmbedElement.h"
42 #include "HTMLFieldSetElement.h"
43 #include "HTMLFontElement.h"
44 #include "HTMLFormElement.h"
45 #include "HTMLFrameElement.h"
46 #include "HTMLFrameSetElement.h"
47 #include "HTMLHRElement.h"
48 #include "HTMLHeadElement.h"
49 #include "HTMLHeadingElement.h"
50 #include "HTMLHtmlElement.h"
51 #include "HTMLIFrameElement.h"
52 #include "HTMLImageElement.h"
53 #include "HTMLIsIndexElement.h"
54 #include "HTMLKeygenElement.h"
55 #include "HTMLLIElement.h"
56 #include "HTMLLabelElement.h"
57 #include "HTMLLegendElement.h"
58 #include "HTMLLinkElement.h"
59 #include "HTMLMapElement.h"
60 #include "HTMLMarqueeElement.h"
61 #include "HTMLMenuElement.h"
62 #include "HTMLMetaElement.h"
63 #include "HTMLModElement.h"
64 #include "HTMLNames.h"
65 #include "HTMLOListElement.h"
66 #include "HTMLObjectElement.h"
67 #include "HTMLOptGroupElement.h"
68 #include "HTMLOptionElement.h"
69 #include "HTMLParagraphElement.h"
70 #include "HTMLParamElement.h"
71 #include "HTMLPreElement.h"
72 #include "HTMLQuoteElement.h"
73 #include "HTMLScriptElement.h"
74 #include "HTMLSelectElement.h"
75 #include "HTMLSourceElement.h"
76 #include "HTMLStyleElement.h"
77 #include "HTMLTableCaptionElement.h"
78 #include "HTMLTableCellElement.h"
79 #include "HTMLTableColElement.h"
80 #include "HTMLTableElement.h"
81 #include "HTMLTableRowElement.h"
82 #include "HTMLTableSectionElement.h"
83 #include "HTMLTextAreaElement.h"
84 #include "HTMLTitleElement.h"
85 #include "HTMLUListElement.h"
86 #include "HTMLVideoElement.h"
87
88 namespace WebCore {
89
90 using namespace HTMLNames;
91
92 typedef PassRefPtr<HTMLElement> (*ConstructorFunc)(const QualifiedName& tagName, Document*, HTMLFormElement*, bool createdByParser);
93 typedef HashMap<AtomicStringImpl*, ConstructorFunc> FunctionMap;
94 static FunctionMap* gFunctionMap;
95
htmlConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)96 static PassRefPtr<HTMLElement> htmlConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
97 {
98 return new HTMLHtmlElement(htmlTag, doc);
99 }
100
headConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)101 static PassRefPtr<HTMLElement> headConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
102 {
103 return new HTMLHeadElement(headTag, doc);
104 }
105
bodyConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)106 static PassRefPtr<HTMLElement> bodyConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
107 {
108 return new HTMLBodyElement(bodyTag, doc);
109 }
110
baseConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)111 static PassRefPtr<HTMLElement> baseConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
112 {
113 return new HTMLBaseElement(baseTag, doc);
114 }
115
linkConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool createdByParser)116 static PassRefPtr<HTMLElement> linkConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool createdByParser)
117 {
118 return new HTMLLinkElement(linkTag, doc, createdByParser);
119 }
120
metaConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)121 static PassRefPtr<HTMLElement> metaConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
122 {
123 return new HTMLMetaElement(metaTag, doc);
124 }
125
styleConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool createdByParser)126 static PassRefPtr<HTMLElement> styleConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool createdByParser)
127 {
128 return new HTMLStyleElement(styleTag, doc, createdByParser);
129 }
130
titleConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)131 static PassRefPtr<HTMLElement> titleConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
132 {
133 return new HTMLTitleElement(titleTag, doc);
134 }
135
frameConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool createdByParser)136 static PassRefPtr<HTMLElement> frameConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool createdByParser)
137 {
138 return new HTMLFrameElement(frameTag, doc, createdByParser);
139 }
140
framesetConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)141 static PassRefPtr<HTMLElement> framesetConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
142 {
143 return new HTMLFrameSetElement(framesetTag, doc);
144 }
145
iframeConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool createdByParser)146 static PassRefPtr<HTMLElement> iframeConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool createdByParser)
147 {
148 return new HTMLIFrameElement(iframeTag, doc, createdByParser);
149 }
150
formConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)151 static PassRefPtr<HTMLElement> formConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
152 {
153 return new HTMLFormElement(formTag, doc);
154 }
155
buttonConstructor(const QualifiedName &,Document * doc,HTMLFormElement * form,bool)156 static PassRefPtr<HTMLElement> buttonConstructor(const QualifiedName&, Document* doc, HTMLFormElement* form, bool)
157 {
158 return new HTMLButtonElement(buttonTag, doc, form);
159 }
160
inputConstructor(const QualifiedName &,Document * doc,HTMLFormElement * form,bool)161 static PassRefPtr<HTMLElement> inputConstructor(const QualifiedName&, Document* doc, HTMLFormElement* form, bool)
162 {
163 return new HTMLInputElement(inputTag, doc, form);
164 }
165
isindexConstructor(const QualifiedName &,Document * doc,HTMLFormElement * form,bool)166 static PassRefPtr<HTMLElement> isindexConstructor(const QualifiedName&, Document* doc, HTMLFormElement* form, bool)
167 {
168 return new HTMLIsIndexElement(isindexTag, doc, form);
169 }
170
fieldsetConstructor(const QualifiedName &,Document * doc,HTMLFormElement * form,bool)171 static PassRefPtr<HTMLElement> fieldsetConstructor(const QualifiedName&, Document* doc, HTMLFormElement* form, bool)
172 {
173 return new HTMLFieldSetElement(fieldsetTag, doc, form);
174 }
175
keygenConstructor(const QualifiedName &,Document * doc,HTMLFormElement * form,bool)176 static PassRefPtr<HTMLElement> keygenConstructor(const QualifiedName&, Document* doc, HTMLFormElement* form, bool)
177 {
178 return new HTMLKeygenElement(keygenTag, doc, form);
179 }
180
labelConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)181 static PassRefPtr<HTMLElement> labelConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
182 {
183 return new HTMLLabelElement(labelTag, doc);
184 }
185
legendConstructor(const QualifiedName &,Document * doc,HTMLFormElement * form,bool)186 static PassRefPtr<HTMLElement> legendConstructor(const QualifiedName&, Document* doc, HTMLFormElement* form, bool)
187 {
188 return new HTMLLegendElement(legendTag, doc, form);
189 }
190
optgroupConstructor(const QualifiedName &,Document * doc,HTMLFormElement * form,bool)191 static PassRefPtr<HTMLElement> optgroupConstructor(const QualifiedName&, Document* doc, HTMLFormElement* form, bool)
192 {
193 return new HTMLOptGroupElement(optgroupTag, doc, form);
194 }
195
optionConstructor(const QualifiedName &,Document * doc,HTMLFormElement * form,bool)196 static PassRefPtr<HTMLElement> optionConstructor(const QualifiedName&, Document* doc, HTMLFormElement* form, bool)
197 {
198 return new HTMLOptionElement(optionTag, doc, form);
199 }
200
selectConstructor(const QualifiedName &,Document * doc,HTMLFormElement * form,bool)201 static PassRefPtr<HTMLElement> selectConstructor(const QualifiedName&, Document* doc, HTMLFormElement* form, bool)
202 {
203 return new HTMLSelectElement(selectTag, doc, form);
204 }
205
textareaConstructor(const QualifiedName &,Document * doc,HTMLFormElement * form,bool)206 static PassRefPtr<HTMLElement> textareaConstructor(const QualifiedName&, Document* doc, HTMLFormElement* form, bool)
207 {
208 return new HTMLTextAreaElement(textareaTag, doc, form);
209 }
210
dlConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)211 static PassRefPtr<HTMLElement> dlConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
212 {
213 return new HTMLDListElement(dlTag, doc);
214 }
215
ulConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)216 static PassRefPtr<HTMLElement> ulConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
217 {
218 return new HTMLUListElement(ulTag, doc);
219 }
220
olConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)221 static PassRefPtr<HTMLElement> olConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
222 {
223 return new HTMLOListElement(olTag, doc);
224 }
225
dirConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)226 static PassRefPtr<HTMLElement> dirConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
227 {
228 return new HTMLDirectoryElement(dirTag, doc);
229 }
230
menuConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)231 static PassRefPtr<HTMLElement> menuConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
232 {
233 return new HTMLMenuElement(menuTag, doc);
234 }
235
liConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)236 static PassRefPtr<HTMLElement> liConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
237 {
238 return new HTMLLIElement(liTag, doc);
239 }
240
blockquoteConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)241 static PassRefPtr<HTMLElement> blockquoteConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
242 {
243 return new HTMLBlockquoteElement(blockquoteTag, doc);
244 }
245
divConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)246 static PassRefPtr<HTMLElement> divConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
247 {
248 return new HTMLDivElement(divTag, doc);
249 }
250
headingConstructor(const QualifiedName & tagName,Document * doc,HTMLFormElement *,bool)251 static PassRefPtr<HTMLElement> headingConstructor(const QualifiedName& tagName, Document* doc, HTMLFormElement*, bool)
252 {
253 return new HTMLHeadingElement(tagName, doc);
254 }
255
hrConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)256 static PassRefPtr<HTMLElement> hrConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
257 {
258 return new HTMLHRElement(hrTag, doc);
259 }
260
paragraphConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)261 static PassRefPtr<HTMLElement> paragraphConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
262 {
263 return new HTMLParagraphElement(pTag, doc);
264 }
265
preConstructor(const QualifiedName & tagName,Document * doc,HTMLFormElement *,bool)266 static PassRefPtr<HTMLElement> preConstructor(const QualifiedName& tagName, Document* doc, HTMLFormElement*, bool)
267 {
268 return new HTMLPreElement(tagName, doc);
269 }
270
basefontConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)271 static PassRefPtr<HTMLElement> basefontConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
272 {
273 return new HTMLBaseFontElement(basefontTag, doc);
274 }
275
fontConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)276 static PassRefPtr<HTMLElement> fontConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
277 {
278 return new HTMLFontElement(fontTag, doc);
279 }
280
modConstructor(const QualifiedName & tagName,Document * doc,HTMLFormElement *,bool)281 static PassRefPtr<HTMLElement> modConstructor(const QualifiedName& tagName, Document* doc, HTMLFormElement*, bool)
282 {
283 return new HTMLModElement(tagName, doc);
284 }
285
anchorConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)286 static PassRefPtr<HTMLElement> anchorConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
287 {
288 return new HTMLAnchorElement(aTag, doc);
289 }
290
imageConstructor(const QualifiedName &,Document * doc,HTMLFormElement * form,bool)291 static PassRefPtr<HTMLElement> imageConstructor(const QualifiedName&, Document* doc, HTMLFormElement* form, bool)
292 {
293 return new HTMLImageElement(imgTag, doc, form);
294 }
295
mapConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)296 static PassRefPtr<HTMLElement> mapConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
297 {
298 return new HTMLMapElement(mapTag, doc);
299 }
300
areaConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)301 static PassRefPtr<HTMLElement> areaConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
302 {
303 return new HTMLAreaElement(areaTag, doc);
304 }
305
canvasConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)306 static PassRefPtr<HTMLElement> canvasConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
307 {
308 return new HTMLCanvasElement(canvasTag, doc);
309 }
310
appletConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)311 static PassRefPtr<HTMLElement> appletConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
312 {
313 return new HTMLAppletElement(appletTag, doc);
314 }
315
embedConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)316 static PassRefPtr<HTMLElement> embedConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
317 {
318 return new HTMLEmbedElement(embedTag, doc);
319 }
320
objectConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool createdByParser)321 static PassRefPtr<HTMLElement> objectConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool createdByParser)
322 {
323 return new HTMLObjectElement(objectTag, doc, createdByParser);
324 }
325
paramConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)326 static PassRefPtr<HTMLElement> paramConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
327 {
328 return new HTMLParamElement(paramTag, doc);
329 }
330
scriptConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool createdByParser)331 static PassRefPtr<HTMLElement> scriptConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool createdByParser)
332 {
333 return new HTMLScriptElement(scriptTag, doc, createdByParser);
334 }
335
tableConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)336 static PassRefPtr<HTMLElement> tableConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
337 {
338 return new HTMLTableElement(tableTag, doc);
339 }
340
tableCaptionConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)341 static PassRefPtr<HTMLElement> tableCaptionConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
342 {
343 return new HTMLTableCaptionElement(captionTag, doc);
344 }
345
tableColConstructor(const QualifiedName & tagName,Document * doc,HTMLFormElement *,bool)346 static PassRefPtr<HTMLElement> tableColConstructor(const QualifiedName& tagName, Document* doc, HTMLFormElement*, bool)
347 {
348 return new HTMLTableColElement(tagName, doc);
349 }
350
tableRowConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)351 static PassRefPtr<HTMLElement> tableRowConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
352 {
353 return new HTMLTableRowElement(trTag, doc);
354 }
355
tableCellConstructor(const QualifiedName & tagName,Document * doc,HTMLFormElement *,bool)356 static PassRefPtr<HTMLElement> tableCellConstructor(const QualifiedName& tagName, Document* doc, HTMLFormElement*, bool)
357 {
358 return new HTMLTableCellElement(tagName, doc);
359 }
360
tableSectionConstructor(const QualifiedName & tagName,Document * doc,HTMLFormElement *,bool)361 static PassRefPtr<HTMLElement> tableSectionConstructor(const QualifiedName& tagName, Document* doc, HTMLFormElement*, bool)
362 {
363 return new HTMLTableSectionElement(tagName, doc);
364 }
365
brConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)366 static PassRefPtr<HTMLElement> brConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
367 {
368 return new HTMLBRElement(brTag, doc);
369 }
370
quoteConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)371 static PassRefPtr<HTMLElement> quoteConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
372 {
373 doc->setUsesBeforeAfterRules(true);
374 return new HTMLQuoteElement(qTag, doc);
375 }
376
marqueeConstructor(const QualifiedName &,Document * doc,HTMLFormElement *,bool)377 static PassRefPtr<HTMLElement> marqueeConstructor(const QualifiedName&, Document* doc, HTMLFormElement*, bool)
378 {
379 return new HTMLMarqueeElement(marqueeTag, doc);
380 }
381
382 #if ENABLE(VIDEO)
audioConstructor(const QualifiedName & tagName,Document * doc,HTMLFormElement *,bool)383 static PassRefPtr<HTMLElement> audioConstructor(const QualifiedName& tagName, Document* doc, HTMLFormElement*, bool)
384 {
385 if (!MediaPlayer::isAvailable())
386 return new HTMLElement(tagName, doc);
387 return new HTMLAudioElement(audioTag, doc);
388 }
389
videoConstructor(const QualifiedName & tagName,Document * doc,HTMLFormElement *,bool)390 static PassRefPtr<HTMLElement> videoConstructor(const QualifiedName& tagName, Document* doc, HTMLFormElement*, bool)
391 {
392 if (!MediaPlayer::isAvailable())
393 return new HTMLElement(tagName, doc);
394 return new HTMLVideoElement(videoTag, doc);
395 }
396
sourceConstructor(const QualifiedName & tagName,Document * doc,HTMLFormElement *,bool)397 static PassRefPtr<HTMLElement> sourceConstructor(const QualifiedName& tagName, Document* doc, HTMLFormElement*, bool)
398 {
399 if (!MediaPlayer::isAvailable())
400 return new HTMLElement(tagName, doc);
401 return new HTMLSourceElement(sourceTag, doc);
402 }
403 #endif
404
addTag(const QualifiedName & tag,ConstructorFunc func)405 static void addTag(const QualifiedName& tag, ConstructorFunc func)
406 {
407 gFunctionMap->set(tag.localName().impl(), func);
408 }
409
createFunctionMap()410 static void createFunctionMap()
411 {
412 // Create the table.
413 gFunctionMap = new FunctionMap;
414
415 // Populate it with constructor functions.
416 addTag(aTag, anchorConstructor);
417 addTag(appletTag, appletConstructor);
418 addTag(areaTag, areaConstructor);
419 addTag(baseTag, baseConstructor);
420 addTag(basefontTag, basefontConstructor);
421 addTag(blockquoteTag, blockquoteConstructor);
422 addTag(bodyTag, bodyConstructor);
423 addTag(brTag, brConstructor);
424 addTag(buttonTag, buttonConstructor);
425 addTag(canvasTag, canvasConstructor);
426 addTag(captionTag, tableCaptionConstructor);
427 addTag(colTag, tableColConstructor);
428 addTag(colgroupTag, tableColConstructor);
429 addTag(delTag, modConstructor);
430 addTag(dirTag, dirConstructor);
431 addTag(divTag, divConstructor);
432 addTag(dlTag, dlConstructor);
433 addTag(embedTag, embedConstructor);
434 addTag(fieldsetTag, fieldsetConstructor);
435 addTag(fontTag, fontConstructor);
436 addTag(formTag, formConstructor);
437 addTag(frameTag, frameConstructor);
438 addTag(framesetTag, framesetConstructor);
439 addTag(h1Tag, headingConstructor);
440 addTag(h2Tag, headingConstructor);
441 addTag(h3Tag, headingConstructor);
442 addTag(h4Tag, headingConstructor);
443 addTag(h5Tag, headingConstructor);
444 addTag(h6Tag, headingConstructor);
445 addTag(headTag, headConstructor);
446 addTag(hrTag, hrConstructor);
447 addTag(htmlTag, htmlConstructor);
448 addTag(iframeTag, iframeConstructor);
449 addTag(imageTag, imageConstructor);
450 addTag(imgTag, imageConstructor);
451 addTag(inputTag, inputConstructor);
452 addTag(insTag, modConstructor);
453 addTag(isindexTag, isindexConstructor);
454 addTag(keygenTag, keygenConstructor);
455 addTag(labelTag, labelConstructor);
456 addTag(legendTag, legendConstructor);
457 addTag(liTag, liConstructor);
458 addTag(linkTag, linkConstructor);
459 addTag(listingTag, preConstructor);
460 addTag(mapTag, mapConstructor);
461 addTag(marqueeTag, marqueeConstructor);
462 addTag(menuTag, menuConstructor);
463 addTag(metaTag, metaConstructor);
464 addTag(objectTag, objectConstructor);
465 addTag(olTag, olConstructor);
466 addTag(optgroupTag, optgroupConstructor);
467 addTag(optionTag, optionConstructor);
468 addTag(pTag, paragraphConstructor);
469 addTag(paramTag, paramConstructor);
470 addTag(preTag, preConstructor);
471 addTag(qTag, quoteConstructor);
472 addTag(scriptTag, scriptConstructor);
473 addTag(selectTag, selectConstructor);
474 addTag(styleTag, styleConstructor);
475 addTag(tableTag, tableConstructor);
476 addTag(tbodyTag, tableSectionConstructor);
477 addTag(tdTag, tableCellConstructor);
478 addTag(textareaTag, textareaConstructor);
479 addTag(tfootTag, tableSectionConstructor);
480 addTag(thTag, tableCellConstructor);
481 addTag(theadTag, tableSectionConstructor);
482 addTag(titleTag, titleConstructor);
483 addTag(trTag, tableRowConstructor);
484 addTag(ulTag, ulConstructor);
485 addTag(xmpTag, preConstructor);
486 #if ENABLE(VIDEO)
487 addTag(audioTag, audioConstructor);
488 addTag(sourceTag, sourceConstructor);
489 addTag(videoTag, videoConstructor);
490 #endif
491 }
492
createHTMLElement(const QualifiedName & tagName,Document * doc,HTMLFormElement * form,bool createdByParser)493 PassRefPtr<HTMLElement> HTMLElementFactory::createHTMLElement(const QualifiedName& tagName, Document* doc, HTMLFormElement* form, bool createdByParser)
494 {
495 if (!doc)
496 return 0; // Don't allow elements to ever be made without having a doc.
497
498 if (!gFunctionMap)
499 createFunctionMap();
500
501 ConstructorFunc func = gFunctionMap->get(tagName.localName().impl());
502 if (func)
503 return func(tagName, doc, form, createdByParser);
504
505 // elements with no special representation in the DOM
506 return new HTMLElement(tagName, doc);
507 }
508
509 }
510
511