diff --git a/Libraries/LibWeb/Bindings/HTMLImageElementWrapper.cpp b/Libraries/LibWeb/Bindings/HTMLImageElementWrapper.cpp new file mode 100644 index 0000000000..67d128c5db --- /dev/null +++ b/Libraries/LibWeb/Bindings/HTMLImageElementWrapper.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2020, Andreas Kling + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include + +namespace Web { +namespace Bindings { + +HTMLImageElementWrapper::HTMLImageElementWrapper(HTMLImageElement& element) + : ElementWrapper(element) +{ +} + +HTMLImageElementWrapper::~HTMLImageElementWrapper() +{ +} + +HTMLImageElement& HTMLImageElementWrapper::node() +{ + return static_cast(NodeWrapper::node()); +} + +const HTMLImageElement& HTMLImageElementWrapper::node() const +{ + return static_cast(NodeWrapper::node()); +} + +} +} diff --git a/Libraries/LibWeb/Bindings/HTMLImageElementWrapper.h b/Libraries/LibWeb/Bindings/HTMLImageElementWrapper.h new file mode 100644 index 0000000000..bbadc7c228 --- /dev/null +++ b/Libraries/LibWeb/Bindings/HTMLImageElementWrapper.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2020, Andreas Kling + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include + +namespace Web { +namespace Bindings { + +class HTMLImageElementWrapper : public ElementWrapper { +public: + explicit HTMLImageElementWrapper(HTMLImageElement&); + virtual ~HTMLImageElementWrapper() override; + + HTMLImageElement& node(); + const HTMLImageElement& node() const; + +private: + virtual const char* class_name() const override { return "HTMLImageElementWrapper"; } +}; + +} +} diff --git a/Libraries/LibWeb/Bindings/NodeWrapper.cpp b/Libraries/LibWeb/Bindings/NodeWrapper.cpp index 289a5c69f2..b62d7bceb8 100644 --- a/Libraries/LibWeb/Bindings/NodeWrapper.cpp +++ b/Libraries/LibWeb/Bindings/NodeWrapper.cpp @@ -29,9 +29,11 @@ #include #include #include +#include #include #include #include +#include #include namespace Web { @@ -43,6 +45,8 @@ NodeWrapper* wrap(JS::Heap& heap, Node& node) return static_cast(wrap_impl(heap, to(node))); if (is(node)) return static_cast(wrap_impl(heap, to(node))); + if (is(node)) + return static_cast(wrap_impl(heap, to(node))); if (is(node)) return static_cast(wrap_impl(heap, to(node))); return static_cast(wrap_impl(heap, node)); diff --git a/Libraries/LibWeb/DOM/HTMLImageElement.h b/Libraries/LibWeb/DOM/HTMLImageElement.h index 46056f9d93..f56850004e 100644 --- a/Libraries/LibWeb/DOM/HTMLImageElement.h +++ b/Libraries/LibWeb/DOM/HTMLImageElement.h @@ -36,6 +36,8 @@ class LayoutDocument; class HTMLImageElement : public HTMLElement { public: + using WrapperType = Bindings::HTMLImageElementWrapper; + HTMLImageElement(Document&, const FlyString& tag_name); virtual ~HTMLImageElement() override; diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h index 6c82e1f345..c75815c3da 100644 --- a/Libraries/LibWeb/Forward.h +++ b/Libraries/LibWeb/Forward.h @@ -40,6 +40,7 @@ class HTMLCanvasElement; class HTMLElement; class HTMLHeadElement; class HTMLHtmlElement; +class HTMLImageElement; class HtmlView; class LayoutDocument; class LayoutNode; @@ -62,6 +63,7 @@ class EventWrapper; class EventListenerWrapper; class EventTargetWrapper; class HTMLCanvasElementWrapper; +class HTMLImageElementWrapper; class MouseEventWrapper; class NodeWrapper; class WindowObject; diff --git a/Libraries/LibWeb/Makefile b/Libraries/LibWeb/Makefile index 13d7a6c8ea..63bcd6432d 100644 --- a/Libraries/LibWeb/Makefile +++ b/Libraries/LibWeb/Makefile @@ -6,6 +6,7 @@ LIBWEB_OBJS = \ Bindings/EventListenerWrapper.o \ Bindings/EventTargetWrapper.o \ Bindings/HTMLCanvasElementWrapper.o \ + Bindings/HTMLImageElementWrapper.o \ Bindings/MouseEventWrapper.o \ Bindings/NavigatorObject.o \ Bindings/NodeWrapper.o \