ElementFactory.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. /*
  2. * Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2020, Luke Wilde <lukew@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #include <LibWeb/DOM/Document.h>
  8. #include <LibWeb/DOM/ElementFactory.h>
  9. #include <LibWeb/HTML/HTMLAnchorElement.h>
  10. #include <LibWeb/HTML/HTMLAreaElement.h>
  11. #include <LibWeb/HTML/HTMLAudioElement.h>
  12. #include <LibWeb/HTML/HTMLBRElement.h>
  13. #include <LibWeb/HTML/HTMLBaseElement.h>
  14. #include <LibWeb/HTML/HTMLBlinkElement.h>
  15. #include <LibWeb/HTML/HTMLBodyElement.h>
  16. #include <LibWeb/HTML/HTMLButtonElement.h>
  17. #include <LibWeb/HTML/HTMLCanvasElement.h>
  18. #include <LibWeb/HTML/HTMLDListElement.h>
  19. #include <LibWeb/HTML/HTMLDataElement.h>
  20. #include <LibWeb/HTML/HTMLDataListElement.h>
  21. #include <LibWeb/HTML/HTMLDetailsElement.h>
  22. #include <LibWeb/HTML/HTMLDialogElement.h>
  23. #include <LibWeb/HTML/HTMLDirectoryElement.h>
  24. #include <LibWeb/HTML/HTMLDivElement.h>
  25. #include <LibWeb/HTML/HTMLEmbedElement.h>
  26. #include <LibWeb/HTML/HTMLFieldSetElement.h>
  27. #include <LibWeb/HTML/HTMLFontElement.h>
  28. #include <LibWeb/HTML/HTMLFormElement.h>
  29. #include <LibWeb/HTML/HTMLFrameElement.h>
  30. #include <LibWeb/HTML/HTMLFrameSetElement.h>
  31. #include <LibWeb/HTML/HTMLHRElement.h>
  32. #include <LibWeb/HTML/HTMLHeadElement.h>
  33. #include <LibWeb/HTML/HTMLHeadingElement.h>
  34. #include <LibWeb/HTML/HTMLHtmlElement.h>
  35. #include <LibWeb/HTML/HTMLIFrameElement.h>
  36. #include <LibWeb/HTML/HTMLImageElement.h>
  37. #include <LibWeb/HTML/HTMLInputElement.h>
  38. #include <LibWeb/HTML/HTMLLIElement.h>
  39. #include <LibWeb/HTML/HTMLLabelElement.h>
  40. #include <LibWeb/HTML/HTMLLegendElement.h>
  41. #include <LibWeb/HTML/HTMLLinkElement.h>
  42. #include <LibWeb/HTML/HTMLMapElement.h>
  43. #include <LibWeb/HTML/HTMLMarqueeElement.h>
  44. #include <LibWeb/HTML/HTMLMenuElement.h>
  45. #include <LibWeb/HTML/HTMLMetaElement.h>
  46. #include <LibWeb/HTML/HTMLMeterElement.h>
  47. #include <LibWeb/HTML/HTMLModElement.h>
  48. #include <LibWeb/HTML/HTMLOListElement.h>
  49. #include <LibWeb/HTML/HTMLObjectElement.h>
  50. #include <LibWeb/HTML/HTMLOptGroupElement.h>
  51. #include <LibWeb/HTML/HTMLOptionElement.h>
  52. #include <LibWeb/HTML/HTMLOutputElement.h>
  53. #include <LibWeb/HTML/HTMLParagraphElement.h>
  54. #include <LibWeb/HTML/HTMLParamElement.h>
  55. #include <LibWeb/HTML/HTMLPictureElement.h>
  56. #include <LibWeb/HTML/HTMLPreElement.h>
  57. #include <LibWeb/HTML/HTMLProgressElement.h>
  58. #include <LibWeb/HTML/HTMLQuoteElement.h>
  59. #include <LibWeb/HTML/HTMLScriptElement.h>
  60. #include <LibWeb/HTML/HTMLSelectElement.h>
  61. #include <LibWeb/HTML/HTMLSlotElement.h>
  62. #include <LibWeb/HTML/HTMLSourceElement.h>
  63. #include <LibWeb/HTML/HTMLSpanElement.h>
  64. #include <LibWeb/HTML/HTMLStyleElement.h>
  65. #include <LibWeb/HTML/HTMLTableCaptionElement.h>
  66. #include <LibWeb/HTML/HTMLTableCellElement.h>
  67. #include <LibWeb/HTML/HTMLTableColElement.h>
  68. #include <LibWeb/HTML/HTMLTableElement.h>
  69. #include <LibWeb/HTML/HTMLTableRowElement.h>
  70. #include <LibWeb/HTML/HTMLTableSectionElement.h>
  71. #include <LibWeb/HTML/HTMLTemplateElement.h>
  72. #include <LibWeb/HTML/HTMLTextAreaElement.h>
  73. #include <LibWeb/HTML/HTMLTimeElement.h>
  74. #include <LibWeb/HTML/HTMLTitleElement.h>
  75. #include <LibWeb/HTML/HTMLTrackElement.h>
  76. #include <LibWeb/HTML/HTMLUListElement.h>
  77. #include <LibWeb/HTML/HTMLUnknownElement.h>
  78. #include <LibWeb/HTML/HTMLVideoElement.h>
  79. #include <LibWeb/SVG/SVGCircleElement.h>
  80. #include <LibWeb/SVG/SVGClipPathElement.h>
  81. #include <LibWeb/SVG/SVGDefsElement.h>
  82. #include <LibWeb/SVG/SVGEllipseElement.h>
  83. #include <LibWeb/SVG/SVGForeignObjectElement.h>
  84. #include <LibWeb/SVG/SVGGElement.h>
  85. #include <LibWeb/SVG/SVGLineElement.h>
  86. #include <LibWeb/SVG/SVGPathElement.h>
  87. #include <LibWeb/SVG/SVGPolygonElement.h>
  88. #include <LibWeb/SVG/SVGPolylineElement.h>
  89. #include <LibWeb/SVG/SVGRectElement.h>
  90. #include <LibWeb/SVG/SVGSVGElement.h>
  91. #include <LibWeb/SVG/SVGTextContentElement.h>
  92. #include <LibWeb/SVG/TagNames.h>
  93. namespace Web::DOM {
  94. // https://dom.spec.whatwg.org/#concept-create-element
  95. WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(Document& document, DeprecatedFlyString local_name, DeprecatedFlyString namespace_, DeprecatedFlyString prefix)
  96. {
  97. // 1. If prefix was not given, let prefix be null.
  98. // NOTE: This is already taken care of by `prefix` having a default value.
  99. // FIXME: 2. If is was not given, let is be null.
  100. // FIXME: 3. Let result be null.
  101. // FIXME: 4. Let definition be the result of looking up a custom element definition given document, namespace, localName, and is.
  102. // FIXME: 5. If definition is non-null, and definition’s name is not equal to its local name (i.e., definition represents a customized built-in element), then: ...
  103. // FIXME: 6. Otherwise, if definition is non-null, then: ...
  104. // 7. Otherwise:
  105. // 1. Let interface be the element interface for localName and namespace.
  106. // 2. Set result to a new element that implements interface, with no attributes, namespace set to namespace, namespace prefix set to prefix,
  107. // local name set to localName, custom element state set to "uncustomized", custom element definition set to null, is value set to is,
  108. // and node document set to document.
  109. // FIXME: 3. If namespace is the HTML namespace, and either localName is a valid custom element name or is is non-null,
  110. // then set result’s custom element state to "undefined".
  111. // 8. Return result.
  112. auto& realm = document.realm();
  113. auto lowercase_tag_name = local_name.to_lowercase();
  114. auto qualified_name = QualifiedName { local_name, prefix, namespace_ };
  115. if (lowercase_tag_name == HTML::TagNames::a)
  116. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLAnchorElement>(realm, document, move(qualified_name)));
  117. if (lowercase_tag_name == HTML::TagNames::area)
  118. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLAreaElement>(realm, document, move(qualified_name)));
  119. if (lowercase_tag_name == HTML::TagNames::audio)
  120. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLAudioElement>(realm, document, move(qualified_name)));
  121. if (lowercase_tag_name == HTML::TagNames::base)
  122. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLBaseElement>(realm, document, move(qualified_name)));
  123. if (lowercase_tag_name == HTML::TagNames::blink)
  124. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLBlinkElement>(realm, document, move(qualified_name)));
  125. if (lowercase_tag_name == HTML::TagNames::body)
  126. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLBodyElement>(realm, document, move(qualified_name)));
  127. if (lowercase_tag_name == HTML::TagNames::br)
  128. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLBRElement>(realm, document, move(qualified_name)));
  129. if (lowercase_tag_name == HTML::TagNames::button)
  130. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLButtonElement>(realm, document, move(qualified_name)));
  131. if (lowercase_tag_name == HTML::TagNames::canvas)
  132. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLCanvasElement>(realm, document, move(qualified_name)));
  133. if (lowercase_tag_name == HTML::TagNames::data)
  134. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLDataElement>(realm, document, move(qualified_name)));
  135. if (lowercase_tag_name == HTML::TagNames::datalist)
  136. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLDataListElement>(realm, document, move(qualified_name)));
  137. if (lowercase_tag_name == HTML::TagNames::details)
  138. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLDetailsElement>(realm, document, move(qualified_name)));
  139. if (lowercase_tag_name == HTML::TagNames::dialog)
  140. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLDialogElement>(realm, document, move(qualified_name)));
  141. if (lowercase_tag_name == HTML::TagNames::dir)
  142. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLDirectoryElement>(realm, document, move(qualified_name)));
  143. if (lowercase_tag_name == HTML::TagNames::div)
  144. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLDivElement>(realm, document, move(qualified_name)));
  145. if (lowercase_tag_name == HTML::TagNames::dl)
  146. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLDListElement>(realm, document, move(qualified_name)));
  147. if (lowercase_tag_name == HTML::TagNames::embed)
  148. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLEmbedElement>(realm, document, move(qualified_name)));
  149. if (lowercase_tag_name == HTML::TagNames::fieldset)
  150. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLFieldSetElement>(realm, document, move(qualified_name)));
  151. if (lowercase_tag_name == HTML::TagNames::font)
  152. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLFontElement>(realm, document, move(qualified_name)));
  153. if (lowercase_tag_name == HTML::TagNames::form)
  154. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLFormElement>(realm, document, move(qualified_name)));
  155. if (lowercase_tag_name == HTML::TagNames::frame)
  156. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLFrameElement>(realm, document, move(qualified_name)));
  157. if (lowercase_tag_name == HTML::TagNames::frameset)
  158. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLFrameSetElement>(realm, document, move(qualified_name)));
  159. if (lowercase_tag_name == HTML::TagNames::head)
  160. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLHeadElement>(realm, document, move(qualified_name)));
  161. if (lowercase_tag_name.is_one_of(HTML::TagNames::h1, HTML::TagNames::h2, HTML::TagNames::h3, HTML::TagNames::h4, HTML::TagNames::h5, HTML::TagNames::h6))
  162. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLHeadingElement>(realm, document, move(qualified_name)));
  163. if (lowercase_tag_name == HTML::TagNames::hr)
  164. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLHRElement>(realm, document, move(qualified_name)));
  165. if (lowercase_tag_name == HTML::TagNames::html)
  166. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLHtmlElement>(realm, document, move(qualified_name)));
  167. if (lowercase_tag_name == HTML::TagNames::iframe)
  168. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLIFrameElement>(realm, document, move(qualified_name)));
  169. if (lowercase_tag_name == HTML::TagNames::img)
  170. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLImageElement>(realm, document, move(qualified_name)));
  171. if (lowercase_tag_name == HTML::TagNames::input)
  172. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLInputElement>(realm, document, move(qualified_name)));
  173. if (lowercase_tag_name == HTML::TagNames::label)
  174. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLLabelElement>(realm, document, move(qualified_name)));
  175. if (lowercase_tag_name == HTML::TagNames::legend)
  176. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLLegendElement>(realm, document, move(qualified_name)));
  177. if (lowercase_tag_name == HTML::TagNames::li)
  178. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLLIElement>(realm, document, move(qualified_name)));
  179. if (lowercase_tag_name == HTML::TagNames::link)
  180. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLLinkElement>(realm, document, move(qualified_name)));
  181. if (lowercase_tag_name == HTML::TagNames::map)
  182. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLMapElement>(realm, document, move(qualified_name)));
  183. if (lowercase_tag_name == HTML::TagNames::marquee)
  184. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLMarqueeElement>(realm, document, move(qualified_name)));
  185. if (lowercase_tag_name == HTML::TagNames::menu)
  186. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLMenuElement>(realm, document, move(qualified_name)));
  187. if (lowercase_tag_name == HTML::TagNames::meta)
  188. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLMetaElement>(realm, document, move(qualified_name)));
  189. if (lowercase_tag_name == HTML::TagNames::meter)
  190. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLMeterElement>(realm, document, move(qualified_name)));
  191. if (lowercase_tag_name.is_one_of(HTML::TagNames::ins, HTML::TagNames::del))
  192. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLModElement>(realm, document, move(qualified_name)));
  193. if (lowercase_tag_name == HTML::TagNames::object)
  194. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLObjectElement>(realm, document, move(qualified_name)));
  195. if (lowercase_tag_name == HTML::TagNames::ol)
  196. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLOListElement>(realm, document, move(qualified_name)));
  197. if (lowercase_tag_name == HTML::TagNames::optgroup)
  198. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLOptGroupElement>(realm, document, move(qualified_name)));
  199. if (lowercase_tag_name == HTML::TagNames::option)
  200. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLOptionElement>(realm, document, move(qualified_name)));
  201. if (lowercase_tag_name == HTML::TagNames::output)
  202. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLOutputElement>(realm, document, move(qualified_name)));
  203. if (lowercase_tag_name == HTML::TagNames::p)
  204. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLParagraphElement>(realm, document, move(qualified_name)));
  205. if (lowercase_tag_name == HTML::TagNames::param)
  206. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLParamElement>(realm, document, move(qualified_name)));
  207. if (lowercase_tag_name == HTML::TagNames::picture)
  208. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLPictureElement>(realm, document, move(qualified_name)));
  209. // NOTE: The obsolete elements "listing" and "xmp" are explicitly mapped to HTMLPreElement in the specification.
  210. if (lowercase_tag_name.is_one_of(HTML::TagNames::pre, HTML::TagNames::listing, HTML::TagNames::xmp))
  211. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLPreElement>(realm, document, move(qualified_name)));
  212. if (lowercase_tag_name == HTML::TagNames::progress)
  213. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLProgressElement>(realm, document, move(qualified_name)));
  214. if (lowercase_tag_name.is_one_of(HTML::TagNames::blockquote, HTML::TagNames::q))
  215. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLQuoteElement>(realm, document, move(qualified_name)));
  216. if (lowercase_tag_name == HTML::TagNames::script)
  217. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLScriptElement>(realm, document, move(qualified_name)));
  218. if (lowercase_tag_name == HTML::TagNames::select)
  219. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLSelectElement>(realm, document, move(qualified_name)));
  220. if (lowercase_tag_name == HTML::TagNames::slot)
  221. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLSlotElement>(realm, document, move(qualified_name)));
  222. if (lowercase_tag_name == HTML::TagNames::source)
  223. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLSourceElement>(realm, document, move(qualified_name)));
  224. if (lowercase_tag_name == HTML::TagNames::span)
  225. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLSpanElement>(realm, document, move(qualified_name)));
  226. if (lowercase_tag_name == HTML::TagNames::style)
  227. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLStyleElement>(realm, document, move(qualified_name)));
  228. if (lowercase_tag_name == HTML::TagNames::caption)
  229. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTableCaptionElement>(realm, document, move(qualified_name)));
  230. if (lowercase_tag_name.is_one_of(Web::HTML::TagNames::td, Web::HTML::TagNames::th))
  231. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTableCellElement>(realm, document, move(qualified_name)));
  232. if (lowercase_tag_name.is_one_of(HTML::TagNames::colgroup, HTML::TagNames::col))
  233. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTableColElement>(realm, document, move(qualified_name)));
  234. if (lowercase_tag_name == HTML::TagNames::table)
  235. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTableElement>(realm, document, move(qualified_name)));
  236. if (lowercase_tag_name == HTML::TagNames::tr)
  237. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTableRowElement>(realm, document, move(qualified_name)));
  238. if (lowercase_tag_name.is_one_of(HTML::TagNames::tbody, HTML::TagNames::thead, HTML::TagNames::tfoot))
  239. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTableSectionElement>(realm, document, move(qualified_name)));
  240. if (lowercase_tag_name == HTML::TagNames::template_)
  241. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTemplateElement>(realm, document, move(qualified_name)));
  242. if (lowercase_tag_name == HTML::TagNames::textarea)
  243. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTextAreaElement>(realm, document, move(qualified_name)));
  244. if (lowercase_tag_name == HTML::TagNames::time)
  245. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTimeElement>(realm, document, move(qualified_name)));
  246. if (lowercase_tag_name == HTML::TagNames::title)
  247. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTitleElement>(realm, document, move(qualified_name)));
  248. if (lowercase_tag_name == HTML::TagNames::track)
  249. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTrackElement>(realm, document, move(qualified_name)));
  250. if (lowercase_tag_name == HTML::TagNames::ul)
  251. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLUListElement>(realm, document, move(qualified_name)));
  252. if (lowercase_tag_name == HTML::TagNames::video)
  253. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLVideoElement>(realm, document, move(qualified_name)));
  254. if (lowercase_tag_name.is_one_of(
  255. HTML::TagNames::article, HTML::TagNames::section, HTML::TagNames::nav, HTML::TagNames::aside, HTML::TagNames::hgroup, HTML::TagNames::header, HTML::TagNames::footer, HTML::TagNames::address, HTML::TagNames::dt, HTML::TagNames::dd, HTML::TagNames::figure, HTML::TagNames::figcaption, HTML::TagNames::main, HTML::TagNames::em, HTML::TagNames::strong, HTML::TagNames::small, HTML::TagNames::s, HTML::TagNames::cite, HTML::TagNames::dfn, HTML::TagNames::abbr, HTML::TagNames::ruby, HTML::TagNames::rt, HTML::TagNames::rp, HTML::TagNames::code, HTML::TagNames::var, HTML::TagNames::samp, HTML::TagNames::kbd, HTML::TagNames::sub, HTML::TagNames::sup, HTML::TagNames::i, HTML::TagNames::b, HTML::TagNames::u, HTML::TagNames::mark, HTML::TagNames::bdi, HTML::TagNames::bdo, HTML::TagNames::wbr, HTML::TagNames::summary, HTML::TagNames::noscript,
  256. // Obsolete
  257. HTML::TagNames::acronym, HTML::TagNames::basefont, HTML::TagNames::big, HTML::TagNames::center, HTML::TagNames::nobr, HTML::TagNames::noembed, HTML::TagNames::noframes, HTML::TagNames::plaintext, HTML::TagNames::rb, HTML::TagNames::rtc, HTML::TagNames::strike, HTML::TagNames::tt))
  258. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLElement>(realm, document, move(qualified_name)));
  259. if (lowercase_tag_name == SVG::TagNames::svg)
  260. return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGSVGElement>(realm, document, move(qualified_name)));
  261. // FIXME: Support SVG's mixedCase tag names properly.
  262. if (lowercase_tag_name.equals_ignoring_ascii_case(SVG::TagNames::clipPath))
  263. return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGClipPathElement>(realm, document, move(qualified_name)));
  264. if (lowercase_tag_name == SVG::TagNames::circle)
  265. return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGCircleElement>(realm, document, move(qualified_name)));
  266. if (lowercase_tag_name.equals_ignoring_ascii_case(SVG::TagNames::defs))
  267. return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGDefsElement>(realm, document, move(qualified_name)));
  268. if (lowercase_tag_name == SVG::TagNames::ellipse)
  269. return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGEllipseElement>(realm, document, move(qualified_name)));
  270. if (lowercase_tag_name.equals_ignoring_ascii_case(SVG::TagNames::foreignObject))
  271. return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGForeignObjectElement>(realm, document, move(qualified_name)));
  272. if (lowercase_tag_name == SVG::TagNames::line)
  273. return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGLineElement>(realm, document, move(qualified_name)));
  274. if (lowercase_tag_name == SVG::TagNames::path)
  275. return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGPathElement>(realm, document, move(qualified_name)));
  276. if (lowercase_tag_name == SVG::TagNames::polygon)
  277. return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGPolygonElement>(realm, document, move(qualified_name)));
  278. if (lowercase_tag_name == SVG::TagNames::polyline)
  279. return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGPolylineElement>(realm, document, move(qualified_name)));
  280. if (lowercase_tag_name == SVG::TagNames::rect)
  281. return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGRectElement>(realm, document, move(qualified_name)));
  282. if (lowercase_tag_name == SVG::TagNames::g)
  283. return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGGElement>(realm, document, move(qualified_name)));
  284. if (lowercase_tag_name == SVG::TagNames::text)
  285. return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGTextContentElement>(realm, document, move(qualified_name)));
  286. // FIXME: If name is a valid custom element name, then return HTMLElement.
  287. return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLUnknownElement>(realm, document, move(qualified_name)));
  288. }
  289. }