diff --git a/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp b/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp index 38d4ad9265..fe9acca6ff 100644 --- a/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp +++ b/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp @@ -100,6 +100,8 @@ #include #include #include +#include +#include #include #include #include @@ -170,6 +172,8 @@ #include #include #include +#include +#include namespace Web::Bindings { @@ -315,6 +319,10 @@ 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)) diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index 27fc076af6..54f8208f98 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -300,6 +300,11 @@ libweb_js_wrapper(HTML/HTMLUnknownElement) libweb_js_wrapper(HTML/HTMLVideoElement) libweb_js_wrapper(HTML/ImageData) libweb_js_wrapper(HighResolutionTime/Performance) +libweb_js_wrapper(SVG/SVGElement) +libweb_js_wrapper(SVG/SVGGeometryElement) +libweb_js_wrapper(SVG/SVGGraphicsElement) +libweb_js_wrapper(SVG/SVGPathElement) +libweb_js_wrapper(SVG/SVGSVGElement) 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 287e1488e5..b30fe7e192 100644 --- a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp +++ b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp @@ -290,7 +290,7 @@ int main(int argc, char** argv) return 1; } - if (namespace_.is_one_of("DOM", "HTML", "UIEvents", "HighResolutionTime")) { + if (namespace_.is_one_of("DOM", "HTML", "UIEvents", "HighResolutionTime", "SVG")) { StringBuilder builder; builder.append(namespace_); builder.append("::"); @@ -381,6 +381,8 @@ static void generate_header(const IDL::Interface& interface) out() << "#include "; out() << "#elif __has_include()"; out() << "#include "; + out() << "#elif __has_include()"; + out() << "#include "; out() << "#endif"; if (wrapper_base_class != "Wrapper") diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h index a8f7b2ed8a..deb84f39f2 100644 --- a/Libraries/LibWeb/Forward.h +++ b/Libraries/LibWeb/Forward.h @@ -136,6 +136,14 @@ namespace Web::HighResolutionTime { class Performance; } +namespace Web::SVG { +class SVGElement; +class SVGGeometryElement; +class SVGGraphicsElement; +class SVGPathElement; +class SVGSVGElement; +} + namespace Web { class EventHandler; class Frame; @@ -248,6 +256,11 @@ class MouseEventWrapper; class NodeWrapper; class PerformanceWrapper; class ScriptExecutionContext; +class SVGElementWrapper; +class SVGGeometryElementWrapper; +class SVGGraphicsElementWrapper; +class SVGPathElementWrapper; +class SVGSVGElementWrapper; class TextWrapper; class UIEventWrapper; class WindowObject; diff --git a/Libraries/LibWeb/SVG/SVGElement.h b/Libraries/LibWeb/SVG/SVGElement.h index 9c6c77084d..185c1db7fb 100644 --- a/Libraries/LibWeb/SVG/SVGElement.h +++ b/Libraries/LibWeb/SVG/SVGElement.h @@ -32,6 +32,8 @@ namespace Web::SVG { class SVGElement : public DOM::Element { public: + using WrapperType = Bindings::SVGElementWrapper; + virtual bool is_graphics_element() const { return false; } protected: diff --git a/Libraries/LibWeb/SVG/SVGElement.idl b/Libraries/LibWeb/SVG/SVGElement.idl new file mode 100644 index 0000000000..59b8708368 --- /dev/null +++ b/Libraries/LibWeb/SVG/SVGElement.idl @@ -0,0 +1,3 @@ +interface SVGElement : Element { + +} diff --git a/Libraries/LibWeb/SVG/SVGGeometryElement.h b/Libraries/LibWeb/SVG/SVGGeometryElement.h index 2ae4b17519..3d3e6bcd3c 100644 --- a/Libraries/LibWeb/SVG/SVGGeometryElement.h +++ b/Libraries/LibWeb/SVG/SVGGeometryElement.h @@ -32,6 +32,8 @@ namespace Web::SVG { class SVGGeometryElement : public SVGGraphicsElement { public: + using WrapperType = Bindings::SVGGeometryElementWrapper; + protected: SVGGeometryElement(DOM::Document& document, const FlyString& tag_name); }; diff --git a/Libraries/LibWeb/SVG/SVGGeometryElement.idl b/Libraries/LibWeb/SVG/SVGGeometryElement.idl new file mode 100644 index 0000000000..a895ff8602 --- /dev/null +++ b/Libraries/LibWeb/SVG/SVGGeometryElement.idl @@ -0,0 +1,3 @@ +interface SVGGeometryElement : SVGGraphicsElement { + +} diff --git a/Libraries/LibWeb/SVG/SVGGraphicsElement.h b/Libraries/LibWeb/SVG/SVGGraphicsElement.h index ddef811284..c100ce91ce 100644 --- a/Libraries/LibWeb/SVG/SVGGraphicsElement.h +++ b/Libraries/LibWeb/SVG/SVGGraphicsElement.h @@ -47,6 +47,8 @@ static const SVGPaintingContext default_painting_context = { class SVGGraphicsElement : public SVGElement { public: + using WrapperType = Bindings::SVGGraphicsElementWrapper; + SVGGraphicsElement(DOM::Document&, const FlyString& tag_name); virtual void parse_attribute(const FlyString& name, const String& value) override; diff --git a/Libraries/LibWeb/SVG/SVGGraphicsElement.idl b/Libraries/LibWeb/SVG/SVGGraphicsElement.idl new file mode 100644 index 0000000000..7d84dc562d --- /dev/null +++ b/Libraries/LibWeb/SVG/SVGGraphicsElement.idl @@ -0,0 +1,3 @@ +interface SVGGraphicsElement : SVGElement { + +} diff --git a/Libraries/LibWeb/SVG/SVGPathElement.h b/Libraries/LibWeb/SVG/SVGPathElement.h index 4091c8e53f..887d37e52f 100644 --- a/Libraries/LibWeb/SVG/SVGPathElement.h +++ b/Libraries/LibWeb/SVG/SVGPathElement.h @@ -104,6 +104,8 @@ private: class SVGPathElement final : public SVGGeometryElement { public: + using WrapperType = Bindings::SVGPathElementWrapper; + SVGPathElement(DOM::Document&, const FlyString& tag_name); virtual ~SVGPathElement() override = default; @@ -116,3 +118,7 @@ private: }; } + +AK_BEGIN_TYPE_TRAITS(Web::SVG::SVGPathElement) +static bool is_type(const Web::DOM::Node& node) { return node.is_svg_element() && downcast(node).local_name() == Web::SVG::TagNames::path; } +AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/SVG/SVGPathElement.idl b/Libraries/LibWeb/SVG/SVGPathElement.idl new file mode 100644 index 0000000000..857a7041cf --- /dev/null +++ b/Libraries/LibWeb/SVG/SVGPathElement.idl @@ -0,0 +1,3 @@ +interface SVGPathElement : SVGGeometryElement { + +} diff --git a/Libraries/LibWeb/SVG/SVGSVGElement.h b/Libraries/LibWeb/SVG/SVGSVGElement.h index f29b0028f0..2f0915fb77 100644 --- a/Libraries/LibWeb/SVG/SVGSVGElement.h +++ b/Libraries/LibWeb/SVG/SVGSVGElement.h @@ -33,6 +33,8 @@ namespace Web::SVG { class SVGSVGElement final : public SVGGraphicsElement { public: + using WrapperType = Bindings::SVGSVGElementWrapper; + SVGSVGElement(DOM::Document&, const FlyString& tag_name); virtual RefPtr create_layout_node(const CSS::StyleProperties* parent_style) override; @@ -50,3 +52,7 @@ private: }; } + +AK_BEGIN_TYPE_TRAITS(Web::SVG::SVGSVGElement) +static bool is_type(const Web::DOM::Node& node) { return node.is_svg_element() && downcast(node).local_name() == Web::SVG::TagNames::svg; } +AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/SVG/SVGSVGElement.idl b/Libraries/LibWeb/SVG/SVGSVGElement.idl new file mode 100644 index 0000000000..b36206e948 --- /dev/null +++ b/Libraries/LibWeb/SVG/SVGSVGElement.idl @@ -0,0 +1,3 @@ +interface SVGSVGElement : SVGGraphicsElement { + +}