diff options
author | Luke <luke.wilde@live.co.uk> | 2020-07-27 05:04:26 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-27 19:51:45 +0200 |
commit | a2b40de0cc902a71666b1b1034f103e6a8b69c7d (patch) | |
tree | a4463252693917e3a67ab22e269c1e686a2241c0 | |
parent | db1b67e88a1ff9758b3a1cb58e99b35330e4b038 (diff) | |
download | serenity-a2b40de0cc902a71666b1b1034f103e6a8b69c7d.zip |
LibWeb: Add a whole bunch of HTML DOM bindings
Note that these aren't full implementations of the bindings. This
mostly implements the low hanging fruit (namely, basic reflections)
There are some attributes that should be USVString instead of
DOMString. However, USVString is a slightly different definition
of DOMString, so it should suffice for now.
44 files changed, 327 insertions, 29 deletions
diff --git a/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp b/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp index b280016749..f7c9cc8dbb 100644 --- a/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp +++ b/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp @@ -26,13 +26,49 @@ #include <LibWeb/Bindings/DocumentWrapper.h> #include <LibWeb/Bindings/DocumentTypeWrapper.h> +#include <LibWeb/Bindings/HTMLAnchorElementWrapper.h> +#include <LibWeb/Bindings/HTMLBodyElementWrapper.h> +#include <LibWeb/Bindings/HTMLBRElementWrapper.h> #include <LibWeb/Bindings/HTMLCanvasElementWrapper.h> -#include <LibWeb/Bindings/HTMLImageElementWrapper.h> #include <LibWeb/Bindings/HTMLElementWrapper.h> +#include <LibWeb/Bindings/HTMLFormElementWrapper.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/HTMLLinkElementWrapper.h> +#include <LibWeb/Bindings/HTMLObjectElementWrapper.h> +#include <LibWeb/Bindings/HTMLScriptElementWrapper.h> +#include <LibWeb/Bindings/HTMLStyleElementWrapper.h> +#include <LibWeb/Bindings/HTMLTableCellElementWrapper.h> +#include <LibWeb/Bindings/HTMLTableElementWrapper.h> +#include <LibWeb/Bindings/HTMLTableRowElementWrapper.h> +#include <LibWeb/Bindings/HTMLTitleElementWrapper.h> #include <LibWeb/Bindings/NodeWrapper.h> #include <LibWeb/DOM/Document.h> +#include <LibWeb/HTML/HTMLAnchorElement.h> +#include <LibWeb/HTML/HTMLBodyElement.h> +#include <LibWeb/HTML/HTMLBRElement.h> #include <LibWeb/HTML/HTMLCanvasElement.h> +#include <LibWeb/HTML/HTMLFormElement.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/HTMLLinkElement.h> +#include <LibWeb/HTML/HTMLObjectElement.h> +#include <LibWeb/HTML/HTMLScriptElement.h> +#include <LibWeb/HTML/HTMLStyleElement.h> +#include <LibWeb/HTML/HTMLTableCellElement.h> +#include <LibWeb/HTML/HTMLTableElement.h> +#include <LibWeb/HTML/HTMLTableRowElement.h> +#include <LibWeb/HTML/HTMLTitleElement.h> #include <LibWeb/DOM/Node.h> namespace Web { @@ -44,10 +80,46 @@ NodeWrapper* wrap(JS::GlobalObject& global_object, DOM::Node& node) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<DOM::Document>(node))); if (is<DOM::DocumentType>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<DOM::DocumentType>(node))); + if (is<HTMLAnchorElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLAnchorElement>(node))); + if (is<HTMLBodyElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLBodyElement>(node))); + if (is<HTMLBRElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLBRElement>(node))); if (is<HTMLCanvasElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLCanvasElement>(node))); + if (is<HTMLFormElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLFormElement>(node))); + if (is<HTMLHeadElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLHeadElement>(node))); + if (is<HTMLHeadingElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLHeadingElement>(node))); + if (is<HTMLHRElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLHRElement>(node))); + if (is<HTMLHtmlElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLHtmlElement>(node))); + if (is<HTMLIFrameElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLIFrameElement>(node))); if (is<HTMLImageElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLImageElement>(node))); + if (is<HTMLInputElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLInputElement>(node))); + if (is<HTMLLinkElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLLinkElement>(node))); + if (is<HTMLObjectElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLObjectElement>(node))); + if (is<HTMLScriptElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLScriptElement>(node))); + if (is<HTMLStyleElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLStyleElement>(node))); + if (is<HTMLTableCellElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLTableCellElement>(node))); + if (is<HTMLTableElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLTableElement>(node))); + if (is<HTMLTableRowElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLTableRowElement>(node))); + if (is<HTMLTitleElement>(node)) + return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLTitleElement>(node))); if (is<HTMLElement>(node)) return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLElement>(node))); if (is<DOM::Element>(node)) diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index 24be8f4c35..704d0a040d 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -169,9 +169,27 @@ libweb_js_wrapper(DOM/EventTarget) libweb_js_wrapper(DOM/MouseEvent) libweb_js_wrapper(DOM/Node) libweb_js_wrapper(HTML/CanvasRenderingContext2D) +libweb_js_wrapper(HTML/HTMLAnchorElement) +libweb_js_wrapper(HTML/HTMLBodyElement) +libweb_js_wrapper(HTML/HTMLBRElement) libweb_js_wrapper(HTML/HTMLCanvasElement) libweb_js_wrapper(HTML/HTMLElement) +libweb_js_wrapper(HTML/HTMLFormElement) +libweb_js_wrapper(HTML/HTMLHeadElement) +libweb_js_wrapper(HTML/HTMLHeadingElement) +libweb_js_wrapper(HTML/HTMLHRElement) +libweb_js_wrapper(HTML/HTMLHtmlElement) +libweb_js_wrapper(HTML/HTMLIFrameElement) libweb_js_wrapper(HTML/HTMLImageElement) +libweb_js_wrapper(HTML/HTMLInputElement) +libweb_js_wrapper(HTML/HTMLLinkElement) +libweb_js_wrapper(HTML/HTMLObjectElement) +libweb_js_wrapper(HTML/HTMLScriptElement) +libweb_js_wrapper(HTML/HTMLStyleElement) +libweb_js_wrapper(HTML/HTMLTableCellElement) +libweb_js_wrapper(HTML/HTMLTableElement) +libweb_js_wrapper(HTML/HTMLTableRowElement) +libweb_js_wrapper(HTML/HTMLTitleElement) libweb_js_wrapper(HTML/ImageData) get_property(WRAPPER_SOURCES GLOBAL PROPERTY wrapper_sources) diff --git a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp index e24d29d52a..4d2375c0f6 100644 --- a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp +++ b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp @@ -481,6 +481,7 @@ void generate_implementation(const IDL::Interface& interface) out() << "#include <LibWeb/DOM/Element.h>"; out() << "#include <LibWeb/HTML/HTMLElement.h>"; out() << "#include <LibWeb/DOM/EventListener.h>"; + out() << "#include <LibWeb/Bindings/DocumentWrapper.h>"; out() << "#include <LibWeb/Bindings/DocumentTypeWrapper.h>"; out() << "#include <LibWeb/Bindings/HTMLCanvasElementWrapper.h>"; out() << "#include <LibWeb/Bindings/HTMLImageElementWrapper.h>"; diff --git a/Libraries/LibWeb/DOM/AttributeNames.h b/Libraries/LibWeb/DOM/AttributeNames.h index 4bad355a78..4f45cde8c6 100644 --- a/Libraries/LibWeb/DOM/AttributeNames.h +++ b/Libraries/LibWeb/DOM/AttributeNames.h @@ -34,30 +34,51 @@ namespace AttributeNames { void initialize(); -#define ENUMERATE_HTML_ATTRIBUTES \ - __ENUMERATE_HTML_ATTRIBUTE(action) \ - __ENUMERATE_HTML_ATTRIBUTE(align) \ - __ENUMERATE_HTML_ATTRIBUTE(alt) \ - __ENUMERATE_HTML_ATTRIBUTE(async) \ - __ENUMERATE_HTML_ATTRIBUTE(bgcolor) \ - __ENUMERATE_HTML_ATTRIBUTE(class_) \ - __ENUMERATE_HTML_ATTRIBUTE(colspan) \ - __ENUMERATE_HTML_ATTRIBUTE(data) \ - __ENUMERATE_HTML_ATTRIBUTE(defer) \ - __ENUMERATE_HTML_ATTRIBUTE(height) \ - __ENUMERATE_HTML_ATTRIBUTE(href) \ - __ENUMERATE_HTML_ATTRIBUTE(id) \ - __ENUMERATE_HTML_ATTRIBUTE(lang) \ - __ENUMERATE_HTML_ATTRIBUTE(method) \ - __ENUMERATE_HTML_ATTRIBUTE(name) \ - __ENUMERATE_HTML_ATTRIBUTE(rel) \ - __ENUMERATE_HTML_ATTRIBUTE(size) \ - __ENUMERATE_HTML_ATTRIBUTE(src) \ - __ENUMERATE_HTML_ATTRIBUTE(style) \ - __ENUMERATE_HTML_ATTRIBUTE(target) \ - __ENUMERATE_HTML_ATTRIBUTE(title) \ - __ENUMERATE_HTML_ATTRIBUTE(type) \ - __ENUMERATE_HTML_ATTRIBUTE(value) \ +#define ENUMERATE_HTML_ATTRIBUTES \ + __ENUMERATE_HTML_ATTRIBUTE(abbr) \ + __ENUMERATE_HTML_ATTRIBUTE(accept) \ + __ENUMERATE_HTML_ATTRIBUTE(action) \ + __ENUMERATE_HTML_ATTRIBUTE(align) \ + __ENUMERATE_HTML_ATTRIBUTE(allow) \ + __ENUMERATE_HTML_ATTRIBUTE(alt) \ + __ENUMERATE_HTML_ATTRIBUTE(async) \ + __ENUMERATE_HTML_ATTRIBUTE(bgcolor) \ + __ENUMERATE_HTML_ATTRIBUTE(class_) \ + __ENUMERATE_HTML_ATTRIBUTE(colspan) \ + __ENUMERATE_HTML_ATTRIBUTE(data) \ + __ENUMERATE_HTML_ATTRIBUTE(download) \ + __ENUMERATE_HTML_ATTRIBUTE(defer) \ + __ENUMERATE_HTML_ATTRIBUTE(dirname) \ + __ENUMERATE_HTML_ATTRIBUTE(headers) \ + __ENUMERATE_HTML_ATTRIBUTE(height) \ + __ENUMERATE_HTML_ATTRIBUTE(href) \ + __ENUMERATE_HTML_ATTRIBUTE(hreflang) \ + __ENUMERATE_HTML_ATTRIBUTE(id) \ + __ENUMERATE_HTML_ATTRIBUTE(imagesizes) \ + __ENUMERATE_HTML_ATTRIBUTE(imagesrcset) \ + __ENUMERATE_HTML_ATTRIBUTE(integrity) \ + __ENUMERATE_HTML_ATTRIBUTE(lang) \ + __ENUMERATE_HTML_ATTRIBUTE(max) \ + __ENUMERATE_HTML_ATTRIBUTE(media) \ + __ENUMERATE_HTML_ATTRIBUTE(method) \ + __ENUMERATE_HTML_ATTRIBUTE(min) \ + __ENUMERATE_HTML_ATTRIBUTE(name) \ + __ENUMERATE_HTML_ATTRIBUTE(pattern) \ + __ENUMERATE_HTML_ATTRIBUTE(ping) \ + __ENUMERATE_HTML_ATTRIBUTE(placeholder) \ + __ENUMERATE_HTML_ATTRIBUTE(rel) \ + __ENUMERATE_HTML_ATTRIBUTE(size) \ + __ENUMERATE_HTML_ATTRIBUTE(sizes) \ + __ENUMERATE_HTML_ATTRIBUTE(src) \ + __ENUMERATE_HTML_ATTRIBUTE(srcdoc) \ + __ENUMERATE_HTML_ATTRIBUTE(srcset) \ + __ENUMERATE_HTML_ATTRIBUTE(step) \ + __ENUMERATE_HTML_ATTRIBUTE(style) \ + __ENUMERATE_HTML_ATTRIBUTE(target) \ + __ENUMERATE_HTML_ATTRIBUTE(title) \ + __ENUMERATE_HTML_ATTRIBUTE(type) \ + __ENUMERATE_HTML_ATTRIBUTE(usemap) \ + __ENUMERATE_HTML_ATTRIBUTE(value) \ __ENUMERATE_HTML_ATTRIBUTE(width) #define __ENUMERATE_HTML_ATTRIBUTE(name) extern FlyString name; diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h index c82afaace0..c3de704746 100644 --- a/Libraries/LibWeb/Forward.h +++ b/Libraries/LibWeb/Forward.h @@ -93,9 +93,27 @@ class ElementWrapper; class EventWrapper; class EventListenerWrapper; class EventTargetWrapper; +class HTMLAnchorElementWrapper; +class HTMLBodyElementWrapper; +class HTMLBRElementWrapper; class HTMLCanvasElementWrapper; class HTMLElementWrapper; +class HTMLFormElementWrapper; +class HTMLHeadElementWrapper; +class HTMLHeadingElementWrapper; +class HTMLHRElementWrapper; +class HTMLHtmlElementWrapper; +class HTMLIFrameElementWrapper; class HTMLImageElementWrapper; +class HTMLInputElementWrapper; +class HTMLLinkElementWrapper; +class HTMLObjectElementWrapper; +class HTMLScriptElementWrapper; +class HTMLStyleElementWrapper; +class HTMLTableCellElementWrapper; +class HTMLTableElementWrapper; +class HTMLTableRowElementWrapper; +class HTMLTitleElementWrapper; class ImageDataWrapper; class LocationObject; class MouseEventWrapper; diff --git a/Libraries/LibWeb/HTML/HTMLAnchorElement.h b/Libraries/LibWeb/HTML/HTMLAnchorElement.h index b4fb47ece3..8e4da8a7c8 100644 --- a/Libraries/LibWeb/HTML/HTMLAnchorElement.h +++ b/Libraries/LibWeb/HTML/HTMLAnchorElement.h @@ -32,6 +32,8 @@ namespace Web { class HTMLAnchorElement : public HTMLElement { public: + using WrapperType = Bindings::HTMLAnchorElementWrapper; + HTMLAnchorElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLAnchorElement() override; diff --git a/Libraries/LibWeb/HTML/HTMLAnchorElement.idl b/Libraries/LibWeb/HTML/HTMLAnchorElement.idl new file mode 100644 index 0000000000..db905a0d67 --- /dev/null +++ b/Libraries/LibWeb/HTML/HTMLAnchorElement.idl @@ -0,0 +1,10 @@ +interface HTMLAnchorElement : HTMLElement { + + [Reflect] attribute DOMString target; + [Reflect] attribute DOMString download; + [Reflect] attribute DOMString ping; + [Reflect] attribute DOMString rel; + [Reflect] attribute DOMString hreflang; + [Reflect] attribute DOMString type; + +} diff --git a/Libraries/LibWeb/HTML/HTMLBRElement.h b/Libraries/LibWeb/HTML/HTMLBRElement.h index a97fc15a06..eaded297d3 100644 --- a/Libraries/LibWeb/HTML/HTMLBRElement.h +++ b/Libraries/LibWeb/HTML/HTMLBRElement.h @@ -32,6 +32,8 @@ namespace Web { class HTMLBRElement final : public HTMLElement { public: + using WrapperType = Bindings::HTMLBRElementWrapper; + HTMLBRElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLBRElement() override; diff --git a/Libraries/LibWeb/HTML/HTMLBRElement.idl b/Libraries/LibWeb/HTML/HTMLBRElement.idl new file mode 100644 index 0000000000..e8c475d909 --- /dev/null +++ b/Libraries/LibWeb/HTML/HTMLBRElement.idl @@ -0,0 +1,5 @@ +interface HTMLBRElement : HTMLElement { + + + +} diff --git a/Libraries/LibWeb/HTML/HTMLBodyElement.h b/Libraries/LibWeb/HTML/HTMLBodyElement.h index 4c7da3db39..5e75d45535 100644 --- a/Libraries/LibWeb/HTML/HTMLBodyElement.h +++ b/Libraries/LibWeb/HTML/HTMLBodyElement.h @@ -32,6 +32,8 @@ namespace Web { class HTMLBodyElement : public HTMLElement { public: + using WrapperType = Bindings::HTMLBodyElementWrapper; + HTMLBodyElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLBodyElement() override; diff --git a/Libraries/LibWeb/HTML/HTMLBodyElement.idl b/Libraries/LibWeb/HTML/HTMLBodyElement.idl new file mode 100644 index 0000000000..7d249cff24 --- /dev/null +++ b/Libraries/LibWeb/HTML/HTMLBodyElement.idl @@ -0,0 +1,5 @@ +interface HTMLBodyElement : HTMLElement { + + + +} diff --git a/Libraries/LibWeb/HTML/HTMLFormElement.h b/Libraries/LibWeb/HTML/HTMLFormElement.h index ca0c3e6e26..286b37d8de 100644 --- a/Libraries/LibWeb/HTML/HTMLFormElement.h +++ b/Libraries/LibWeb/HTML/HTMLFormElement.h @@ -33,6 +33,8 @@ namespace Web { class HTMLFormElement : public HTMLElement { public: + using WrapperType = Bindings::HTMLFormElementWrapper; + HTMLFormElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLFormElement() override; diff --git a/Libraries/LibWeb/HTML/HTMLFormElement.idl b/Libraries/LibWeb/HTML/HTMLFormElement.idl new file mode 100644 index 0000000000..fabc85f18b --- /dev/null +++ b/Libraries/LibWeb/HTML/HTMLFormElement.idl @@ -0,0 +1,6 @@ +interface HTMLFormElement : HTMLElement { + + [Reflect] attribute DOMString name; + [Reflect] attribute DOMString rel; + +} diff --git a/Libraries/LibWeb/HTML/HTMLHRElement.h b/Libraries/LibWeb/HTML/HTMLHRElement.h index 12c72e406d..94340e3742 100644 --- a/Libraries/LibWeb/HTML/HTMLHRElement.h +++ b/Libraries/LibWeb/HTML/HTMLHRElement.h @@ -32,6 +32,8 @@ namespace Web { class HTMLHRElement : public HTMLElement { public: + using WrapperType = Bindings::HTMLHRElementWrapper; + HTMLHRElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLHRElement() override; }; diff --git a/Libraries/LibWeb/HTML/HTMLHRElement.idl b/Libraries/LibWeb/HTML/HTMLHRElement.idl new file mode 100644 index 0000000000..25a7e57878 --- /dev/null +++ b/Libraries/LibWeb/HTML/HTMLHRElement.idl @@ -0,0 +1,5 @@ +interface HTMLHRElement : HTMLElement { + + + +} diff --git a/Libraries/LibWeb/HTML/HTMLHeadElement.h b/Libraries/LibWeb/HTML/HTMLHeadElement.h index 8f2b7e9681..a074b97616 100644 --- a/Libraries/LibWeb/HTML/HTMLHeadElement.h +++ b/Libraries/LibWeb/HTML/HTMLHeadElement.h @@ -32,6 +32,8 @@ namespace Web { class HTMLHeadElement : public HTMLElement { public: + using WrapperType = Bindings::HTMLHeadElementWrapper; + HTMLHeadElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLHeadElement() override; }; diff --git a/Libraries/LibWeb/HTML/HTMLHeadElement.idl b/Libraries/LibWeb/HTML/HTMLHeadElement.idl new file mode 100644 index 0000000000..8d918327dc --- /dev/null +++ b/Libraries/LibWeb/HTML/HTMLHeadElement.idl @@ -0,0 +1,5 @@ +interface HTMLHeadElement : HTMLElement { + + + +} diff --git a/Libraries/LibWeb/HTML/HTMLHeadingElement.h b/Libraries/LibWeb/HTML/HTMLHeadingElement.h index 0cf80fdb41..f042af1662 100644 --- a/Libraries/LibWeb/HTML/HTMLHeadingElement.h +++ b/Libraries/LibWeb/HTML/HTMLHeadingElement.h @@ -32,8 +32,14 @@ namespace Web { class HTMLHeadingElement : public HTMLElement { public: + using WrapperType = Bindings::HTMLHeadingElementWrapper; + HTMLHeadingElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLHeadingElement() override; }; } + +AK_BEGIN_TYPE_TRAITS(Web::HTMLHeadingElement) +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name().is_one_of(Web::HTML::TagNames::h1, Web::HTML::TagNames::h2, Web::HTML::TagNames::h3, Web::HTML::TagNames::h4, Web::HTML::TagNames::h5, Web::HTML::TagNames::h6); } +AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLHeadingElement.idl b/Libraries/LibWeb/HTML/HTMLHeadingElement.idl new file mode 100644 index 0000000000..961f6d4dd1 --- /dev/null +++ b/Libraries/LibWeb/HTML/HTMLHeadingElement.idl @@ -0,0 +1,5 @@ +interface HTMLHeadingElement : HTMLElement { + + + +} diff --git a/Libraries/LibWeb/HTML/HTMLHtmlElement.h b/Libraries/LibWeb/HTML/HTMLHtmlElement.h index a99cc73cdb..c06ce9957e 100644 --- a/Libraries/LibWeb/HTML/HTMLHtmlElement.h +++ b/Libraries/LibWeb/HTML/HTMLHtmlElement.h @@ -32,6 +32,8 @@ namespace Web { class HTMLHtmlElement : public HTMLElement { public: + using WrapperType = Bindings::HTMLHtmlElementWrapper; + HTMLHtmlElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLHtmlElement() override; }; diff --git a/Libraries/LibWeb/HTML/HTMLHtmlElement.idl b/Libraries/LibWeb/HTML/HTMLHtmlElement.idl new file mode 100644 index 0000000000..9e882145ca --- /dev/null +++ b/Libraries/LibWeb/HTML/HTMLHtmlElement.idl @@ -0,0 +1,5 @@ +interface HTMLHtmlElement : HTMLElement { + + + +} diff --git a/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index fe577a899b..3922ebd9ff 100644 --- a/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -82,7 +82,7 @@ void HTMLIFrameElement::load_src(const String& value) m_hosted_frame->loader().load(url, FrameLoader::Type::IFrame); } -const DOM::Document* HTMLIFrameElement::hosted_document() const +const DOM::Document* HTMLIFrameElement::content_document() const { return m_hosted_frame ? m_hosted_frame->document() : nullptr; } diff --git a/Libraries/LibWeb/HTML/HTMLIFrameElement.h b/Libraries/LibWeb/HTML/HTMLIFrameElement.h index ea915698e2..015e65b314 100644 --- a/Libraries/LibWeb/HTML/HTMLIFrameElement.h +++ b/Libraries/LibWeb/HTML/HTMLIFrameElement.h @@ -32,6 +32,8 @@ namespace Web { class HTMLIFrameElement final : public HTMLElement { public: + using WrapperType = Bindings::HTMLIFrameElementWrapper; + HTMLIFrameElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLIFrameElement() override; @@ -40,7 +42,7 @@ public: Frame* hosted_frame() { return m_hosted_frame; } const Frame* hosted_frame() const { return m_hosted_frame; } - const DOM::Document* hosted_document() const; + const DOM::Document* content_document() const; private: virtual void document_did_attach_to_frame(Frame&) override; diff --git a/Libraries/LibWeb/HTML/HTMLIFrameElement.idl b/Libraries/LibWeb/HTML/HTMLIFrameElement.idl new file mode 100644 index 0000000000..97513c966c --- /dev/null +++ b/Libraries/LibWeb/HTML/HTMLIFrameElement.idl @@ -0,0 +1,12 @@ +interface HTMLIFrameElement : HTMLElement { + + [Reflect] attribute DOMString src; + [Reflect] attribute DOMString srcdoc; + [Reflect] attribute DOMString name; + [Reflect] attribute DOMString allow; + [Reflect] attribute DOMString width; + [Reflect] attribute DOMString height; + + readonly attribute Document? contentDocument; + +} diff --git a/Libraries/LibWeb/HTML/HTMLImageElement.idl b/Libraries/LibWeb/HTML/HTMLImageElement.idl index 4b1edafd5f..f1ffbbcfe4 100644 --- a/Libraries/LibWeb/HTML/HTMLImageElement.idl +++ b/Libraries/LibWeb/HTML/HTMLImageElement.idl @@ -2,5 +2,8 @@ interface HTMLImageElement : HTMLElement { [Reflect] attribute DOMString src; [Reflect] attribute DOMString alt; + [Reflect] attribute DOMString srcset; + [Reflect] attribute DOMString sizes; + [Reflect=usemap] attribute DOMString useMap; } diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.h b/Libraries/LibWeb/HTML/HTMLInputElement.h index 3004e78545..ebb399f29d 100644 --- a/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -32,6 +32,8 @@ namespace Web { class HTMLInputElement : public HTMLElement { public: + using WrapperType = Bindings::HTMLInputElementWrapper; + HTMLInputElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLInputElement() override; diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.idl b/Libraries/LibWeb/HTML/HTMLInputElement.idl new file mode 100644 index 0000000000..84004409e8 --- /dev/null +++ b/Libraries/LibWeb/HTML/HTMLInputElement.idl @@ -0,0 +1,14 @@ +interface HTMLInputElement : HTMLElement { + + [Reflect] attribute DOMString accept; + [Reflect] attribute DOMString alt; + [Reflect] attribute DOMString max; + [Reflect] attribute DOMString min; + [Reflect] attribute DOMString pattern; + [Reflect] attribute DOMString placeholder; + [Reflect] attribute DOMString src; + [Reflect] attribute DOMString step; + [Reflect=dirname] attribute DOMString dirName; + [Reflect=value] attribute DOMString defaultValue; + +} diff --git a/Libraries/LibWeb/HTML/HTMLLinkElement.h b/Libraries/LibWeb/HTML/HTMLLinkElement.h index 691ce9e233..eec0f9c347 100644 --- a/Libraries/LibWeb/HTML/HTMLLinkElement.h +++ b/Libraries/LibWeb/HTML/HTMLLinkElement.h @@ -35,6 +35,8 @@ class HTMLLinkElement final : public HTMLElement , public ResourceClient { public: + using WrapperType = Bindings::HTMLLinkElementWrapper; + HTMLLinkElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLLinkElement() override; diff --git a/Libraries/LibWeb/HTML/HTMLLinkElement.idl b/Libraries/LibWeb/HTML/HTMLLinkElement.idl new file mode 100644 index 0000000000..f96c5e8bd9 --- /dev/null +++ b/Libraries/LibWeb/HTML/HTMLLinkElement.idl @@ -0,0 +1,12 @@ +interface HTMLLinkElement : HTMLElement { + + [Reflect] attribute DOMString href; + [Reflect] attribute DOMString hreflang; + [Reflect] attribute DOMString integrity; + [Reflect] attribute DOMString media; + [Reflect] attribute DOMString rel; + [Reflect] attribute DOMString type; + [Reflect=imagesrcset] attribute DOMString imageSrcset; + [Reflect=imagesizes] attribute DOMString imageSizes; + +} diff --git a/Libraries/LibWeb/HTML/HTMLObjectElement.h b/Libraries/LibWeb/HTML/HTMLObjectElement.h index c3dc7e7e8f..c21111e51c 100644 --- a/Libraries/LibWeb/HTML/HTMLObjectElement.h +++ b/Libraries/LibWeb/HTML/HTMLObjectElement.h @@ -37,6 +37,8 @@ class LayoutDocument; class HTMLObjectElement final : public HTMLElement { public: + using WrapperType = Bindings::HTMLObjectElementWrapper; + HTMLObjectElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLObjectElement() override; diff --git a/Libraries/LibWeb/HTML/HTMLObjectElement.idl b/Libraries/LibWeb/HTML/HTMLObjectElement.idl new file mode 100644 index 0000000000..bb7444ab74 --- /dev/null +++ b/Libraries/LibWeb/HTML/HTMLObjectElement.idl @@ -0,0 +1,8 @@ +interface HTMLObjectElement : HTMLElement { + + [Reflect] attribute DOMString data; + [Reflect] attribute DOMString type; + [Reflect] attribute DOMString name; + [Reflect=usemap] attribute DOMString useMap; + +} diff --git a/Libraries/LibWeb/HTML/HTMLScriptElement.h b/Libraries/LibWeb/HTML/HTMLScriptElement.h index 9cb0fa953e..f9d3ab885a 100644 --- a/Libraries/LibWeb/HTML/HTMLScriptElement.h +++ b/Libraries/LibWeb/HTML/HTMLScriptElement.h @@ -33,6 +33,8 @@ namespace Web { class HTMLScriptElement : public HTMLElement { public: + using WrapperType = Bindings::HTMLScriptElementWrapper; + HTMLScriptElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLScriptElement() override; diff --git a/Libraries/LibWeb/HTML/HTMLScriptElement.idl b/Libraries/LibWeb/HTML/HTMLScriptElement.idl new file mode 100644 index 0000000000..93675f7219 --- /dev/null +++ b/Libraries/LibWeb/HTML/HTMLScriptElement.idl @@ -0,0 +1,7 @@ +interface HTMLScriptElement : HTMLElement { + + [Reflect] attribute DOMString src; + [Reflect] attribute DOMString type; + [Reflect] attribute DOMString integrity; + +} diff --git a/Libraries/LibWeb/HTML/HTMLStyleElement.h b/Libraries/LibWeb/HTML/HTMLStyleElement.h index c4b2b2a9f9..cb8b64eba5 100644 --- a/Libraries/LibWeb/HTML/HTMLStyleElement.h +++ b/Libraries/LibWeb/HTML/HTMLStyleElement.h @@ -32,6 +32,8 @@ namespace Web { class HTMLStyleElement : public HTMLElement { public: + using WrapperType = Bindings::HTMLStyleElementWrapper; + HTMLStyleElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLStyleElement() override; diff --git a/Libraries/LibWeb/HTML/HTMLStyleElement.idl b/Libraries/LibWeb/HTML/HTMLStyleElement.idl new file mode 100644 index 0000000000..71450d086c --- /dev/null +++ b/Libraries/LibWeb/HTML/HTMLStyleElement.idl @@ -0,0 +1,5 @@ +interface HTMLStyleElement : HTMLElement { + + [Reflect] attribute DOMString media; + +} diff --git a/Libraries/LibWeb/HTML/HTMLTableCellElement.h b/Libraries/LibWeb/HTML/HTMLTableCellElement.h index 3b02504b5c..648e982f98 100644 --- a/Libraries/LibWeb/HTML/HTMLTableCellElement.h +++ b/Libraries/LibWeb/HTML/HTMLTableCellElement.h @@ -32,6 +32,8 @@ namespace Web { class HTMLTableCellElement final : public HTMLElement { public: + using WrapperType = Bindings::HTMLTableCellElementWrapper; + HTMLTableCellElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLTableCellElement() override; @@ -42,5 +44,5 @@ private: } AK_BEGIN_TYPE_TRAITS(Web::HTMLTableCellElement) -static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::td; } +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name().is_one_of(Web::HTML::TagNames::td, Web::HTML::TagNames::th); } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLTableCellElement.idl b/Libraries/LibWeb/HTML/HTMLTableCellElement.idl new file mode 100644 index 0000000000..077fe037b9 --- /dev/null +++ b/Libraries/LibWeb/HTML/HTMLTableCellElement.idl @@ -0,0 +1,6 @@ +interface HTMLTableCellElement : HTMLElement { + + [Reflect] attribute DOMString headers; + [Reflect] attribute DOMString abbr; + +} diff --git a/Libraries/LibWeb/HTML/HTMLTableElement.h b/Libraries/LibWeb/HTML/HTMLTableElement.h index 12cacc565a..c87c5f9726 100644 --- a/Libraries/LibWeb/HTML/HTMLTableElement.h +++ b/Libraries/LibWeb/HTML/HTMLTableElement.h @@ -32,6 +32,8 @@ namespace Web { class HTMLTableElement final : public HTMLElement { public: + using WrapperType = Bindings::HTMLTableElementWrapper; + HTMLTableElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLTableElement() override; diff --git a/Libraries/LibWeb/HTML/HTMLTableElement.idl b/Libraries/LibWeb/HTML/HTMLTableElement.idl new file mode 100644 index 0000000000..4e4120ad8f --- /dev/null +++ b/Libraries/LibWeb/HTML/HTMLTableElement.idl @@ -0,0 +1,5 @@ +interface HTMLTableElement : HTMLElement { + + + +} diff --git a/Libraries/LibWeb/HTML/HTMLTableRowElement.h b/Libraries/LibWeb/HTML/HTMLTableRowElement.h index 8ea764b262..e211555727 100644 --- a/Libraries/LibWeb/HTML/HTMLTableRowElement.h +++ b/Libraries/LibWeb/HTML/HTMLTableRowElement.h @@ -32,6 +32,8 @@ namespace Web { class HTMLTableRowElement : public HTMLElement { public: + using WrapperType = Bindings::HTMLTableRowElementWrapper; + HTMLTableRowElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLTableRowElement() override; }; diff --git a/Libraries/LibWeb/HTML/HTMLTableRowElement.idl b/Libraries/LibWeb/HTML/HTMLTableRowElement.idl new file mode 100644 index 0000000000..ced8c32162 --- /dev/null +++ b/Libraries/LibWeb/HTML/HTMLTableRowElement.idl @@ -0,0 +1,5 @@ +interface HTMLTableRowElement : HTMLElement { + + + +} diff --git a/Libraries/LibWeb/HTML/HTMLTitleElement.h b/Libraries/LibWeb/HTML/HTMLTitleElement.h index 3b820738bf..b0bd70b4ec 100644 --- a/Libraries/LibWeb/HTML/HTMLTitleElement.h +++ b/Libraries/LibWeb/HTML/HTMLTitleElement.h @@ -32,6 +32,8 @@ namespace Web { class HTMLTitleElement : public HTMLElement { public: + using WrapperType = Bindings::HTMLTitleElementWrapper; + HTMLTitleElement(DOM::Document&, const FlyString& local_name); virtual ~HTMLTitleElement() override; }; diff --git a/Libraries/LibWeb/HTML/HTMLTitleElement.idl b/Libraries/LibWeb/HTML/HTMLTitleElement.idl new file mode 100644 index 0000000000..745e8757d3 --- /dev/null +++ b/Libraries/LibWeb/HTML/HTMLTitleElement.idl @@ -0,0 +1,5 @@ +interface HTMLTitleElement : HTMLElement { + + + +} diff --git a/Libraries/LibWeb/Layout/LayoutFrame.cpp b/Libraries/LibWeb/Layout/LayoutFrame.cpp index ae980b0ff7..2246982bcb 100644 --- a/Libraries/LibWeb/Layout/LayoutFrame.cpp +++ b/Libraries/LibWeb/Layout/LayoutFrame.cpp @@ -64,7 +64,7 @@ void LayoutFrame::paint(PaintContext& context, PaintPhase phase) LayoutReplaced::paint(context, phase); if (phase == PaintPhase::Foreground) { - auto* hosted_document = node().hosted_document(); + auto* hosted_document = node().content_document(); if (!hosted_document) return; auto* hosted_layout_tree = hosted_document->layout_node(); |