diff options
author | Luke <luke.wilde@live.co.uk> | 2020-08-09 17:10:41 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-09 21:14:51 +0200 |
commit | 5724ac8e7225ea6a368b391a4e1b72bc70bfe07c (patch) | |
tree | 23ea1fa8ff4fb1d95a4cee4ddaf49f672a1cec07 /Libraries/LibWeb | |
parent | be5a62d5d7bd5d1484c909ada2bf9b189afacf69 (diff) | |
download | serenity-5724ac8e7225ea6a368b391a4e1b72bc70bfe07c.zip |
LibWeb: Add HTML elements to factories, add missing tags and attributes
This is mostly to get the grunt work of the way. This is split up into
multiple commits to hopefully make it more manageable to review.
Note that these are not full implementations, and the bindings mostly
get the low hanging fruit.
Also implements some attributes that I kept out because they had
dashes in them. Therefore, this closes #2905.
Diffstat (limited to 'Libraries/LibWeb')
-rw-r--r-- | Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp | 202 | ||||
-rw-r--r-- | Libraries/LibWeb/CMakeLists.txt | 98 | ||||
-rw-r--r-- | Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp | 14 | ||||
-rw-r--r-- | Libraries/LibWeb/DOM/AttributeNames.cpp | 7 | ||||
-rw-r--r-- | Libraries/LibWeb/DOM/AttributeNames.h | 19 | ||||
-rw-r--r-- | Libraries/LibWeb/DOM/ElementFactory.cpp | 210 | ||||
-rw-r--r-- | Libraries/LibWeb/DOM/Node.h | 1 | ||||
-rw-r--r-- | Libraries/LibWeb/DOM/TagNames.h | 28 | ||||
-rw-r--r-- | Libraries/LibWeb/Forward.h | 112 | ||||
-rw-r--r-- | Libraries/LibWeb/HTML/HTMLFormElement.idl | 1 | ||||
-rw-r--r-- | Libraries/LibWeb/HTML/HTMLMetaElement.idl | 1 | ||||
-rw-r--r-- | Libraries/LibWeb/HTML/HTMLPreElement.h | 2 | ||||
-rw-r--r-- | Libraries/LibWeb/HTML/HTMLUnknownElement.h | 7 |
13 files changed, 652 insertions, 50 deletions
diff --git a/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp b/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp index 70bfd61bf8..4826e02d92 100644 --- a/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp +++ b/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2020, Luke Wilde <luke.wilde@live.co.uk> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,53 +29,147 @@ #include <LibWeb/Bindings/DocumentTypeWrapper.h> #include <LibWeb/Bindings/DocumentWrapper.h> #include <LibWeb/Bindings/HTMLAnchorElementWrapper.h> -#include <LibWeb/Bindings/HTMLBRElementWrapper.h> +#include <LibWeb/Bindings/HTMLAreaElementWrapper.h> +#include <LibWeb/Bindings/HTMLAudioElementWrapper.h> +#include <LibWeb/Bindings/HTMLBaseElementWrapper.h> #include <LibWeb/Bindings/HTMLBodyElementWrapper.h> +#include <LibWeb/Bindings/HTMLBRElementWrapper.h> +#include <LibWeb/Bindings/HTMLButtonElementWrapper.h> #include <LibWeb/Bindings/HTMLCanvasElementWrapper.h> +#include <LibWeb/Bindings/HTMLDataElementWrapper.h> +#include <LibWeb/Bindings/HTMLDetailsElementWrapper.h> +#include <LibWeb/Bindings/HTMLDataListElementWrapper.h> +#include <LibWeb/Bindings/HTMLDialogElementWrapper.h> +#include <LibWeb/Bindings/HTMLDivElementWrapper.h> +#include <LibWeb/Bindings/HTMLDListElementWrapper.h> +#include <LibWeb/Bindings/HTMLEmbedElementWrapper.h> +#include <LibWeb/Bindings/HTMLFieldSetElementWrapper.h> #include <LibWeb/Bindings/HTMLElementWrapper.h> #include <LibWeb/Bindings/HTMLFormElementWrapper.h> -#include <LibWeb/Bindings/HTMLHRElementWrapper.h> +#include <LibWeb/Bindings/HTMLFrameElementWrapper.h> +#include <LibWeb/Bindings/HTMLFrameSetElementWrapper.h> #include <LibWeb/Bindings/HTMLHeadElementWrapper.h> #include <LibWeb/Bindings/HTMLHeadingElementWrapper.h> +#include <LibWeb/Bindings/HTMLHRElementWrapper.h> #include <LibWeb/Bindings/HTMLHtmlElementWrapper.h> #include <LibWeb/Bindings/HTMLIFrameElementWrapper.h> #include <LibWeb/Bindings/HTMLImageElementWrapper.h> #include <LibWeb/Bindings/HTMLInputElementWrapper.h> +#include <LibWeb/Bindings/HTMLLabelElementWrapper.h> +#include <LibWeb/Bindings/HTMLLegendElementWrapper.h> +#include <LibWeb/Bindings/HTMLLIElementWrapper.h> #include <LibWeb/Bindings/HTMLLinkElementWrapper.h> +#include <LibWeb/Bindings/HTMLMapElementWrapper.h> +#include <LibWeb/Bindings/HTMLMarqueeElementWrapper.h> +#include <LibWeb/Bindings/HTMLMenuElementWrapper.h> +#include <LibWeb/Bindings/HTMLMetaElementWrapper.h> +#include <LibWeb/Bindings/HTMLMeterElementWrapper.h> +#include <LibWeb/Bindings/HTMLModElementWrapper.h> #include <LibWeb/Bindings/HTMLObjectElementWrapper.h> +#include <LibWeb/Bindings/HTMLOListElementWrapper.h> +#include <LibWeb/Bindings/HTMLOptGroupElementWrapper.h> +#include <LibWeb/Bindings/HTMLOptionElementWrapper.h> +#include <LibWeb/Bindings/HTMLOutputElementWrapper.h> +#include <LibWeb/Bindings/HTMLParagraphElementWrapper.h> +#include <LibWeb/Bindings/HTMLParamElementWrapper.h> +#include <LibWeb/Bindings/HTMLPictureElementWrapper.h> +#include <LibWeb/Bindings/HTMLPreElementWrapper.h> +#include <LibWeb/Bindings/HTMLProgressElementWrapper.h> +#include <LibWeb/Bindings/HTMLQuoteElementWrapper.h> #include <LibWeb/Bindings/HTMLScriptElementWrapper.h> +#include <LibWeb/Bindings/HTMLSelectElementWrapper.h> +#include <LibWeb/Bindings/HTMLSlotElementWrapper.h> +#include <LibWeb/Bindings/HTMLSourceElementWrapper.h> +#include <LibWeb/Bindings/HTMLSpanElementWrapper.h> #include <LibWeb/Bindings/HTMLStyleElementWrapper.h> +#include <LibWeb/Bindings/HTMLTableCaptionElementWrapper.h> +#include <LibWeb/Bindings/HTMLTableColElementWrapper.h> #include <LibWeb/Bindings/HTMLTableCellElementWrapper.h> #include <LibWeb/Bindings/HTMLTableElementWrapper.h> #include <LibWeb/Bindings/HTMLTableRowElementWrapper.h> +#include <LibWeb/Bindings/HTMLTableSectionElementWrapper.h> +#include <LibWeb/Bindings/HTMLTemplateElementWrapper.h> +#include <LibWeb/Bindings/HTMLTextAreaElementWrapper.h> +#include <LibWeb/Bindings/HTMLTimeElementWrapper.h> #include <LibWeb/Bindings/HTMLTitleElementWrapper.h> +#include <LibWeb/Bindings/HTMLTrackElementWrapper.h> +#include <LibWeb/Bindings/HTMLUListElementWrapper.h> +#include <LibWeb/Bindings/HTMLUnknownElementWrapper.h> +#include <LibWeb/Bindings/HTMLVideoElementWrapper.h> #include <LibWeb/Bindings/NodeWrapper.h> #include <LibWeb/Bindings/TextWrapper.h> #include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Node.h> #include <LibWeb/HTML/HTMLAnchorElement.h> -#include <LibWeb/HTML/HTMLBRElement.h> +#include <LibWeb/HTML/HTMLAreaElement.h> +#include <LibWeb/HTML/HTMLAudioElement.h> +#include <LibWeb/HTML/HTMLBaseElement.h> #include <LibWeb/HTML/HTMLBodyElement.h> +#include <LibWeb/HTML/HTMLBRElement.h> +#include <LibWeb/HTML/HTMLButtonElement.h> #include <LibWeb/HTML/HTMLCanvasElement.h> +#include <LibWeb/HTML/HTMLDataElement.h> +#include <LibWeb/HTML/HTMLDetailsElement.h> +#include <LibWeb/HTML/HTMLDataListElement.h> +#include <LibWeb/HTML/HTMLDialogElement.h> +#include <LibWeb/HTML/HTMLDivElement.h> +#include <LibWeb/HTML/HTMLDListElement.h> +#include <LibWeb/HTML/HTMLEmbedElement.h> +#include <LibWeb/HTML/HTMLFieldSetElement.h> #include <LibWeb/HTML/HTMLFormElement.h> -#include <LibWeb/HTML/HTMLHRElement.h> +#include <LibWeb/HTML/HTMLFrameElement.h> +#include <LibWeb/HTML/HTMLFrameSetElement.h> #include <LibWeb/HTML/HTMLHeadElement.h> #include <LibWeb/HTML/HTMLHeadingElement.h> +#include <LibWeb/HTML/HTMLHRElement.h> #include <LibWeb/HTML/HTMLHtmlElement.h> #include <LibWeb/HTML/HTMLIFrameElement.h> #include <LibWeb/HTML/HTMLImageElement.h> #include <LibWeb/HTML/HTMLInputElement.h> +#include <LibWeb/HTML/HTMLLabelElement.h> +#include <LibWeb/HTML/HTMLLegendElement.h> +#include <LibWeb/HTML/HTMLLIElement.h> #include <LibWeb/HTML/HTMLLinkElement.h> +#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/HTMLObjectElement.h> +#include <LibWeb/HTML/HTMLOListElement.h> +#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> #include <LibWeb/HTML/HTMLScriptElement.h> +#include <LibWeb/HTML/HTMLSelectElement.h> +#include <LibWeb/HTML/HTMLSlotElement.h> +#include <LibWeb/HTML/HTMLSourceElement.h> +#include <LibWeb/HTML/HTMLSpanElement.h> #include <LibWeb/HTML/HTMLStyleElement.h> +#include <LibWeb/HTML/HTMLTableCaptionElement.h> #include <LibWeb/HTML/HTMLTableCellElement.h> +#include <LibWeb/HTML/HTMLTableColElement.h> #include <LibWeb/HTML/HTMLTableElement.h> #include <LibWeb/HTML/HTMLTableRowElement.h> +#include <LibWeb/HTML/HTMLTableSectionElement.h> +#include <LibWeb/HTML/HTMLTemplateElement.h> +#include <LibWeb/HTML/HTMLTextAreaElement.h> +#include <LibWeb/HTML/HTMLTimeElement.h> #include <LibWeb/HTML/HTMLTitleElement.h> +#include <LibWeb/HTML/HTMLTrackElement.h> +#include <LibWeb/HTML/HTMLUListElement.h> +#include <LibWeb/HTML/HTMLUnknownElement.h> +#include <LibWeb/HTML/HTMLVideoElement.h> +#include <LibWeb/DOM/Node.h> -namespace Web { -namespace Bindings { +namespace Web::Bindings { NodeWrapper* wrap(JS::GlobalObject& global_object, DOM::Node& node) { @@ -84,14 +179,42 @@ NodeWrapper* wrap(JS::GlobalObject& global_object, DOM::Node& node) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<DOM::DocumentType>(node))); if (is<HTML::HTMLAnchorElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLAnchorElement>(node))); + if (is<HTML::HTMLAreaElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLAreaElement>(node))); + if (is<HTML::HTMLAudioElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLAudioElement>(node))); + if (is<HTML::HTMLBaseElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLBaseElement>(node))); if (is<HTML::HTMLBodyElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLBodyElement>(node))); if (is<HTML::HTMLBRElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLBRElement>(node))); + if (is<HTML::HTMLButtonElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLButtonElement>(node))); if (is<HTML::HTMLCanvasElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLCanvasElement>(node))); + if (is<HTML::HTMLDataElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLDataElement>(node))); + if (is<HTML::HTMLDataListElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLDataListElement>(node))); + if (is<HTML::HTMLDetailsElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLDetailsElement>(node))); + if (is<HTML::HTMLDialogElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLDialogElement>(node))); + if (is<HTML::HTMLDivElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLDivElement>(node))); + if (is<HTML::HTMLDListElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLDListElement>(node))); + if (is<HTML::HTMLEmbedElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLEmbedElement>(node))); + if (is<HTML::HTMLFieldSetElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLFieldSetElement>(node))); if (is<HTML::HTMLFormElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLFormElement>(node))); + if (is<HTML::HTMLFrameElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLFrameElement>(node))); + if (is<HTML::HTMLFrameSetElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLFrameSetElement>(node))); if (is<HTML::HTMLHeadElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLHeadElement>(node))); if (is<HTML::HTMLHeadingElement>(node)) @@ -106,22 +229,88 @@ NodeWrapper* wrap(JS::GlobalObject& global_object, DOM::Node& node) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLImageElement>(node))); if (is<HTML::HTMLInputElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLInputElement>(node))); + if (is<HTML::HTMLLabelElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLLabelElement>(node))); + if (is<HTML::HTMLLegendElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLLegendElement>(node))); + if (is<HTML::HTMLLIElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLLIElement>(node))); if (is<HTML::HTMLLinkElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLLinkElement>(node))); + if (is<HTML::HTMLMapElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLMapElement>(node))); + if (is<HTML::HTMLMarqueeElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLMarqueeElement>(node))); + if (is<HTML::HTMLMenuElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLMenuElement>(node))); + if (is<HTML::HTMLMetaElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLMetaElement>(node))); + if (is<HTML::HTMLMeterElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLMeterElement>(node))); + if (is<HTML::HTMLModElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLModElement>(node))); if (is<HTML::HTMLObjectElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLObjectElement>(node))); + if (is<HTML::HTMLOListElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLOListElement>(node))); + if (is<HTML::HTMLOptGroupElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLOptGroupElement>(node))); + if (is<HTML::HTMLOptionElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLOptionElement>(node))); + if (is<HTML::HTMLOutputElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLOutputElement>(node))); + if (is<HTML::HTMLParagraphElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLParagraphElement>(node))); + if (is<HTML::HTMLParamElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLParamElement>(node))); + if (is<HTML::HTMLPictureElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLPictureElement>(node))); + if (is<HTML::HTMLPreElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLPreElement>(node))); + if (is<HTML::HTMLProgressElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLProgressElement>(node))); + if (is<HTML::HTMLQuoteElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLQuoteElement>(node))); if (is<HTML::HTMLScriptElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLScriptElement>(node))); + if (is<HTML::HTMLSelectElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLSelectElement>(node))); + if (is<HTML::HTMLSlotElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLSlotElement>(node))); + if (is<HTML::HTMLSourceElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLSourceElement>(node))); + if (is<HTML::HTMLSpanElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLSpanElement>(node))); if (is<HTML::HTMLStyleElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLStyleElement>(node))); + if (is<HTML::HTMLTableCaptionElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLTableCaptionElement>(node))); if (is<HTML::HTMLTableCellElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLTableCellElement>(node))); + if (is<HTML::HTMLTableColElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLTableColElement>(node))); if (is<HTML::HTMLTableElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLTableElement>(node))); if (is<HTML::HTMLTableRowElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLTableRowElement>(node))); + if (is<HTML::HTMLTableSectionElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLTableSectionElement>(node))); + if (is<HTML::HTMLTemplateElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLTemplateElement>(node))); + if (is<HTML::HTMLTextAreaElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLTextAreaElement>(node))); + if (is<HTML::HTMLTimeElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLTimeElement>(node))); if (is<HTML::HTMLTitleElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLTitleElement>(node))); + if (is<HTML::HTMLTrackElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLTrackElement>(node))); + if (is<HTML::HTMLUListElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLUListElement>(node))); + if (is<HTML::HTMLUnknownElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLUnknownElement>(node))); + if (is<HTML::HTMLVideoElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLVideoElement>(node))); if (is<HTML::HTMLElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLElement>(node))); if (is<DOM::Element>(node)) @@ -134,4 +323,3 @@ NodeWrapper* wrap(JS::GlobalObject& global_object, DOM::Node& node) } } -} diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index 1bec9e2e92..83de29089b 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -47,13 +47,27 @@ set(SOURCES FontCache.cpp HTML/CanvasRenderingContext2D.cpp HTML/HTMLAnchorElement.cpp - HTML/HTMLBRElement.cpp + HTML/HTMLAreaElement.cpp + HTML/HTMLAudioElement.cpp + HTML/HTMLBaseElement.cpp HTML/HTMLBlinkElement.cpp HTML/HTMLBodyElement.cpp + HTML/HTMLBRElement.cpp + HTML/HTMLButtonElement.cpp HTML/HTMLCanvasElement.cpp + HTML/HTMLDataElement.cpp + HTML/HTMLDataListElement.cpp + HTML/HTMLDetailsElement.cpp + HTML/HTMLDialogElement.cpp + HTML/HTMLDivElement.cpp + HTML/HTMLDListElement.cpp HTML/HTMLElement.cpp + HTML/HTMLEmbedElement.cpp + HTML/HTMLFieldSetElement.cpp HTML/HTMLFontElement.cpp HTML/HTMLFormElement.cpp + HTML/HTMLFrameElement.cpp + HTML/HTMLFrameSetElement.cpp HTML/HTMLHRElement.cpp HTML/HTMLHeadElement.cpp HTML/HTMLHeadingElement.cpp @@ -61,14 +75,48 @@ set(SOURCES HTML/HTMLIFrameElement.cpp HTML/HTMLImageElement.cpp HTML/HTMLInputElement.cpp + HTML/HTMLLabelElement.cpp + HTML/HTMLLegendElement.cpp + HTML/HTMLLIElement.cpp HTML/HTMLLinkElement.cpp + HTML/HTMLMapElement.cpp + HTML/HTMLMarqueeElement.cpp + HTML/HTMLMediaElement.cpp + HTML/HTMLMenuElement.cpp + HTML/HTMLMetaElement.cpp + HTML/HTMLMeterElement.cpp + HTML/HTMLModElement.cpp HTML/HTMLObjectElement.cpp + HTML/HTMLOListElement.cpp + HTML/HTMLOptGroupElement.cpp + HTML/HTMLOptionElement.cpp + HTML/HTMLOutputElement.cpp + HTML/HTMLParagraphElement.cpp + HTML/HTMLParamElement.cpp + HTML/HTMLPictureElement.cpp + HTML/HTMLPreElement.cpp + HTML/HTMLProgressElement.cpp + HTML/HTMLQuoteElement.cpp HTML/HTMLScriptElement.cpp + HTML/HTMLSelectElement.cpp + HTML/HTMLSlotElement.cpp + HTML/HTMLSourceElement.cpp + HTML/HTMLSpanElement.cpp HTML/HTMLStyleElement.cpp + HTML/HTMLTableCaptionElement.cpp HTML/HTMLTableCellElement.cpp + HTML/HTMLTableColElement.cpp HTML/HTMLTableElement.cpp HTML/HTMLTableRowElement.cpp + HTML/HTMLTableSectionElement.cpp + HTML/HTMLTemplateElement.cpp + HTML/HTMLTextAreaElement.cpp + HTML/HTMLTimeElement.cpp HTML/HTMLTitleElement.cpp + HTML/HTMLTrackElement.cpp + HTML/HTMLUListElement.cpp + HTML/HTMLUnknownElement.cpp + HTML/HTMLVideoElement.cpp HTML/ImageData.cpp HTML/Parser/Entities.cpp HTML/Parser/HTMLDocumentParser.cpp @@ -172,11 +220,25 @@ libweb_js_wrapper(DOM/Node) libweb_js_wrapper(DOM/Text) libweb_js_wrapper(HTML/CanvasRenderingContext2D) libweb_js_wrapper(HTML/HTMLAnchorElement) +libweb_js_wrapper(HTML/HTMLAreaElement) +libweb_js_wrapper(HTML/HTMLAudioElement) +libweb_js_wrapper(HTML/HTMLBaseElement) libweb_js_wrapper(HTML/HTMLBodyElement) libweb_js_wrapper(HTML/HTMLBRElement) +libweb_js_wrapper(HTML/HTMLButtonElement) libweb_js_wrapper(HTML/HTMLCanvasElement) +libweb_js_wrapper(HTML/HTMLDataElement) +libweb_js_wrapper(HTML/HTMLDataListElement) +libweb_js_wrapper(HTML/HTMLDetailsElement) +libweb_js_wrapper(HTML/HTMLDialogElement) +libweb_js_wrapper(HTML/HTMLDivElement) +libweb_js_wrapper(HTML/HTMLDListElement) libweb_js_wrapper(HTML/HTMLElement) +libweb_js_wrapper(HTML/HTMLEmbedElement) +libweb_js_wrapper(HTML/HTMLFieldSetElement) libweb_js_wrapper(HTML/HTMLFormElement) +libweb_js_wrapper(HTML/HTMLFrameElement) +libweb_js_wrapper(HTML/HTMLFrameSetElement) libweb_js_wrapper(HTML/HTMLHeadElement) libweb_js_wrapper(HTML/HTMLHeadingElement) libweb_js_wrapper(HTML/HTMLHRElement) @@ -184,14 +246,48 @@ libweb_js_wrapper(HTML/HTMLHtmlElement) libweb_js_wrapper(HTML/HTMLIFrameElement) libweb_js_wrapper(HTML/HTMLImageElement) libweb_js_wrapper(HTML/HTMLInputElement) +libweb_js_wrapper(HTML/HTMLLabelElement) +libweb_js_wrapper(HTML/HTMLLegendElement) +libweb_js_wrapper(HTML/HTMLLIElement) libweb_js_wrapper(HTML/HTMLLinkElement) +libweb_js_wrapper(HTML/HTMLMapElement) +libweb_js_wrapper(HTML/HTMLMarqueeElement) +libweb_js_wrapper(HTML/HTMLMediaElement) +libweb_js_wrapper(HTML/HTMLMenuElement) +libweb_js_wrapper(HTML/HTMLMetaElement) +libweb_js_wrapper(HTML/HTMLMeterElement) +libweb_js_wrapper(HTML/HTMLModElement) libweb_js_wrapper(HTML/HTMLObjectElement) +libweb_js_wrapper(HTML/HTMLOListElement) +libweb_js_wrapper(HTML/HTMLOptGroupElement) +libweb_js_wrapper(HTML/HTMLOptionElement) +libweb_js_wrapper(HTML/HTMLOutputElement) +libweb_js_wrapper(HTML/HTMLParagraphElement) +libweb_js_wrapper(HTML/HTMLParamElement) +libweb_js_wrapper(HTML/HTMLPictureElement) +libweb_js_wrapper(HTML/HTMLPreElement) +libweb_js_wrapper(HTML/HTMLProgressElement) +libweb_js_wrapper(HTML/HTMLQuoteElement) libweb_js_wrapper(HTML/HTMLScriptElement) +libweb_js_wrapper(HTML/HTMLSelectElement) +libweb_js_wrapper(HTML/HTMLSlotElement) +libweb_js_wrapper(HTML/HTMLSourceElement) +libweb_js_wrapper(HTML/HTMLSpanElement) libweb_js_wrapper(HTML/HTMLStyleElement) +libweb_js_wrapper(HTML/HTMLTableCaptionElement) libweb_js_wrapper(HTML/HTMLTableCellElement) +libweb_js_wrapper(HTML/HTMLTableColElement) libweb_js_wrapper(HTML/HTMLTableElement) libweb_js_wrapper(HTML/HTMLTableRowElement) +libweb_js_wrapper(HTML/HTMLTableSectionElement) +libweb_js_wrapper(HTML/HTMLTemplateElement) +libweb_js_wrapper(HTML/HTMLTextAreaElement) +libweb_js_wrapper(HTML/HTMLTimeElement) libweb_js_wrapper(HTML/HTMLTitleElement) +libweb_js_wrapper(HTML/HTMLTrackElement) +libweb_js_wrapper(HTML/HTMLUListElement) +libweb_js_wrapper(HTML/HTMLUnknownElement) +libweb_js_wrapper(HTML/HTMLVideoElement) libweb_js_wrapper(HTML/ImageData) libweb_js_wrapper(UIEvents/MouseEvent) libweb_js_wrapper(UIEvents/UIEvent) diff --git a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp index f9a50dccec..5670104a8c 100644 --- a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp +++ b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp @@ -51,15 +51,19 @@ static String snake_name(const StringView& title_name) return builder.to_string(); } -static String add_underscore_to_cpp_keywords(const String& input) +static String make_input_acceptable_cpp(const String& input) { - if (input == "class" || input == "template") { + if (input == "class" || input == "template" || input == "for") { StringBuilder builder; builder.append(input); builder.append('_'); return builder.to_string(); } - return input; + + String input_without_dashes = input; + input_without_dashes.replace("-", "_"); + + return input_without_dashes; } namespace IDL { @@ -638,7 +642,7 @@ void generate_implementation(const IDL::Interface& interface) auto attribute_name = attribute.extended_attributes.get("Reflect").value(); if (attribute_name.is_null()) attribute_name = attribute.name; - attribute_name = add_underscore_to_cpp_keywords(attribute_name); + attribute_name = make_input_acceptable_cpp(attribute_name); out() << " auto retval = impl->attribute(HTML::AttributeNames::" << attribute_name << ");"; } else { out() << " auto retval = impl->" << snake_name(attribute.name) << "();"; @@ -660,7 +664,7 @@ void generate_implementation(const IDL::Interface& interface) auto attribute_name = attribute.extended_attributes.get("Reflect").value(); if (attribute_name.is_null()) attribute_name = attribute.name; - attribute_name = add_underscore_to_cpp_keywords(attribute_name); + attribute_name = make_input_acceptable_cpp(attribute_name); out() << " impl->set_attribute(HTML::AttributeNames::" << attribute_name << ", cpp_value);"; } else { out() << " impl->set_" << snake_name(attribute.name) << "(cpp_value);"; diff --git a/Libraries/LibWeb/DOM/AttributeNames.cpp b/Libraries/LibWeb/DOM/AttributeNames.cpp index 5310670589..3a5b0de38a 100644 --- a/Libraries/LibWeb/DOM/AttributeNames.cpp +++ b/Libraries/LibWeb/DOM/AttributeNames.cpp @@ -45,8 +45,13 @@ void initialize() ENUMERATE_HTML_ATTRIBUTES #undef __ENUMERATE_HTML_ATTRIBUTE - // NOTE: Special case for the class attribute since it's a C++ keyword. + // NOTE: Special case for the class and for attributes since they're C++ keywords. class_ = "class"; + for_ = "for"; + + // NOTE: Special cases for attributes with dashes in them. + accept_charset = "accept-charset"; + http_equiv = "http-equiv"; s_initialized = true; } diff --git a/Libraries/LibWeb/DOM/AttributeNames.h b/Libraries/LibWeb/DOM/AttributeNames.h index 5a1b5fcdde..9ffa580416 100644 --- a/Libraries/LibWeb/DOM/AttributeNames.h +++ b/Libraries/LibWeb/DOM/AttributeNames.h @@ -37,28 +37,40 @@ void initialize(); #define ENUMERATE_HTML_ATTRIBUTES \ __ENUMERATE_HTML_ATTRIBUTE(abbr) \ __ENUMERATE_HTML_ATTRIBUTE(accept) \ + __ENUMERATE_HTML_ATTRIBUTE(accept_charset) \ __ENUMERATE_HTML_ATTRIBUTE(action) \ __ENUMERATE_HTML_ATTRIBUTE(align) \ __ENUMERATE_HTML_ATTRIBUTE(allow) \ __ENUMERATE_HTML_ATTRIBUTE(alt) \ __ENUMERATE_HTML_ATTRIBUTE(async) \ + __ENUMERATE_HTML_ATTRIBUTE(behaviour) \ __ENUMERATE_HTML_ATTRIBUTE(bgcolor) \ + __ENUMERATE_HTML_ATTRIBUTE(cite) \ __ENUMERATE_HTML_ATTRIBUTE(class_) \ + __ENUMERATE_HTML_ATTRIBUTE(cols) \ __ENUMERATE_HTML_ATTRIBUTE(colspan) \ + __ENUMERATE_HTML_ATTRIBUTE(content) \ __ENUMERATE_HTML_ATTRIBUTE(contenteditable) \ __ENUMERATE_HTML_ATTRIBUTE(data) \ + __ENUMERATE_HTML_ATTRIBUTE(datetime) \ __ENUMERATE_HTML_ATTRIBUTE(download) \ __ENUMERATE_HTML_ATTRIBUTE(defer) \ + __ENUMERATE_HTML_ATTRIBUTE(direction) \ __ENUMERATE_HTML_ATTRIBUTE(dirname) \ + __ENUMERATE_HTML_ATTRIBUTE(for_) \ + __ENUMERATE_HTML_ATTRIBUTE(frameborder) \ __ENUMERATE_HTML_ATTRIBUTE(headers) \ __ENUMERATE_HTML_ATTRIBUTE(height) \ __ENUMERATE_HTML_ATTRIBUTE(href) \ __ENUMERATE_HTML_ATTRIBUTE(hreflang) \ + __ENUMERATE_HTML_ATTRIBUTE(http_equiv) \ __ENUMERATE_HTML_ATTRIBUTE(id) \ __ENUMERATE_HTML_ATTRIBUTE(imagesizes) \ __ENUMERATE_HTML_ATTRIBUTE(imagesrcset) \ __ENUMERATE_HTML_ATTRIBUTE(integrity) \ + __ENUMERATE_HTML_ATTRIBUTE(label) \ __ENUMERATE_HTML_ATTRIBUTE(lang) \ + __ENUMERATE_HTML_ATTRIBUTE(longdesc) \ __ENUMERATE_HTML_ATTRIBUTE(max) \ __ENUMERATE_HTML_ATTRIBUTE(media) \ __ENUMERATE_HTML_ATTRIBUTE(method) \ @@ -67,11 +79,15 @@ void initialize(); __ENUMERATE_HTML_ATTRIBUTE(pattern) \ __ENUMERATE_HTML_ATTRIBUTE(ping) \ __ENUMERATE_HTML_ATTRIBUTE(placeholder) \ + __ENUMERATE_HTML_ATTRIBUTE(poster) \ __ENUMERATE_HTML_ATTRIBUTE(rel) \ + __ENUMERATE_HTML_ATTRIBUTE(rows) \ + __ENUMERATE_HTML_ATTRIBUTE(scrolling) \ __ENUMERATE_HTML_ATTRIBUTE(size) \ __ENUMERATE_HTML_ATTRIBUTE(sizes) \ __ENUMERATE_HTML_ATTRIBUTE(src) \ __ENUMERATE_HTML_ATTRIBUTE(srcdoc) \ + __ENUMERATE_HTML_ATTRIBUTE(srclang) \ __ENUMERATE_HTML_ATTRIBUTE(srcset) \ __ENUMERATE_HTML_ATTRIBUTE(step) \ __ENUMERATE_HTML_ATTRIBUTE(style) \ @@ -80,7 +96,8 @@ void initialize(); __ENUMERATE_HTML_ATTRIBUTE(type) \ __ENUMERATE_HTML_ATTRIBUTE(usemap) \ __ENUMERATE_HTML_ATTRIBUTE(value) \ - __ENUMERATE_HTML_ATTRIBUTE(width) + __ENUMERATE_HTML_ATTRIBUTE(width) \ + __ENUMERATE_HTML_ATTRIBUTE(wrap) #define __ENUMERATE_HTML_ATTRIBUTE(name) extern FlyString name; ENUMERATE_HTML_ATTRIBUTES diff --git a/Libraries/LibWeb/DOM/ElementFactory.cpp b/Libraries/LibWeb/DOM/ElementFactory.cpp index d75fb01715..a8081cf88d 100644 --- a/Libraries/LibWeb/DOM/ElementFactory.cpp +++ b/Libraries/LibWeb/DOM/ElementFactory.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2020, Luke Wilde <luke.wilde@live.co.uk> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,12 +27,26 @@ #include <LibWeb/DOM/ElementFactory.h> #include <LibWeb/HTML/HTMLAnchorElement.h> -#include <LibWeb/HTML/HTMLBRElement.h> +#include <LibWeb/HTML/HTMLAreaElement.h> +#include <LibWeb/HTML/HTMLAudioElement.h> +#include <LibWeb/HTML/HTMLBaseElement.h> #include <LibWeb/HTML/HTMLBlinkElement.h> #include <LibWeb/HTML/HTMLBodyElement.h> +#include <LibWeb/HTML/HTMLBRElement.h> +#include <LibWeb/HTML/HTMLButtonElement.h> #include <LibWeb/HTML/HTMLCanvasElement.h> +#include <LibWeb/HTML/HTMLDataElement.h> +#include <LibWeb/HTML/HTMLDataListElement.h> +#include <LibWeb/HTML/HTMLDetailsElement.h> +#include <LibWeb/HTML/HTMLDialogElement.h> +#include <LibWeb/HTML/HTMLDivElement.h> +#include <LibWeb/HTML/HTMLDListElement.h> +#include <LibWeb/HTML/HTMLEmbedElement.h> +#include <LibWeb/HTML/HTMLFieldSetElement.h> #include <LibWeb/HTML/HTMLFontElement.h> #include <LibWeb/HTML/HTMLFormElement.h> +#include <LibWeb/HTML/HTMLFrameElement.h> +#include <LibWeb/HTML/HTMLFrameSetElement.h> #include <LibWeb/HTML/HTMLHRElement.h> #include <LibWeb/HTML/HTMLHeadElement.h> #include <LibWeb/HTML/HTMLHeadingElement.h> @@ -39,14 +54,47 @@ #include <LibWeb/HTML/HTMLIFrameElement.h> #include <LibWeb/HTML/HTMLImageElement.h> #include <LibWeb/HTML/HTMLInputElement.h> +#include <LibWeb/HTML/HTMLLabelElement.h> +#include <LibWeb/HTML/HTMLLegendElement.h> +#include <LibWeb/HTML/HTMLLIElement.h> #include <LibWeb/HTML/HTMLLinkElement.h> +#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/HTMLObjectElement.h> +#include <LibWeb/HTML/HTMLOListElement.h> +#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> #include <LibWeb/HTML/HTMLScriptElement.h> +#include <LibWeb/HTML/HTMLSelectElement.h> +#include <LibWeb/HTML/HTMLSlotElement.h> +#include <LibWeb/HTML/HTMLSourceElement.h> +#include <LibWeb/HTML/HTMLSpanElement.h> #include <LibWeb/HTML/HTMLStyleElement.h> +#include <LibWeb/HTML/HTMLTableCaptionElement.h> #include <LibWeb/HTML/HTMLTableCellElement.h> +#include <LibWeb/HTML/HTMLTableColElement.h> #include <LibWeb/HTML/HTMLTableElement.h> #include <LibWeb/HTML/HTMLTableRowElement.h> +#include <LibWeb/HTML/HTMLTableSectionElement.h> +#include <LibWeb/HTML/HTMLTextAreaElement.h> +#include <LibWeb/HTML/HTMLTemplateElement.h> +#include <LibWeb/HTML/HTMLTimeElement.h> +#include <LibWeb/HTML/HTMLTrackElement.h> #include <LibWeb/HTML/HTMLTitleElement.h> +#include <LibWeb/HTML/HTMLUListElement.h> +#include <LibWeb/HTML/HTMLUnknownElement.h> +#include <LibWeb/HTML/HTMLVideoElement.h> #include <LibWeb/SVG/SVGPathElement.h> #include <LibWeb/SVG/SVGSVGElement.h> #include <LibWeb/SVG/TagNames.h> @@ -58,53 +106,155 @@ NonnullRefPtr<Element> create_element(Document& document, const FlyString& tag_n auto lowercase_tag_name = tag_name.to_lowercase(); if (lowercase_tag_name == HTML::TagNames::a) return adopt(*new HTML::HTMLAnchorElement(document, lowercase_tag_name)); - if (lowercase_tag_name == HTML::TagNames::html) - return adopt(*new HTML::HTMLHtmlElement(document, lowercase_tag_name)); - if (lowercase_tag_name == HTML::TagNames::head) - return adopt(*new HTML::HTMLHeadElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::area) + return adopt(*new HTML::HTMLAreaElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::audio) + return adopt(*new HTML::HTMLAudioElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::base) + return adopt(*new HTML::HTMLBaseElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::blink) + return adopt(*new HTML::HTMLBlinkElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::body) return adopt(*new HTML::HTMLBodyElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::br) + return adopt(*new HTML::HTMLBRElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::button) + return adopt(*new HTML::HTMLButtonElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::canvas) + return adopt(*new HTML::HTMLCanvasElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::data) + return adopt(*new HTML::HTMLDataElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::datalist) + return adopt(*new HTML::HTMLDataListElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::details) + return adopt(*new HTML::HTMLDetailsElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::dialog) + return adopt(*new HTML::HTMLDialogElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::div) + return adopt(*new HTML::HTMLDivElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::dl) + return adopt(*new HTML::HTMLDListElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::embed) + return adopt(*new HTML::HTMLEmbedElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::fieldset) + return adopt(*new HTML::HTMLFieldSetElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::font) return adopt(*new HTML::HTMLFontElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::form) + return adopt(*new HTML::HTMLFormElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::frame) + return adopt(*new HTML::HTMLFrameElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::frameset) + return adopt(*new HTML::HTMLFrameSetElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::head) + return adopt(*new HTML::HTMLHeadElement(document, lowercase_tag_name)); + 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)) + return adopt(*new HTML::HTMLHeadingElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::hr) return adopt(*new HTML::HTMLHRElement(document, lowercase_tag_name)); - if (lowercase_tag_name == HTML::TagNames::style) - return adopt(*new HTML::HTMLStyleElement(document, lowercase_tag_name)); - if (lowercase_tag_name == HTML::TagNames::title) - return adopt(*new HTML::HTMLTitleElement(document, lowercase_tag_name)); - if (lowercase_tag_name == HTML::TagNames::link) - return adopt(*new HTML::HTMLLinkElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::html) + return adopt(*new HTML::HTMLHtmlElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::iframe) + return adopt(*new HTML::HTMLIFrameElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::img) return adopt(*new HTML::HTMLImageElement(document, lowercase_tag_name)); - if (lowercase_tag_name == HTML::TagNames::blink) - return adopt(*new HTML::HTMLBlinkElement(document, lowercase_tag_name)); - if (lowercase_tag_name == HTML::TagNames::form) - return adopt(*new HTML::HTMLFormElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::input) return adopt(*new HTML::HTMLInputElement(document, lowercase_tag_name)); - if (lowercase_tag_name == HTML::TagNames::br) - return adopt(*new HTML::HTMLBRElement(document, lowercase_tag_name)); - if (lowercase_tag_name == HTML::TagNames::iframe) - return adopt(*new HTML::HTMLIFrameElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::label) + return adopt(*new HTML::HTMLLabelElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::legend) + return adopt(*new HTML::HTMLLegendElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::li) + return adopt(*new HTML::HTMLLIElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::link) + return adopt(*new HTML::HTMLLinkElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::map) + return adopt(*new HTML::HTMLMapElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::marquee) + return adopt(*new HTML::HTMLMarqueeElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::menu) + return adopt(*new HTML::HTMLMenuElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::meta) + return adopt(*new HTML::HTMLMetaElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::meter) + return adopt(*new HTML::HTMLMeterElement(document, lowercase_tag_name)); + if (lowercase_tag_name.is_one_of(HTML::TagNames::ins, HTML::TagNames::del)) + return adopt(*new HTML::HTMLModElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::object) + return adopt(*new HTML::HTMLObjectElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::ol) + return adopt(*new HTML::HTMLOListElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::optgroup) + return adopt(*new HTML::HTMLOptGroupElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::option) + return adopt(*new HTML::HTMLOptionElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::output) + return adopt(*new HTML::HTMLOutputElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::p) + return adopt(*new HTML::HTMLParagraphElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::param) + return adopt(*new HTML::HTMLParamElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::picture) + return adopt(*new HTML::HTMLPictureElement(document, lowercase_tag_name)); + // 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)) + return adopt(*new HTML::HTMLPreElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::progress) + return adopt(*new HTML::HTMLProgressElement(document, lowercase_tag_name)); + if (lowercase_tag_name.is_one_of(HTML::TagNames::blockquote, HTML::TagNames::q)) + return adopt(*new HTML::HTMLQuoteElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::script) + return adopt(*new HTML::HTMLScriptElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::select) + return adopt(*new HTML::HTMLSelectElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::slot) + return adopt(*new HTML::HTMLSlotElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::source) + return adopt(*new HTML::HTMLSourceElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::span) + return adopt(*new HTML::HTMLSpanElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::style) + return adopt(*new HTML::HTMLStyleElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::caption) + return adopt(*new HTML::HTMLTableCaptionElement(document, lowercase_tag_name)); + if (lowercase_tag_name.is_one_of(Web::HTML::TagNames::td, Web::HTML::TagNames::th)) + return adopt(*new HTML::HTMLTableCellElement(document, lowercase_tag_name)); + if (lowercase_tag_name.is_one_of(HTML::TagNames::colgroup, HTML::TagNames::col)) + return adopt(*new HTML::HTMLTableColElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::table) return adopt(*new HTML::HTMLTableElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::tr) return adopt(*new HTML::HTMLTableRowElement(document, lowercase_tag_name)); - if (lowercase_tag_name == HTML::TagNames::td || lowercase_tag_name == HTML::TagNames::th) - return adopt(*new HTML::HTMLTableCellElement(document, lowercase_tag_name)); - 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)) - return adopt(*new HTML::HTMLHeadingElement(document, lowercase_tag_name)); - if (lowercase_tag_name == HTML::TagNames::script) - return adopt(*new HTML::HTMLScriptElement(document, lowercase_tag_name)); - if (lowercase_tag_name == HTML::TagNames::canvas) - return adopt(*new HTML::HTMLCanvasElement(document, lowercase_tag_name)); - if (lowercase_tag_name == HTML::TagNames::object) - return adopt(*new HTML::HTMLObjectElement(document, lowercase_tag_name)); + if (lowercase_tag_name.is_one_of(HTML::TagNames::tbody, HTML::TagNames::thead, HTML::TagNames::tfoot)) + return adopt(*new HTML::HTMLTableSectionElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::template_) + return adopt(*new HTML::HTMLTemplateElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::textarea) + return adopt(*new HTML::HTMLTextAreaElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::time) + return adopt(*new HTML::HTMLTimeElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::title) + return adopt(*new HTML::HTMLTitleElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::track) + return adopt(*new HTML::HTMLTrackElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::ul) + return adopt(*new HTML::HTMLUListElement(document, lowercase_tag_name)); + if (lowercase_tag_name == HTML::TagNames::video) + return adopt(*new HTML::HTMLVideoElement(document, lowercase_tag_name)); + if (lowercase_tag_name.is_one_of( + 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) + ) + return adopt(*new HTML::HTMLElement(document, lowercase_tag_name)); if (lowercase_tag_name == SVG::TagNames::svg) return adopt(*new SVG::SVGSVGElement(document, lowercase_tag_name)); if (lowercase_tag_name == SVG::TagNames::path) return adopt(*new SVG::SVGPathElement(document, lowercase_tag_name)); - return adopt(*new Element(document, lowercase_tag_name)); + + // FIXME: If name is a valid custom element name, then return HTMLElement. + + return adopt(*new HTML::HTMLUnknownElement(document, lowercase_tag_name)); } } diff --git a/Libraries/LibWeb/DOM/Node.h b/Libraries/LibWeb/DOM/Node.h index 1e23180806..5fb56d2c11 100644 --- a/Libraries/LibWeb/DOM/Node.h +++ b/Libraries/LibWeb/DOM/Node.h @@ -95,6 +95,7 @@ public: String child_text_content() const; virtual bool is_html_element() const { return false; } + virtual bool is_unknown_html_element() const { return false; } const Node* root() const; bool is_connected() const; diff --git a/Libraries/LibWeb/DOM/TagNames.h b/Libraries/LibWeb/DOM/TagNames.h index ae5f632d1d..7db11b7107 100644 --- a/Libraries/LibWeb/DOM/TagNames.h +++ b/Libraries/LibWeb/DOM/TagNames.h @@ -36,14 +36,19 @@ void initialize(); #define ENUMERATE_HTML_TAGS \ __ENUMERATE_HTML_TAG(a) \ + __ENUMERATE_HTML_TAG(abbr) \ + __ENUMERATE_HTML_TAG(acronym) \ __ENUMERATE_HTML_TAG(address) \ __ENUMERATE_HTML_TAG(applet) \ __ENUMERATE_HTML_TAG(area) \ __ENUMERATE_HTML_TAG(article) \ __ENUMERATE_HTML_TAG(aside) \ + __ENUMERATE_HTML_TAG(audio) \ __ENUMERATE_HTML_TAG(b) \ __ENUMERATE_HTML_TAG(base) \ __ENUMERATE_HTML_TAG(basefont) \ + __ENUMERATE_HTML_TAG(bdi) \ + __ENUMERATE_HTML_TAG(bdo) \ __ENUMERATE_HTML_TAG(bgsound) \ __ENUMERATE_HTML_TAG(big) \ __ENUMERATE_HTML_TAG(blink) \ @@ -54,11 +59,16 @@ void initialize(); __ENUMERATE_HTML_TAG(canvas) \ __ENUMERATE_HTML_TAG(caption) \ __ENUMERATE_HTML_TAG(center) \ + __ENUMERATE_HTML_TAG(cite) \ __ENUMERATE_HTML_TAG(code) \ __ENUMERATE_HTML_TAG(col) \ __ENUMERATE_HTML_TAG(colgroup) \ + __ENUMERATE_HTML_TAG(data) \ + __ENUMERATE_HTML_TAG(datalist) \ __ENUMERATE_HTML_TAG(dd) \ + __ENUMERATE_HTML_TAG(del) \ __ENUMERATE_HTML_TAG(details) \ + __ENUMERATE_HTML_TAG(dfn) \ __ENUMERATE_HTML_TAG(dialog) \ __ENUMERATE_HTML_TAG(dir) \ __ENUMERATE_HTML_TAG(div) \ @@ -90,15 +100,22 @@ void initialize(); __ENUMERATE_HTML_TAG(image) \ __ENUMERATE_HTML_TAG(img) \ __ENUMERATE_HTML_TAG(input) \ + __ENUMERATE_HTML_TAG(ins) \ + __ENUMERATE_HTML_TAG(kbd) \ __ENUMERATE_HTML_TAG(keygen) \ + __ENUMERATE_HTML_TAG(label) \ + __ENUMERATE_HTML_TAG(legend) \ __ENUMERATE_HTML_TAG(li) \ __ENUMERATE_HTML_TAG(link) \ __ENUMERATE_HTML_TAG(listing) \ __ENUMERATE_HTML_TAG(main) \ + __ENUMERATE_HTML_TAG(map) \ + __ENUMERATE_HTML_TAG(mark) \ __ENUMERATE_HTML_TAG(marquee) \ __ENUMERATE_HTML_TAG(math) \ __ENUMERATE_HTML_TAG(menu) \ __ENUMERATE_HTML_TAG(meta) \ + __ENUMERATE_HTML_TAG(meter) \ __ENUMERATE_HTML_TAG(nav) \ __ENUMERATE_HTML_TAG(nobr) \ __ENUMERATE_HTML_TAG(noembed) \ @@ -108,26 +125,34 @@ void initialize(); __ENUMERATE_HTML_TAG(ol) \ __ENUMERATE_HTML_TAG(optgroup) \ __ENUMERATE_HTML_TAG(option) \ + __ENUMERATE_HTML_TAG(output) \ __ENUMERATE_HTML_TAG(p) \ __ENUMERATE_HTML_TAG(param) \ + __ENUMERATE_HTML_TAG(picture) \ __ENUMERATE_HTML_TAG(path) \ __ENUMERATE_HTML_TAG(plaintext) \ __ENUMERATE_HTML_TAG(pre) \ + __ENUMERATE_HTML_TAG(progress) \ + __ENUMERATE_HTML_TAG(q) \ __ENUMERATE_HTML_TAG(ruby) \ __ENUMERATE_HTML_TAG(rb) \ __ENUMERATE_HTML_TAG(rp) \ __ENUMERATE_HTML_TAG(rt) \ __ENUMERATE_HTML_TAG(rtc) \ __ENUMERATE_HTML_TAG(s) \ + __ENUMERATE_HTML_TAG(samp) \ __ENUMERATE_HTML_TAG(script) \ __ENUMERATE_HTML_TAG(section) \ __ENUMERATE_HTML_TAG(select) \ + __ENUMERATE_HTML_TAG(slot) \ __ENUMERATE_HTML_TAG(small) \ __ENUMERATE_HTML_TAG(source) \ __ENUMERATE_HTML_TAG(span) \ __ENUMERATE_HTML_TAG(strike) \ __ENUMERATE_HTML_TAG(strong) \ __ENUMERATE_HTML_TAG(style) \ + __ENUMERATE_HTML_TAG(sub) \ + __ENUMERATE_HTML_TAG(sup) \ __ENUMERATE_HTML_TAG(summary) \ __ENUMERATE_HTML_TAG(svg) \ __ENUMERATE_HTML_TAG(table) \ @@ -138,12 +163,15 @@ void initialize(); __ENUMERATE_HTML_TAG(tfoot) \ __ENUMERATE_HTML_TAG(th) \ __ENUMERATE_HTML_TAG(thead) \ + __ENUMERATE_HTML_TAG(time) \ __ENUMERATE_HTML_TAG(title) \ __ENUMERATE_HTML_TAG(tr) \ __ENUMERATE_HTML_TAG(track) \ __ENUMERATE_HTML_TAG(tt) \ __ENUMERATE_HTML_TAG(u) \ __ENUMERATE_HTML_TAG(ul) \ + __ENUMERATE_HTML_TAG(var) \ + __ENUMERATE_HTML_TAG(video) \ __ENUMERATE_HTML_TAG(wbr) \ __ENUMERATE_HTML_TAG(xmp) diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h index c11dcfc033..3be40219b7 100644 --- a/Libraries/LibWeb/Forward.h +++ b/Libraries/LibWeb/Forward.h @@ -55,15 +55,77 @@ enum class QuirksMode; namespace Web::HTML { class CanvasRenderingContext2D; class HTMLAnchorElement; +class HTMLAreaElement; +class HTMLAudioElement; +class HTMLBaseElement; +class HTMLBlinkElement; class HTMLBodyElement; +class HTMLBRElement; +class HTMLButtonElement; class HTMLCanvasElement; +class HTMLDataElement; +class HTMLDataListElement; +class HTMLDetailsElement; +class HTMLDialogElement; +class HTMLDivElement; +class HTMLDListElement; class HTMLDocumentParser; class HTMLElement; +class HTMLEmbedElement; +class HTMLFieldSetElement; +class HTMLFontElement; class HTMLFormElement; +class HTMLFrameElement; +class HTMLFrameSetElement; class HTMLHeadElement; +class HTMLHeadingElement; +class HTMLHRElement; class HTMLHtmlElement; +class HTMLIFrameElement; class HTMLImageElement; +class HTMLInputElement; +class HTMLLabelElement; +class HTMLLegendElement; +class HTMLLIElement; +class HTMLLinkElement; +class HTMLMapElement; +class HTMLMarqueeElement; +class HTMLMediaElement; +class HTMLMenuElement; +class HTMLMetaElement; +class HTMLMeterElement; +class HTMLModElement; +class HTMLObjectElement; +class HTMLOListElement; +class HTMLOptGroupElement; +class HTMLOptionElement; +class HTMLOutputElement; +class HTMLParagraphElement; +class HTMLParamElement; +class HTMLPictureElement; +class HTMLPreElement; +class HTMLProgressElement; +class HTMLQuoteElement; class HTMLScriptElement; +class HTMLSelectElement; +class HTMLSlotElement; +class HTMLSourceElement; +class HTMLSpanElement; +class HTMLStyleElement; +class HTMLTableCaptionElement; +class HTMLTableCellElement; +class HTMLTableColElement; +class HTMLTableElement; +class HTMLTableRowElement; +class HTMLTableSectionElement; +class HTMLTemplateElement; +class HTMLTextAreaElement; +class HTMLTimeElement; +class HTMLTitleElement; +class HTMLTrackElement; +class HTMLUListElement; +class HTMLUnknownElement; +class HTMLVideoElement; class ImageData; } @@ -99,11 +161,25 @@ class EventListenerWrapper; class EventTargetWrapper; class EventWrapper; class HTMLAnchorElementWrapper; -class HTMLBRElementWrapper; +class HTMLAreaElementWrapper; +class HTMLAudioElementWrapper; +class HTMLBaseElementWrapper; class HTMLBodyElementWrapper; +class HTMLBRElementWrapper; +class HTMLButtonElementWrapper; class HTMLCanvasElementWrapper; +class HTMLDataElementWrapper; +class HTMLDataListElementWrapper; +class HTMLDetailsElementWrapper; +class HTMLDialogElementWrapper; +class HTMLDivElementWrapper; +class HTMLDListElementWrapper; class HTMLElementWrapper; +class HTMLEmbedElementWrapper; +class HTMLFieldSetElementWrapper; class HTMLFormElementWrapper; +class HTMLFrameElementWrapper; +class HTMLFrameSetElementWrapper; class HTMLHRElementWrapper; class HTMLHeadElementWrapper; class HTMLHeadingElementWrapper; @@ -111,14 +187,48 @@ class HTMLHtmlElementWrapper; class HTMLIFrameElementWrapper; class HTMLImageElementWrapper; class HTMLInputElementWrapper; +class HTMLLabelElementWrapper; +class HTMLLegendElementWrapper; +class HTMLLIElementWrapper; class HTMLLinkElementWrapper; +class HTMLMapElementWrapper; +class HTMLMarqueeElementWrapper; +class HTMLMediaElementWrapper; +class HTMLMenuElementWrapper; +class HTMLMetaElementWrapper; +class HTMLMeterElementWrapper; +class HTMLModElementWrapper; class HTMLObjectElementWrapper; +class HTMLOListElementWrapper; +class HTMLOptGroupElementWrapper; +class HTMLOptionElementWrapper; +class HTMLOutputElementWrapper; +class HTMLParagraphElementWrapper; +class HTMLParamElementWrapper; +class HTMLPictureElementWrapper; +class HTMLPreElementWrapper; +class HTMLProgressElementWrapper; +class HTMLQuoteElementWrapper; class HTMLScriptElementWrapper; +class HTMLSelectElementWrapper; +class HTMLSlotElementWrapper; +class HTMLSourceElementWrapper; +class HTMLSpanElementWrapper; class HTMLStyleElementWrapper; +class HTMLTableCaptionElementWrapper; class HTMLTableCellElementWrapper; +class HTMLTableColElementWrapper; class HTMLTableElementWrapper; class HTMLTableRowElementWrapper; +class HTMLTableSectionElementWrapper; +class HTMLTemplateElementWrapper; +class HTMLTextAreaElementWrapper; +class HTMLTimeElementWrapper; class HTMLTitleElementWrapper; +class HTMLTrackElementWrapper; +class HTMLUListElementWrapper; +class HTMLUnknownElementWrapper; +class HTMLVideoElementWrapper; class ImageDataWrapper; class LocationObject; class MouseEventWrapper; diff --git a/Libraries/LibWeb/HTML/HTMLFormElement.idl b/Libraries/LibWeb/HTML/HTMLFormElement.idl index fabc85f18b..810b167de1 100644 --- a/Libraries/LibWeb/HTML/HTMLFormElement.idl +++ b/Libraries/LibWeb/HTML/HTMLFormElement.idl @@ -2,5 +2,6 @@ interface HTMLFormElement : HTMLElement { [Reflect] attribute DOMString name; [Reflect] attribute DOMString rel; + [Reflect=accept-charset] attribute DOMString acceptCharset; } diff --git a/Libraries/LibWeb/HTML/HTMLMetaElement.idl b/Libraries/LibWeb/HTML/HTMLMetaElement.idl index 436dcf01ae..96ce93b65d 100644 --- a/Libraries/LibWeb/HTML/HTMLMetaElement.idl +++ b/Libraries/LibWeb/HTML/HTMLMetaElement.idl @@ -2,5 +2,6 @@ interface HTMLMetaElement : HTMLElement { [Reflect] attribute DOMString name; [Reflect] attribute DOMString content; + [Reflect=http-equiv] attribute DOMString httpEquiv; } diff --git a/Libraries/LibWeb/HTML/HTMLPreElement.h b/Libraries/LibWeb/HTML/HTMLPreElement.h index 2dfd4dad4b..d145a0ffec 100644 --- a/Libraries/LibWeb/HTML/HTMLPreElement.h +++ b/Libraries/LibWeb/HTML/HTMLPreElement.h @@ -41,5 +41,5 @@ public: } AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLPreElement) -static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast<Web::HTML::HTMLElement>(node).local_name().is_one_of(Web::HTML::TagNames::pre, Web::HTML::TagNames::listing, Web::HTML::TagNames::xmp); } +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast<Web::HTML::HTMLElement>(node).local_name() == Web::HTML::TagNames::pre; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLUnknownElement.h b/Libraries/LibWeb/HTML/HTMLUnknownElement.h index cf338027af..5dd7cfdc50 100644 --- a/Libraries/LibWeb/HTML/HTMLUnknownElement.h +++ b/Libraries/LibWeb/HTML/HTMLUnknownElement.h @@ -36,12 +36,13 @@ public: HTMLUnknownElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLUnknownElement() override; + +private: + virtual bool is_unknown_html_element() const final { return true; } }; } AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLUnknownElement) -// FIXME: I'm not sure what the check for this should be. -// There are some elements which are explicitly mapped to HTMLUnknownElement, but other than that, it's for, well, unknown elements. -static bool is_type(const Web::DOM::Node& node) { return node.is_html_element(); } +static bool is_type(const Web::DOM::Node& node) { return node.is_unknown_html_element(); } AK_END_TYPE_TRAITS() |