diff --git a/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp b/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp index d87eb2b73fd..70bfd61bf8f 100644 --- a/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp +++ b/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp @@ -24,17 +24,18 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include +#include #include -#include #include +#include #include #include #include +#include #include #include -#include #include #include #include @@ -48,15 +49,17 @@ #include #include #include +#include #include +#include #include -#include #include +#include #include #include +#include #include #include -#include #include #include #include @@ -69,7 +72,6 @@ #include #include #include -#include namespace Web { namespace Bindings { @@ -124,6 +126,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))); return static_cast(wrap_impl(global_object, node)); } diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index 30e91f641ad..8e3f621152b 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -25,6 +25,7 @@ set(SOURCES CSS/StyleValue.cpp DOM/AttributeNames.cpp DOM/CharacterData.cpp + DOM/CharacterData.idl DOM/Comment.cpp DOM/Document.cpp DOM/DocumentType.cpp @@ -37,6 +38,7 @@ set(SOURCES DOM/Position.cpp DOM/TagNames.cpp DOM/Text.cpp + DOM/Text.idl DOM/Timer.cpp DOM/Window.cpp DOM/XMLHttpRequest.cpp @@ -162,12 +164,14 @@ function(libweb_js_wrapper class) add_custom_target(generate_${basename}Wrapper.cpp DEPENDS Bindings/${class}Wrapper.cpp) endfunction() +libweb_js_wrapper(DOM/CharacterData) libweb_js_wrapper(DOM/Document) libweb_js_wrapper(DOM/DocumentType) libweb_js_wrapper(DOM/Element) libweb_js_wrapper(DOM/Event) libweb_js_wrapper(DOM/EventTarget) libweb_js_wrapper(DOM/Node) +libweb_js_wrapper(DOM/Text) libweb_js_wrapper(HTML/CanvasRenderingContext2D) libweb_js_wrapper(HTML/HTMLAnchorElement) libweb_js_wrapper(HTML/HTMLBodyElement) diff --git a/Libraries/LibWeb/DOM/CharacterData.h b/Libraries/LibWeb/DOM/CharacterData.h index 55688f2e6ea..9204487e27a 100644 --- a/Libraries/LibWeb/DOM/CharacterData.h +++ b/Libraries/LibWeb/DOM/CharacterData.h @@ -36,11 +36,15 @@ class CharacterData : public Node , public NonDocumentTypeChildNode { public: + using WrapperType = Bindings::CharacterDataWrapper; + virtual ~CharacterData() override; const String& data() const { return m_data; } void set_data(const String& data) { m_data = data; } + unsigned length() const { return m_data.length(); } + virtual String text_content() const override { return m_data; } protected: diff --git a/Libraries/LibWeb/DOM/CharacterData.idl b/Libraries/LibWeb/DOM/CharacterData.idl new file mode 100644 index 00000000000..a076806fe1f --- /dev/null +++ b/Libraries/LibWeb/DOM/CharacterData.idl @@ -0,0 +1,9 @@ +interface CharacterData : Node { + + attribute DOMString data; + readonly attribute unsigned long length; + + readonly attribute Element? nextElementSibling; + readonly attribute Element? previousElementSibling; + +} diff --git a/Libraries/LibWeb/DOM/Text.h b/Libraries/LibWeb/DOM/Text.h index 5ef79d73292..8ba78b7179d 100644 --- a/Libraries/LibWeb/DOM/Text.h +++ b/Libraries/LibWeb/DOM/Text.h @@ -34,6 +34,8 @@ namespace Web::DOM { class Text final : public CharacterData { public: + using WrapperType = Bindings::TextWrapper; + explicit Text(Document&, const String&); virtual ~Text() override; diff --git a/Libraries/LibWeb/DOM/Text.idl b/Libraries/LibWeb/DOM/Text.idl new file mode 100644 index 00000000000..7377e93e29d --- /dev/null +++ b/Libraries/LibWeb/DOM/Text.idl @@ -0,0 +1,3 @@ +interface Text : CharacterData { + +} diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h index 0e386470bdd..c11dcfc033a 100644 --- a/Libraries/LibWeb/Forward.h +++ b/Libraries/LibWeb/Forward.h @@ -91,6 +91,7 @@ class XMLHttpRequest; namespace Web::Bindings { class CanvasRenderingContext2DWrapper; +class CharacterDataWrapper; class DocumentTypeWrapper; class DocumentWrapper; class ElementWrapper; @@ -122,6 +123,7 @@ class ImageDataWrapper; class LocationObject; class MouseEventWrapper; class NodeWrapper; +class TextWrapper; class UIEventWrapper; class WindowObject; class Wrappable;