| 1 | /* |
| 2 | * THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT EDIT. |
| 3 | * |
| 4 | * This file was generated by the dom/make_names.pl script. |
| 5 | * |
| 6 | * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 21 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 24 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 25 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #include "config.h" |
| 31 | #include "HTMLElementFactory.h" |
| 32 | |
| 33 | #include "HTMLNames.h" |
| 34 | |
| 35 | #include "HTMLAnchorElement.h" |
| 36 | #include "HTMLElement.h" |
| 37 | #include "HTMLAppletElement.h" |
| 38 | #include "HTMLAreaElement.h" |
| 39 | #include "HTMLBaseElement.h" |
| 40 | #include "HTMLBDIElement.h" |
| 41 | #include "HTMLUnknownElement.h" |
| 42 | #include "HTMLQuoteElement.h" |
| 43 | #include "HTMLBodyElement.h" |
| 44 | #include "HTMLBRElement.h" |
| 45 | #include "HTMLButtonElement.h" |
| 46 | #include "HTMLCanvasElement.h" |
| 47 | #include "HTMLTableCaptionElement.h" |
| 48 | #include "HTMLTableColElement.h" |
| 49 | #include "HTMLDataElement.h" |
| 50 | #include "HTMLModElement.h" |
| 51 | #include "HTMLDetailsElement.h" |
| 52 | #include "HTMLDirectoryElement.h" |
| 53 | #include "HTMLDivElement.h" |
| 54 | #include "HTMLDListElement.h" |
| 55 | #include "HTMLEmbedElement.h" |
| 56 | #include "HTMLFieldSetElement.h" |
| 57 | #include "HTMLFontElement.h" |
| 58 | #include "HTMLFormElement.h" |
| 59 | #include "HTMLFrameElement.h" |
| 60 | #include "HTMLFrameSetElement.h" |
| 61 | #include "HTMLHeadingElement.h" |
| 62 | #include "HTMLHeadElement.h" |
| 63 | #include "HTMLHRElement.h" |
| 64 | #include "HTMLHtmlElement.h" |
| 65 | #include "HTMLIFrameElement.h" |
| 66 | #include "HTMLImageElement.h" |
| 67 | #include "HTMLInputElement.h" |
| 68 | #include "HTMLKeygenElement.h" |
| 69 | #include "HTMLLabelElement.h" |
| 70 | #include "HTMLLegendElement.h" |
| 71 | #include "HTMLLIElement.h" |
| 72 | #include "HTMLLinkElement.h" |
| 73 | #include "HTMLPreElement.h" |
| 74 | #include "HTMLMapElement.h" |
| 75 | #include "HTMLMarqueeElement.h" |
| 76 | #include "HTMLMenuElement.h" |
| 77 | #include "HTMLMenuItemElement.h" |
| 78 | #include "HTMLMetaElement.h" |
| 79 | #include "HTMLObjectElement.h" |
| 80 | #include "HTMLOListElement.h" |
| 81 | #include "HTMLOptGroupElement.h" |
| 82 | #include "HTMLOptionElement.h" |
| 83 | #include "HTMLOutputElement.h" |
| 84 | #include "HTMLParagraphElement.h" |
| 85 | #include "HTMLParamElement.h" |
| 86 | #include "HTMLPictureElement.h" |
| 87 | #include "HTMLProgressElement.h" |
| 88 | #include "RubyTextElement.h" |
| 89 | #include "RubyElement.h" |
| 90 | #include "HTMLScriptElement.h" |
| 91 | #include "HTMLSelectElement.h" |
| 92 | #include "HTMLSlotElement.h" |
| 93 | #include "HTMLSourceElement.h" |
| 94 | #include "HTMLSpanElement.h" |
| 95 | #include "HTMLStyleElement.h" |
| 96 | #include "HTMLSummaryElement.h" |
| 97 | #include "HTMLTableElement.h" |
| 98 | #include "HTMLTableSectionElement.h" |
| 99 | #include "HTMLTableCellElement.h" |
| 100 | #include "HTMLTemplateElement.h" |
| 101 | #include "HTMLTextAreaElement.h" |
| 102 | #include "HTMLTimeElement.h" |
| 103 | #include "HTMLTitleElement.h" |
| 104 | #include "HTMLTableRowElement.h" |
| 105 | #include "HTMLUListElement.h" |
| 106 | #include "HTMLWBRElement.h" |
| 107 | #include "HTMLUnknownElement.h" |
| 108 | |
| 109 | #if ENABLE(ATTACHMENT_ELEMENT) |
| 110 | #include "HTMLAttachmentElement.h" |
| 111 | #endif |
| 112 | |
| 113 | #if ENABLE(DATALIST_ELEMENT) |
| 114 | #include "HTMLDataListElement.h" |
| 115 | #endif |
| 116 | |
| 117 | #if ENABLE(METER_ELEMENT) |
| 118 | #include "HTMLMeterElement.h" |
| 119 | #endif |
| 120 | |
| 121 | #if ENABLE(VIDEO) |
| 122 | #include "HTMLAudioElement.h" |
| 123 | #include "HTMLVideoElement.h" |
| 124 | #endif |
| 125 | |
| 126 | #if ENABLE(VIDEO_TRACK) |
| 127 | #include "HTMLTrackElement.h" |
| 128 | #endif |
| 129 | |
| 130 | #include "Document.h" |
| 131 | #include "RuntimeEnabledFeatures.h" |
| 132 | #include "Settings.h" |
| 133 | #include <wtf/HashMap.h> |
| 134 | #include <wtf/NeverDestroyed.h> |
| 135 | |
| 136 | namespace WebCore { |
| 137 | |
| 138 | using namespace HTMLNames; |
| 139 | |
| 140 | typedef Ref<HTMLElement> (*HTMLConstructorFunction)(const QualifiedName&, Document&, HTMLFormElement*, bool createdByParser); |
| 141 | |
| 142 | static Ref<HTMLElement> anchorConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 143 | { |
| 144 | return HTMLAnchorElement::create(tagName, document); |
| 145 | } |
| 146 | |
| 147 | static Ref<HTMLElement> Constructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 148 | { |
| 149 | return HTMLElement::create(tagName, document); |
| 150 | } |
| 151 | |
| 152 | static Ref<HTMLElement> appletConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 153 | { |
| 154 | return HTMLAppletElement::create(tagName, document); |
| 155 | } |
| 156 | |
| 157 | static Ref<HTMLElement> areaConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 158 | { |
| 159 | return HTMLAreaElement::create(tagName, document); |
| 160 | } |
| 161 | |
| 162 | #if ENABLE(ATTACHMENT_ELEMENT) |
| 163 | static Ref<HTMLElement> attachmentConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 164 | { |
| 165 | if (!RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled()) |
| 166 | return HTMLUnknownElement::create(tagName, document); |
| 167 | return HTMLAttachmentElement::create(tagName, document); |
| 168 | } |
| 169 | #endif |
| 170 | |
| 171 | #if ENABLE(VIDEO) |
| 172 | static Ref<HTMLElement> audioConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool createdByParser) |
| 173 | { |
| 174 | if (!document.settings().mediaEnabled()) |
| 175 | return HTMLUnknownElement::create(tagName, document); |
| 176 | |
| 177 | return HTMLAudioElement::create(tagName, document, createdByParser); |
| 178 | } |
| 179 | #endif |
| 180 | |
| 181 | static Ref<HTMLElement> baseConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 182 | { |
| 183 | return HTMLBaseElement::create(tagName, document); |
| 184 | } |
| 185 | |
| 186 | static Ref<HTMLElement> bdiConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 187 | { |
| 188 | return HTMLBDIElement::create(tagName, document); |
| 189 | } |
| 190 | |
| 191 | static Ref<HTMLElement> unknownConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 192 | { |
| 193 | return HTMLUnknownElement::create(tagName, document); |
| 194 | } |
| 195 | |
| 196 | static Ref<HTMLElement> quoteConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 197 | { |
| 198 | return HTMLQuoteElement::create(tagName, document); |
| 199 | } |
| 200 | |
| 201 | static Ref<HTMLElement> bodyConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 202 | { |
| 203 | return HTMLBodyElement::create(tagName, document); |
| 204 | } |
| 205 | |
| 206 | static Ref<HTMLElement> brConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 207 | { |
| 208 | return HTMLBRElement::create(tagName, document); |
| 209 | } |
| 210 | |
| 211 | static Ref<HTMLElement> buttonConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement* formElement, bool) |
| 212 | { |
| 213 | return HTMLButtonElement::create(tagName, document, formElement); |
| 214 | } |
| 215 | |
| 216 | static Ref<HTMLElement> canvasConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 217 | { |
| 218 | return HTMLCanvasElement::create(tagName, document); |
| 219 | } |
| 220 | |
| 221 | static Ref<HTMLElement> tablecaptionConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 222 | { |
| 223 | return HTMLTableCaptionElement::create(tagName, document); |
| 224 | } |
| 225 | |
| 226 | static Ref<HTMLElement> tablecolConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 227 | { |
| 228 | return HTMLTableColElement::create(tagName, document); |
| 229 | } |
| 230 | |
| 231 | static Ref<HTMLElement> dataConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 232 | { |
| 233 | return HTMLDataElement::create(tagName, document); |
| 234 | } |
| 235 | |
| 236 | #if ENABLE(DATALIST_ELEMENT) |
| 237 | static Ref<HTMLElement> datalistConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 238 | { |
| 239 | if (!RuntimeEnabledFeatures::sharedFeatures().dataListElementEnabled()) |
| 240 | return HTMLUnknownElement::create(tagName, document); |
| 241 | return HTMLDataListElement::create(tagName, document); |
| 242 | } |
| 243 | #endif |
| 244 | |
| 245 | static Ref<HTMLElement> modConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 246 | { |
| 247 | return HTMLModElement::create(tagName, document); |
| 248 | } |
| 249 | |
| 250 | static Ref<HTMLElement> detailsConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 251 | { |
| 252 | return HTMLDetailsElement::create(tagName, document); |
| 253 | } |
| 254 | |
| 255 | static Ref<HTMLElement> directoryConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 256 | { |
| 257 | return HTMLDirectoryElement::create(tagName, document); |
| 258 | } |
| 259 | |
| 260 | static Ref<HTMLElement> divConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 261 | { |
| 262 | return HTMLDivElement::create(tagName, document); |
| 263 | } |
| 264 | |
| 265 | static Ref<HTMLElement> dlistConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 266 | { |
| 267 | return HTMLDListElement::create(tagName, document); |
| 268 | } |
| 269 | |
| 270 | static Ref<HTMLElement> embedConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 271 | { |
| 272 | return HTMLEmbedElement::create(tagName, document); |
| 273 | } |
| 274 | |
| 275 | static Ref<HTMLElement> fieldsetConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement* formElement, bool) |
| 276 | { |
| 277 | return HTMLFieldSetElement::create(tagName, document, formElement); |
| 278 | } |
| 279 | |
| 280 | static Ref<HTMLElement> fontConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 281 | { |
| 282 | return HTMLFontElement::create(tagName, document); |
| 283 | } |
| 284 | |
| 285 | static Ref<HTMLElement> formConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 286 | { |
| 287 | return HTMLFormElement::create(tagName, document); |
| 288 | } |
| 289 | |
| 290 | static Ref<HTMLElement> frameConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 291 | { |
| 292 | return HTMLFrameElement::create(tagName, document); |
| 293 | } |
| 294 | |
| 295 | static Ref<HTMLElement> framesetConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 296 | { |
| 297 | return HTMLFrameSetElement::create(tagName, document); |
| 298 | } |
| 299 | |
| 300 | static Ref<HTMLElement> headingConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 301 | { |
| 302 | return HTMLHeadingElement::create(tagName, document); |
| 303 | } |
| 304 | |
| 305 | static Ref<HTMLElement> headConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 306 | { |
| 307 | return HTMLHeadElement::create(tagName, document); |
| 308 | } |
| 309 | |
| 310 | static Ref<HTMLElement> hrConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 311 | { |
| 312 | return HTMLHRElement::create(tagName, document); |
| 313 | } |
| 314 | |
| 315 | static Ref<HTMLElement> htmlConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 316 | { |
| 317 | return HTMLHtmlElement::create(tagName, document); |
| 318 | } |
| 319 | |
| 320 | static Ref<HTMLElement> iframeConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 321 | { |
| 322 | return HTMLIFrameElement::create(tagName, document); |
| 323 | } |
| 324 | |
| 325 | static Ref<HTMLElement> imageConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement* formElement, bool) |
| 326 | { |
| 327 | return HTMLImageElement::create(tagName, document, formElement); |
| 328 | } |
| 329 | |
| 330 | static Ref<HTMLElement> inputConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement* formElement, bool createdByParser) |
| 331 | { |
| 332 | return HTMLInputElement::create(tagName, document, formElement, createdByParser); |
| 333 | } |
| 334 | |
| 335 | static Ref<HTMLElement> keygenConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement* formElement, bool) |
| 336 | { |
| 337 | return HTMLKeygenElement::create(tagName, document, formElement); |
| 338 | } |
| 339 | |
| 340 | static Ref<HTMLElement> labelConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 341 | { |
| 342 | return HTMLLabelElement::create(tagName, document); |
| 343 | } |
| 344 | |
| 345 | static Ref<HTMLElement> legendConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 346 | { |
| 347 | return HTMLLegendElement::create(tagName, document); |
| 348 | } |
| 349 | |
| 350 | static Ref<HTMLElement> liConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 351 | { |
| 352 | return HTMLLIElement::create(tagName, document); |
| 353 | } |
| 354 | |
| 355 | static Ref<HTMLElement> linkConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool createdByParser) |
| 356 | { |
| 357 | return HTMLLinkElement::create(tagName, document, createdByParser); |
| 358 | } |
| 359 | |
| 360 | static Ref<HTMLElement> preConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 361 | { |
| 362 | return HTMLPreElement::create(tagName, document); |
| 363 | } |
| 364 | |
| 365 | static Ref<HTMLElement> mapConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 366 | { |
| 367 | return HTMLMapElement::create(tagName, document); |
| 368 | } |
| 369 | |
| 370 | static Ref<HTMLElement> marqueeConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 371 | { |
| 372 | return HTMLMarqueeElement::create(tagName, document); |
| 373 | } |
| 374 | |
| 375 | static Ref<HTMLElement> (const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 376 | { |
| 377 | return HTMLMenuElement::create(tagName, document); |
| 378 | } |
| 379 | |
| 380 | static Ref<HTMLElement> (const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 381 | { |
| 382 | if (!RuntimeEnabledFeatures::sharedFeatures().menuItemElementEnabled()) |
| 383 | return HTMLUnknownElement::create(tagName, document); |
| 384 | return HTMLMenuItemElement::create(tagName, document); |
| 385 | } |
| 386 | |
| 387 | static Ref<HTMLElement> metaConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 388 | { |
| 389 | return HTMLMetaElement::create(tagName, document); |
| 390 | } |
| 391 | |
| 392 | #if ENABLE(METER_ELEMENT) |
| 393 | static Ref<HTMLElement> meterConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 394 | { |
| 395 | return HTMLMeterElement::create(tagName, document); |
| 396 | } |
| 397 | #endif |
| 398 | |
| 399 | static Ref<HTMLElement> objectConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement* formElement, bool) |
| 400 | { |
| 401 | return HTMLObjectElement::create(tagName, document, formElement); |
| 402 | } |
| 403 | |
| 404 | static Ref<HTMLElement> olistConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 405 | { |
| 406 | return HTMLOListElement::create(tagName, document); |
| 407 | } |
| 408 | |
| 409 | static Ref<HTMLElement> optgroupConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 410 | { |
| 411 | return HTMLOptGroupElement::create(tagName, document); |
| 412 | } |
| 413 | |
| 414 | static Ref<HTMLElement> optionConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 415 | { |
| 416 | return HTMLOptionElement::create(tagName, document); |
| 417 | } |
| 418 | |
| 419 | static Ref<HTMLElement> outputConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement* formElement, bool) |
| 420 | { |
| 421 | return HTMLOutputElement::create(tagName, document, formElement); |
| 422 | } |
| 423 | |
| 424 | static Ref<HTMLElement> paragraphConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 425 | { |
| 426 | return HTMLParagraphElement::create(tagName, document); |
| 427 | } |
| 428 | |
| 429 | static Ref<HTMLElement> paramConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 430 | { |
| 431 | return HTMLParamElement::create(tagName, document); |
| 432 | } |
| 433 | |
| 434 | static Ref<HTMLElement> pictureConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 435 | { |
| 436 | return HTMLPictureElement::create(tagName, document); |
| 437 | } |
| 438 | |
| 439 | static Ref<HTMLElement> progressConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 440 | { |
| 441 | return HTMLProgressElement::create(tagName, document); |
| 442 | } |
| 443 | |
| 444 | static Ref<HTMLElement> rubytextelementConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 445 | { |
| 446 | return RubyTextElement::create(tagName, document); |
| 447 | } |
| 448 | |
| 449 | static Ref<HTMLElement> rubyelementConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 450 | { |
| 451 | return RubyElement::create(tagName, document); |
| 452 | } |
| 453 | |
| 454 | static Ref<HTMLElement> scriptConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool createdByParser) |
| 455 | { |
| 456 | return HTMLScriptElement::create(tagName, document, createdByParser); |
| 457 | } |
| 458 | |
| 459 | static Ref<HTMLElement> selectConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement* formElement, bool) |
| 460 | { |
| 461 | return HTMLSelectElement::create(tagName, document, formElement); |
| 462 | } |
| 463 | |
| 464 | static Ref<HTMLElement> slotConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 465 | { |
| 466 | return HTMLSlotElement::create(tagName, document); |
| 467 | } |
| 468 | |
| 469 | static Ref<HTMLElement> sourceConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 470 | { |
| 471 | return HTMLSourceElement::create(tagName, document); |
| 472 | } |
| 473 | |
| 474 | static Ref<HTMLElement> spanConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 475 | { |
| 476 | return HTMLSpanElement::create(tagName, document); |
| 477 | } |
| 478 | |
| 479 | static Ref<HTMLElement> styleConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool createdByParser) |
| 480 | { |
| 481 | return HTMLStyleElement::create(tagName, document, createdByParser); |
| 482 | } |
| 483 | |
| 484 | static Ref<HTMLElement> summaryConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 485 | { |
| 486 | return HTMLSummaryElement::create(tagName, document); |
| 487 | } |
| 488 | |
| 489 | static Ref<HTMLElement> tableConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 490 | { |
| 491 | return HTMLTableElement::create(tagName, document); |
| 492 | } |
| 493 | |
| 494 | static Ref<HTMLElement> tablesectionConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 495 | { |
| 496 | return HTMLTableSectionElement::create(tagName, document); |
| 497 | } |
| 498 | |
| 499 | static Ref<HTMLElement> tablecellConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 500 | { |
| 501 | return HTMLTableCellElement::create(tagName, document); |
| 502 | } |
| 503 | |
| 504 | static Ref<HTMLElement> templateConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 505 | { |
| 506 | return HTMLTemplateElement::create(tagName, document); |
| 507 | } |
| 508 | |
| 509 | static Ref<HTMLElement> textareaConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement* formElement, bool) |
| 510 | { |
| 511 | return HTMLTextAreaElement::create(tagName, document, formElement); |
| 512 | } |
| 513 | |
| 514 | static Ref<HTMLElement> timeConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 515 | { |
| 516 | return HTMLTimeElement::create(tagName, document); |
| 517 | } |
| 518 | |
| 519 | static Ref<HTMLElement> titleConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 520 | { |
| 521 | return HTMLTitleElement::create(tagName, document); |
| 522 | } |
| 523 | |
| 524 | static Ref<HTMLElement> tablerowConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 525 | { |
| 526 | return HTMLTableRowElement::create(tagName, document); |
| 527 | } |
| 528 | |
| 529 | #if ENABLE(VIDEO_TRACK) |
| 530 | static Ref<HTMLElement> trackConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 531 | { |
| 532 | if (!document.settings().mediaEnabled()) |
| 533 | return HTMLUnknownElement::create(tagName, document); |
| 534 | |
| 535 | return HTMLTrackElement::create(tagName, document); |
| 536 | } |
| 537 | #endif |
| 538 | |
| 539 | static Ref<HTMLElement> ulistConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 540 | { |
| 541 | return HTMLUListElement::create(tagName, document); |
| 542 | } |
| 543 | |
| 544 | #if ENABLE(VIDEO) |
| 545 | static Ref<HTMLElement> videoConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool createdByParser) |
| 546 | { |
| 547 | if (!document.settings().mediaEnabled()) |
| 548 | return HTMLUnknownElement::create(tagName, document); |
| 549 | |
| 550 | return HTMLVideoElement::create(tagName, document, createdByParser); |
| 551 | } |
| 552 | #endif |
| 553 | |
| 554 | static Ref<HTMLElement> wbrConstructor(const QualifiedName& tagName, Document& document, HTMLFormElement*, bool) |
| 555 | { |
| 556 | return HTMLWBRElement::create(tagName, document); |
| 557 | } |
| 558 | |
| 559 | |
| 560 | struct HTMLConstructorFunctionMapEntry { |
| 561 | HTMLConstructorFunctionMapEntry(HTMLConstructorFunction function, const QualifiedName& name) |
| 562 | : function(function) |
| 563 | , qualifiedName(&name) |
| 564 | { } |
| 565 | |
| 566 | HTMLConstructorFunctionMapEntry() |
| 567 | : function(nullptr) |
| 568 | , qualifiedName(nullptr) |
| 569 | { } |
| 570 | |
| 571 | HTMLConstructorFunction function; |
| 572 | const QualifiedName* qualifiedName; // Use pointer instead of reference so that emptyValue() in HashMap is cheap to create. |
| 573 | }; |
| 574 | |
| 575 | static NEVER_INLINE HashMap<AtomicStringImpl*, HTMLConstructorFunctionMapEntry> createHTMLFactoryMap() |
| 576 | { |
| 577 | struct TableEntry { |
| 578 | const QualifiedName& name; |
| 579 | HTMLConstructorFunction function; |
| 580 | }; |
| 581 | |
| 582 | static const TableEntry table[] = { |
| 583 | { aTag, anchorConstructor }, |
| 584 | { abbrTag, Constructor }, |
| 585 | { acronymTag, Constructor }, |
| 586 | { addressTag, Constructor }, |
| 587 | { appletTag, appletConstructor }, |
| 588 | { areaTag, areaConstructor }, |
| 589 | { articleTag, Constructor }, |
| 590 | { asideTag, Constructor }, |
| 591 | #if ENABLE(ATTACHMENT_ELEMENT) |
| 592 | { attachmentTag, attachmentConstructor }, |
| 593 | #endif |
| 594 | #if ENABLE(VIDEO) |
| 595 | { audioTag, audioConstructor }, |
| 596 | #endif |
| 597 | { bTag, Constructor }, |
| 598 | { baseTag, baseConstructor }, |
| 599 | { basefontTag, Constructor }, |
| 600 | { bdiTag, bdiConstructor }, |
| 601 | { bdoTag, Constructor }, |
| 602 | { bgsoundTag, unknownConstructor }, |
| 603 | { bigTag, Constructor }, |
| 604 | { blockquoteTag, quoteConstructor }, |
| 605 | { bodyTag, bodyConstructor }, |
| 606 | { brTag, brConstructor }, |
| 607 | { buttonTag, buttonConstructor }, |
| 608 | { canvasTag, canvasConstructor }, |
| 609 | { captionTag, tablecaptionConstructor }, |
| 610 | { centerTag, Constructor }, |
| 611 | { citeTag, Constructor }, |
| 612 | { codeTag, Constructor }, |
| 613 | { colTag, tablecolConstructor }, |
| 614 | { colgroupTag, tablecolConstructor }, |
| 615 | { commandTag, unknownConstructor }, |
| 616 | { dataTag, dataConstructor }, |
| 617 | #if ENABLE(DATALIST_ELEMENT) |
| 618 | { datalistTag, datalistConstructor }, |
| 619 | #endif |
| 620 | { ddTag, Constructor }, |
| 621 | { delTag, modConstructor }, |
| 622 | { detailsTag, detailsConstructor }, |
| 623 | { dfnTag, Constructor }, |
| 624 | { dirTag, directoryConstructor }, |
| 625 | { divTag, divConstructor }, |
| 626 | { dlTag, dlistConstructor }, |
| 627 | { dtTag, Constructor }, |
| 628 | { emTag, Constructor }, |
| 629 | { embedTag, embedConstructor }, |
| 630 | { fieldsetTag, fieldsetConstructor }, |
| 631 | { figcaptionTag, Constructor }, |
| 632 | { figureTag, Constructor }, |
| 633 | { fontTag, fontConstructor }, |
| 634 | { footerTag, Constructor }, |
| 635 | { formTag, formConstructor }, |
| 636 | { frameTag, frameConstructor }, |
| 637 | { framesetTag, framesetConstructor }, |
| 638 | { h1Tag, headingConstructor }, |
| 639 | { h2Tag, headingConstructor }, |
| 640 | { h3Tag, headingConstructor }, |
| 641 | { h4Tag, headingConstructor }, |
| 642 | { h5Tag, headingConstructor }, |
| 643 | { h6Tag, headingConstructor }, |
| 644 | { headTag, headConstructor }, |
| 645 | { headerTag, Constructor }, |
| 646 | { hgroupTag, Constructor }, |
| 647 | { hrTag, hrConstructor }, |
| 648 | { htmlTag, htmlConstructor }, |
| 649 | { iTag, Constructor }, |
| 650 | { iframeTag, iframeConstructor }, |
| 651 | { imageTag, unknownConstructor }, |
| 652 | { imgTag, imageConstructor }, |
| 653 | { inputTag, inputConstructor }, |
| 654 | { insTag, modConstructor }, |
| 655 | { kbdTag, Constructor }, |
| 656 | { keygenTag, keygenConstructor }, |
| 657 | { labelTag, labelConstructor }, |
| 658 | { layerTag, Constructor }, |
| 659 | { legendTag, legendConstructor }, |
| 660 | { liTag, liConstructor }, |
| 661 | { linkTag, linkConstructor }, |
| 662 | { listingTag, preConstructor }, |
| 663 | { mainTag, Constructor }, |
| 664 | { mapTag, mapConstructor }, |
| 665 | { markTag, Constructor }, |
| 666 | { marqueeTag, marqueeConstructor }, |
| 667 | { menuTag, menuConstructor }, |
| 668 | { menuitemTag, menuitemConstructor }, |
| 669 | { metaTag, metaConstructor }, |
| 670 | #if ENABLE(METER_ELEMENT) |
| 671 | { meterTag, meterConstructor }, |
| 672 | #endif |
| 673 | { navTag, Constructor }, |
| 674 | { nobrTag, Constructor }, |
| 675 | { noembedTag, Constructor }, |
| 676 | { noframesTag, Constructor }, |
| 677 | { nolayerTag, Constructor }, |
| 678 | { noscriptTag, Constructor }, |
| 679 | { objectTag, objectConstructor }, |
| 680 | { olTag, olistConstructor }, |
| 681 | { optgroupTag, optgroupConstructor }, |
| 682 | { optionTag, optionConstructor }, |
| 683 | { outputTag, outputConstructor }, |
| 684 | { pTag, paragraphConstructor }, |
| 685 | { paramTag, paramConstructor }, |
| 686 | { pictureTag, pictureConstructor }, |
| 687 | { plaintextTag, Constructor }, |
| 688 | { preTag, preConstructor }, |
| 689 | { progressTag, progressConstructor }, |
| 690 | { qTag, quoteConstructor }, |
| 691 | { rbTag, Constructor }, |
| 692 | { rpTag, Constructor }, |
| 693 | { rtTag, rubytextelementConstructor }, |
| 694 | { rtcTag, Constructor }, |
| 695 | { rubyTag, rubyelementConstructor }, |
| 696 | { sTag, Constructor }, |
| 697 | { sampTag, Constructor }, |
| 698 | { scriptTag, scriptConstructor }, |
| 699 | { sectionTag, Constructor }, |
| 700 | { selectTag, selectConstructor }, |
| 701 | { slotTag, slotConstructor }, |
| 702 | { smallTag, Constructor }, |
| 703 | { sourceTag, sourceConstructor }, |
| 704 | { spanTag, spanConstructor }, |
| 705 | { strikeTag, Constructor }, |
| 706 | { strongTag, Constructor }, |
| 707 | { styleTag, styleConstructor }, |
| 708 | { subTag, Constructor }, |
| 709 | { summaryTag, summaryConstructor }, |
| 710 | { supTag, Constructor }, |
| 711 | { tableTag, tableConstructor }, |
| 712 | { tbodyTag, tablesectionConstructor }, |
| 713 | { tdTag, tablecellConstructor }, |
| 714 | { templateTag, templateConstructor }, |
| 715 | { textareaTag, textareaConstructor }, |
| 716 | { tfootTag, tablesectionConstructor }, |
| 717 | { thTag, tablecellConstructor }, |
| 718 | { theadTag, tablesectionConstructor }, |
| 719 | { timeTag, timeConstructor }, |
| 720 | { titleTag, titleConstructor }, |
| 721 | { trTag, tablerowConstructor }, |
| 722 | #if ENABLE(VIDEO_TRACK) |
| 723 | { trackTag, trackConstructor }, |
| 724 | #endif |
| 725 | { ttTag, Constructor }, |
| 726 | { uTag, Constructor }, |
| 727 | { ulTag, ulistConstructor }, |
| 728 | { varTag, Constructor }, |
| 729 | #if ENABLE(VIDEO) |
| 730 | { videoTag, videoConstructor }, |
| 731 | #endif |
| 732 | { wbrTag, wbrConstructor }, |
| 733 | { xmpTag, preConstructor }, |
| 734 | }; |
| 735 | |
| 736 | HashMap<AtomicStringImpl*, HTMLConstructorFunctionMapEntry> map; |
| 737 | for (auto& entry : table) |
| 738 | map.add(entry.name.localName().impl(), HTMLConstructorFunctionMapEntry(entry.function, entry.name)); |
| 739 | return map; |
| 740 | } |
| 741 | |
| 742 | static HTMLConstructorFunctionMapEntry findHTMLElementConstructorFunction(const AtomicString& localName) |
| 743 | { |
| 744 | static const auto map = makeNeverDestroyed(createHTMLFactoryMap()); |
| 745 | return map.get().get(localName.impl()); |
| 746 | } |
| 747 | |
| 748 | RefPtr<HTMLElement> HTMLElementFactory::createKnownElement(const AtomicString& localName, Document& document, HTMLFormElement* formElement, bool createdByParser) |
| 749 | { |
| 750 | const HTMLConstructorFunctionMapEntry& entry = findHTMLElementConstructorFunction(localName); |
| 751 | if (LIKELY(entry.function)) { |
| 752 | ASSERT(entry.qualifiedName); |
| 753 | const auto& name = *entry.qualifiedName; |
| 754 | return entry.function(name, document, formElement, createdByParser); |
| 755 | } |
| 756 | return nullptr; |
| 757 | } |
| 758 | |
| 759 | RefPtr<HTMLElement> HTMLElementFactory::createKnownElement(const QualifiedName& name, Document& document, HTMLFormElement* formElement, bool createdByParser) |
| 760 | { |
| 761 | const HTMLConstructorFunctionMapEntry& entry = findHTMLElementConstructorFunction(name.localName()); |
| 762 | if (LIKELY(entry.function)) |
| 763 | return entry.function(name, document, formElement, createdByParser); |
| 764 | return nullptr; |
| 765 | } |
| 766 | |
| 767 | Ref<HTMLElement> HTMLElementFactory::createElement(const AtomicString& localName, Document& document, HTMLFormElement* formElement, bool createdByParser) |
| 768 | { |
| 769 | const HTMLConstructorFunctionMapEntry& entry = findHTMLElementConstructorFunction(localName); |
| 770 | if (LIKELY(entry.function)) { |
| 771 | ASSERT(entry.qualifiedName); |
| 772 | const auto& name = *entry.qualifiedName; |
| 773 | return entry.function(name, document, formElement, createdByParser); |
| 774 | } |
| 775 | return HTMLUnknownElement::create(QualifiedName(nullAtom(), localName, xhtmlNamespaceURI), document); |
| 776 | } |
| 777 | |
| 778 | Ref<HTMLElement> HTMLElementFactory::createElement(const QualifiedName& name, Document& document, HTMLFormElement* formElement, bool createdByParser) |
| 779 | { |
| 780 | const HTMLConstructorFunctionMapEntry& entry = findHTMLElementConstructorFunction(name.localName()); |
| 781 | if (LIKELY(entry.function)) |
| 782 | return entry.function(name, document, formElement, createdByParser); |
| 783 | return HTMLUnknownElement::create(name, document); |
| 784 | } |
| 785 | |
| 786 | } // namespace WebCore |
| 787 | |
| 788 | |