From a2b40de0cc902a71666b1b1034f103e6a8b69c7d Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 27 Jul 2020 05:04:26 +0100 Subject: [PATCH] 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. --- .../LibWeb/Bindings/NodeWrapperFactory.cpp | 74 ++++++++++++++++++- Libraries/LibWeb/CMakeLists.txt | 18 +++++ .../CodeGenerators/WrapperGenerator.cpp | 1 + Libraries/LibWeb/DOM/AttributeNames.h | 69 +++++++++++------ Libraries/LibWeb/Forward.h | 18 +++++ Libraries/LibWeb/HTML/HTMLAnchorElement.h | 2 + Libraries/LibWeb/HTML/HTMLAnchorElement.idl | 10 +++ Libraries/LibWeb/HTML/HTMLBRElement.h | 2 + Libraries/LibWeb/HTML/HTMLBRElement.idl | 5 ++ Libraries/LibWeb/HTML/HTMLBodyElement.h | 2 + Libraries/LibWeb/HTML/HTMLBodyElement.idl | 5 ++ Libraries/LibWeb/HTML/HTMLFormElement.h | 2 + Libraries/LibWeb/HTML/HTMLFormElement.idl | 6 ++ Libraries/LibWeb/HTML/HTMLHRElement.h | 2 + Libraries/LibWeb/HTML/HTMLHRElement.idl | 5 ++ Libraries/LibWeb/HTML/HTMLHeadElement.h | 2 + Libraries/LibWeb/HTML/HTMLHeadElement.idl | 5 ++ Libraries/LibWeb/HTML/HTMLHeadingElement.h | 6 ++ Libraries/LibWeb/HTML/HTMLHeadingElement.idl | 5 ++ Libraries/LibWeb/HTML/HTMLHtmlElement.h | 2 + Libraries/LibWeb/HTML/HTMLHtmlElement.idl | 5 ++ Libraries/LibWeb/HTML/HTMLIFrameElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLIFrameElement.h | 4 +- Libraries/LibWeb/HTML/HTMLIFrameElement.idl | 12 +++ Libraries/LibWeb/HTML/HTMLImageElement.idl | 3 + Libraries/LibWeb/HTML/HTMLInputElement.h | 2 + Libraries/LibWeb/HTML/HTMLInputElement.idl | 14 ++++ Libraries/LibWeb/HTML/HTMLLinkElement.h | 2 + Libraries/LibWeb/HTML/HTMLLinkElement.idl | 12 +++ Libraries/LibWeb/HTML/HTMLObjectElement.h | 2 + Libraries/LibWeb/HTML/HTMLObjectElement.idl | 8 ++ Libraries/LibWeb/HTML/HTMLScriptElement.h | 2 + Libraries/LibWeb/HTML/HTMLScriptElement.idl | 7 ++ Libraries/LibWeb/HTML/HTMLStyleElement.h | 2 + Libraries/LibWeb/HTML/HTMLStyleElement.idl | 5 ++ Libraries/LibWeb/HTML/HTMLTableCellElement.h | 4 +- .../LibWeb/HTML/HTMLTableCellElement.idl | 6 ++ Libraries/LibWeb/HTML/HTMLTableElement.h | 2 + Libraries/LibWeb/HTML/HTMLTableElement.idl | 5 ++ Libraries/LibWeb/HTML/HTMLTableRowElement.h | 2 + Libraries/LibWeb/HTML/HTMLTableRowElement.idl | 5 ++ Libraries/LibWeb/HTML/HTMLTitleElement.h | 2 + Libraries/LibWeb/HTML/HTMLTitleElement.idl | 5 ++ Libraries/LibWeb/Layout/LayoutFrame.cpp | 2 +- 44 files changed, 327 insertions(+), 29 deletions(-) create mode 100644 Libraries/LibWeb/HTML/HTMLAnchorElement.idl create mode 100644 Libraries/LibWeb/HTML/HTMLBRElement.idl create mode 100644 Libraries/LibWeb/HTML/HTMLBodyElement.idl create mode 100644 Libraries/LibWeb/HTML/HTMLFormElement.idl create mode 100644 Libraries/LibWeb/HTML/HTMLHRElement.idl create mode 100644 Libraries/LibWeb/HTML/HTMLHeadElement.idl create mode 100644 Libraries/LibWeb/HTML/HTMLHeadingElement.idl create mode 100644 Libraries/LibWeb/HTML/HTMLHtmlElement.idl create mode 100644 Libraries/LibWeb/HTML/HTMLIFrameElement.idl create mode 100644 Libraries/LibWeb/HTML/HTMLInputElement.idl create mode 100644 Libraries/LibWeb/HTML/HTMLLinkElement.idl create mode 100644 Libraries/LibWeb/HTML/HTMLObjectElement.idl create mode 100644 Libraries/LibWeb/HTML/HTMLScriptElement.idl create mode 100644 Libraries/LibWeb/HTML/HTMLStyleElement.idl create mode 100644 Libraries/LibWeb/HTML/HTMLTableCellElement.idl create mode 100644 Libraries/LibWeb/HTML/HTMLTableElement.idl create mode 100644 Libraries/LibWeb/HTML/HTMLTableRowElement.idl create mode 100644 Libraries/LibWeb/HTML/HTMLTitleElement.idl diff --git a/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp b/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp index b280016749a..f7c9cc8dbbe 100644 --- a/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp +++ b/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp @@ -26,13 +26,49 @@ #include #include +#include +#include +#include #include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include namespace Web { @@ -44,10 +80,46 @@ NodeWrapper* wrap(JS::GlobalObject& global_object, DOM::Node& node) return static_cast(wrap_impl(global_object, downcast(node))); if (is(node)) return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); if (is(node)) return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); if (is(node)) return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); if (is(node)) return static_cast(wrap_impl(global_object, downcast(node))); if (is(node)) diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index 24be8f4c352..704d0a040df 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 e24d29d52ae..4d2375c0f64 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 "; out() << "#include "; out() << "#include "; + out() << "#include "; out() << "#include "; out() << "#include "; out() << "#include "; diff --git a/Libraries/LibWeb/DOM/AttributeNames.h b/Libraries/LibWeb/DOM/AttributeNames.h index 4bad355a78a..4f45cde8c6e 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 c82afaace06..c3de7047469 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 b4fb47ece3c..8e4da8a7c8d 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 00000000000..db905a0d67c --- /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 a97fc15a069..eaded297d3c 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 00000000000..e8c475d9098 --- /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 4c7da3db39e..5e75d455353 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 00000000000..7d249cff248 --- /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 ca0c3e6e26a..286b37d8def 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 00000000000..fabc85f18bb --- /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 12c72e406d1..94340e37425 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 00000000000..25a7e578789 --- /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 8f2b7e96818..a074b97616e 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 00000000000..8d918327dca --- /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 0cf80fdb419..f042af16628 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(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 00000000000..961f6d4dd1c --- /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 a99cc73cdb3..c06ce9957e9 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 00000000000..9e882145ca9 --- /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 fe577a899b5..3922ebd9ffd 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 ea915698e2a..015e65b3143 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 00000000000..97513c966ce --- /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 4b1edafd5ff..f1ffbbcfe45 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 3004e785457..ebb399f29d8 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 00000000000..84004409e81 --- /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 691ce9e2333..eec0f9c3477 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 00000000000..f96c5e8bd97 --- /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 c3dc7e7e8fb..c21111e51c6 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 00000000000..bb7444ab74d --- /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 9cb0fa953ee..f9d3ab885a5 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 00000000000..93675f72192 --- /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 c4b2b2a9f94..cb8b64eba58 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 00000000000..71450d086c7 --- /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 3b02504b5c4..648e982f980 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(node).local_name() == Web::HTML::TagNames::td; } +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(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 00000000000..077fe037b97 --- /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 12cacc565a2..c87c5f97267 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 00000000000..4e4120ad8f7 --- /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 8ea764b262c..e2115557277 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 00000000000..ced8c321621 --- /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 3b820738bf7..b0bd70b4ec2 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 00000000000..745e8757d3f --- /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 ae980b0ff7f..2246982bcb2 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();