2020-01-18 09:38:21 +01:00
/*
2021-02-07 11:20:15 +01:00
* Copyright ( c ) 2018 - 2021 , Andreas Kling < kling @ serenityos . org >
2021-04-22 22:12:55 +01:00
* Copyright ( c ) 2020 , Luke Wilde < lukew @ serenityos . org >
2020-01-18 09:38:21 +01:00
*
2021-04-22 01:24:48 -07:00
* SPDX - License - Identifier : BSD - 2 - Clause
2020-01-18 09:38:21 +01:00
*/
2020-03-07 10:32:51 +01:00
# include <LibWeb/DOM/ElementFactory.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLAnchorElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLAreaElement.h>
# include <LibWeb/HTML/HTMLAudioElement.h>
2020-09-18 09:49:51 +02:00
# include <LibWeb/HTML/HTMLBRElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLBaseElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLBlinkElement.h>
# include <LibWeb/HTML/HTMLBodyElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLButtonElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLCanvasElement.h>
2020-09-18 09:49:51 +02:00
# include <LibWeb/HTML/HTMLDListElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLDataElement.h>
# include <LibWeb/HTML/HTMLDataListElement.h>
# include <LibWeb/HTML/HTMLDetailsElement.h>
# include <LibWeb/HTML/HTMLDialogElement.h>
2020-11-12 04:16:41 +00:00
# include <LibWeb/HTML/HTMLDirectoryElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLDivElement.h>
# include <LibWeb/HTML/HTMLEmbedElement.h>
# include <LibWeb/HTML/HTMLFieldSetElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLFontElement.h>
# include <LibWeb/HTML/HTMLFormElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLFrameElement.h>
# include <LibWeb/HTML/HTMLFrameSetElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLHRElement.h>
# include <LibWeb/HTML/HTMLHeadElement.h>
# include <LibWeb/HTML/HTMLHeadingElement.h>
# include <LibWeb/HTML/HTMLHtmlElement.h>
# include <LibWeb/HTML/HTMLIFrameElement.h>
# include <LibWeb/HTML/HTMLImageElement.h>
# include <LibWeb/HTML/HTMLInputElement.h>
2020-09-18 09:49:51 +02:00
# include <LibWeb/HTML/HTMLLIElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLLabelElement.h>
# include <LibWeb/HTML/HTMLLegendElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLLinkElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLMapElement.h>
# include <LibWeb/HTML/HTMLMarqueeElement.h>
# include <LibWeb/HTML/HTMLMenuElement.h>
# include <LibWeb/HTML/HTMLMetaElement.h>
# include <LibWeb/HTML/HTMLMeterElement.h>
# include <LibWeb/HTML/HTMLModElement.h>
# include <LibWeb/HTML/HTMLOListElement.h>
2020-09-18 09:49:51 +02:00
# include <LibWeb/HTML/HTMLObjectElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLOptGroupElement.h>
# include <LibWeb/HTML/HTMLOptionElement.h>
# include <LibWeb/HTML/HTMLOutputElement.h>
# include <LibWeb/HTML/HTMLParagraphElement.h>
# include <LibWeb/HTML/HTMLParamElement.h>
# include <LibWeb/HTML/HTMLPictureElement.h>
# include <LibWeb/HTML/HTMLPreElement.h>
# include <LibWeb/HTML/HTMLProgressElement.h>
# include <LibWeb/HTML/HTMLQuoteElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLScriptElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLSelectElement.h>
# include <LibWeb/HTML/HTMLSlotElement.h>
# include <LibWeb/HTML/HTMLSourceElement.h>
# include <LibWeb/HTML/HTMLSpanElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLStyleElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLTableCaptionElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLTableCellElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLTableColElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLTableElement.h>
# include <LibWeb/HTML/HTMLTableRowElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLTableSectionElement.h>
# include <LibWeb/HTML/HTMLTemplateElement.h>
2020-09-18 09:49:51 +02:00
# include <LibWeb/HTML/HTMLTextAreaElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLTimeElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLTitleElement.h>
2020-09-18 09:49:51 +02:00
# include <LibWeb/HTML/HTMLTrackElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLUListElement.h>
# include <LibWeb/HTML/HTMLUnknownElement.h>
# include <LibWeb/HTML/HTMLVideoElement.h>
2022-02-11 16:14:58 +00:00
# include <LibWeb/SVG/SVGCircleElement.h>
2022-02-11 16:45:59 +00:00
# include <LibWeb/SVG/SVGEllipseElement.h>
2021-09-18 00:04:19 +02:00
# include <LibWeb/SVG/SVGGElement.h>
2022-02-11 16:56:36 +00:00
# include <LibWeb/SVG/SVGLineElement.h>
2020-07-23 09:44:42 -07:00
# include <LibWeb/SVG/SVGPathElement.h>
2022-02-11 17:36:05 +00:00
# include <LibWeb/SVG/SVGPolygonElement.h>
2022-02-11 17:28:24 +00:00
# include <LibWeb/SVG/SVGPolylineElement.h>
2022-02-11 15:52:42 +00:00
# include <LibWeb/SVG/SVGRectElement.h>
2020-07-23 09:44:42 -07:00
# include <LibWeb/SVG/SVGSVGElement.h>
2022-03-20 11:20:06 +01:00
# include <LibWeb/SVG/SVGTextContentElement.h>
2020-07-23 09:44:42 -07:00
# include <LibWeb/SVG/TagNames.h>
2019-10-12 13:02:38 +02:00
2020-07-26 19:37:56 +02:00
namespace Web : : DOM {
2020-03-07 10:27:02 +01:00
2022-03-02 10:55:16 +01:00
// https://dom.spec.whatwg.org/#concept-create-element
NonnullRefPtr < Element > create_element ( Document & document , FlyString local_name , FlyString namespace_ , FlyString prefix )
2019-10-12 13:02:38 +02:00
{
2022-03-02 10:55:16 +01:00
// 1. If prefix was not given, let prefix be null.
// NOTE: This is already taken care of by `prefix` having a default value.
2022-02-25 21:29:12 +01:00
2022-03-02 10:55:16 +01:00
// FIXME: 2. If is was not given, let is be null.
// FIXME: 3. Let result be null.
// FIXME: 4. Let definition be the result of looking up a custom element definition given document, namespace, localName, and is.
// 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: ...
// FIXME: 6. Otherwise, if definition is non-null, then: ...
2022-02-25 21:29:12 +01:00
2022-03-02 10:55:16 +01:00
// 7. Otherwise:
// 1. Let interface be the element interface for localName and namespace.
// 2. Set result to a new element that implements interface, with no attributes, namespace set to namespace, namespace prefix set to prefix,
// local name set to localName, custom element state set to "uncustomized", custom element definition set to null, is value set to is,
// and node document set to document.
// FIXME: 3. If namespace is the HTML namespace, and either localName is a valid custom element name or is is non-null,
// then set result’ s custom element state to "undefined".
// 8. Return result.
auto lowercase_tag_name = local_name . to_lowercase ( ) ;
auto qualified_name = QualifiedName { local_name , prefix , namespace_ } ;
2020-06-07 23:27:03 +02:00
if ( lowercase_tag_name = = HTML : : TagNames : : a )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLAnchorElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : area )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLAreaElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : audio )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLAudioElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : base )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLBaseElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : blink )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLBlinkElement ( document , move ( qualified_name ) ) ) ;
2020-06-07 23:27:03 +02:00
if ( lowercase_tag_name = = HTML : : TagNames : : body )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLBodyElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : br )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLBRElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : button )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLButtonElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : canvas )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLCanvasElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : data )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLDataElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : datalist )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLDataListElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : details )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLDetailsElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : dialog )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLDialogElement ( document , move ( qualified_name ) ) ) ;
2020-11-12 04:16:41 +00:00
if ( lowercase_tag_name = = HTML : : TagNames : : dir )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLDirectoryElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : div )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLDivElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : dl )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLDListElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : embed )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLEmbedElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : fieldset )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLFieldSetElement ( document , move ( qualified_name ) ) ) ;
2020-06-07 23:27:03 +02:00
if ( lowercase_tag_name = = HTML : : TagNames : : font )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLFontElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : form )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLFormElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : frame )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLFrameElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : frameset )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLFrameSetElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : head )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLHeadElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
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 ) )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLHeadingElement ( document , move ( qualified_name ) ) ) ;
2020-06-07 23:27:03 +02:00
if ( lowercase_tag_name = = HTML : : TagNames : : hr )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLHRElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : html )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLHtmlElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : iframe )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLIFrameElement ( document , move ( qualified_name ) ) ) ;
2020-06-07 23:27:03 +02:00
if ( lowercase_tag_name = = HTML : : TagNames : : img )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLImageElement ( document , move ( qualified_name ) ) ) ;
2020-06-07 23:27:03 +02:00
if ( lowercase_tag_name = = HTML : : TagNames : : input )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLInputElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : label )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLLabelElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : legend )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLLegendElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : li )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLLIElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : link )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLLinkElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : map )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLMapElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : marquee )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLMarqueeElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : menu )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLMenuElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : meta )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLMetaElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : meter )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLMeterElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name . is_one_of ( HTML : : TagNames : : ins , HTML : : TagNames : : del ) )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLModElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : object )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLObjectElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : ol )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLOListElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : optgroup )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLOptGroupElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : option )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLOptionElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : output )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLOutputElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : p )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLParagraphElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : param )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLParamElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : picture )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLPictureElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
// NOTE: The obsolete elements "listing" and "xmp" are explicitly mapped to HTMLPreElement in the specification.
if ( lowercase_tag_name . is_one_of ( HTML : : TagNames : : pre , HTML : : TagNames : : listing , HTML : : TagNames : : xmp ) )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLPreElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : progress )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLProgressElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name . is_one_of ( HTML : : TagNames : : blockquote , HTML : : TagNames : : q ) )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLQuoteElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : script )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLScriptElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : select )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLSelectElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : slot )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLSlotElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : source )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLSourceElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : span )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLSpanElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : style )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLStyleElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : caption )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLTableCaptionElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name . is_one_of ( Web : : HTML : : TagNames : : td , Web : : HTML : : TagNames : : th ) )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLTableCellElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name . is_one_of ( HTML : : TagNames : : colgroup , HTML : : TagNames : : col ) )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLTableColElement ( document , move ( qualified_name ) ) ) ;
2020-06-07 23:27:03 +02:00
if ( lowercase_tag_name = = HTML : : TagNames : : table )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLTableElement ( document , move ( qualified_name ) ) ) ;
2020-06-07 23:27:03 +02:00
if ( lowercase_tag_name = = HTML : : TagNames : : tr )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLTableRowElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name . is_one_of ( HTML : : TagNames : : tbody , HTML : : TagNames : : thead , HTML : : TagNames : : tfoot ) )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLTableSectionElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : template_ )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLTemplateElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : textarea )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLTextAreaElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : time )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLTimeElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : title )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLTitleElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : track )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLTrackElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : ul )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLUListElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name = = HTML : : TagNames : : video )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLVideoElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
if ( lowercase_tag_name . is_one_of (
2020-09-18 09:49:51 +02:00
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 ,
// Obsolete
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 ) )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLElement ( document , move ( qualified_name ) ) ) ;
2020-07-23 09:44:42 -07:00
if ( lowercase_tag_name = = SVG : : TagNames : : svg )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new SVG : : SVGSVGElement ( document , move ( qualified_name ) ) ) ;
2022-02-11 16:14:58 +00:00
if ( lowercase_tag_name = = SVG : : TagNames : : circle )
return adopt_ref ( * new SVG : : SVGCircleElement ( document , move ( qualified_name ) ) ) ;
2022-02-11 16:45:59 +00:00
if ( lowercase_tag_name = = SVG : : TagNames : : ellipse )
return adopt_ref ( * new SVG : : SVGEllipseElement ( document , move ( qualified_name ) ) ) ;
2022-02-11 16:56:36 +00:00
if ( lowercase_tag_name = = SVG : : TagNames : : line )
return adopt_ref ( * new SVG : : SVGLineElement ( document , move ( qualified_name ) ) ) ;
2020-07-23 09:44:42 -07:00
if ( lowercase_tag_name = = SVG : : TagNames : : path )
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new SVG : : SVGPathElement ( document , move ( qualified_name ) ) ) ;
2022-02-11 17:36:05 +00:00
if ( lowercase_tag_name = = SVG : : TagNames : : polygon )
return adopt_ref ( * new SVG : : SVGPolygonElement ( document , move ( qualified_name ) ) ) ;
2022-02-11 17:28:24 +00:00
if ( lowercase_tag_name = = SVG : : TagNames : : polyline )
return adopt_ref ( * new SVG : : SVGPolylineElement ( document , move ( qualified_name ) ) ) ;
2022-02-11 15:52:42 +00:00
if ( lowercase_tag_name = = SVG : : TagNames : : rect )
return adopt_ref ( * new SVG : : SVGRectElement ( document , move ( qualified_name ) ) ) ;
2021-09-18 00:04:19 +02:00
if ( lowercase_tag_name = = SVG : : TagNames : : g )
return adopt_ref ( * new SVG : : SVGGElement ( document , move ( qualified_name ) ) ) ;
2022-03-20 11:20:06 +01:00
if ( lowercase_tag_name = = SVG : : TagNames : : text )
return adopt_ref ( * new SVG : : SVGTextContentElement ( document , move ( qualified_name ) ) ) ;
2020-08-09 17:10:41 +01:00
// FIXME: If name is a valid custom element name, then return HTMLElement.
2021-04-23 16:46:57 +02:00
return adopt_ref ( * new HTML : : HTMLUnknownElement ( document , move ( qualified_name ) ) ) ;
2019-10-12 13:02:38 +02:00
}
2020-03-07 10:27:02 +01:00
}