diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index d9f62a2000..26d13ad672 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -450,6 +450,7 @@ set(SOURCES Loader/ProxyMappings.cpp Loader/Resource.cpp Loader/ResourceLoader.cpp + MathML/MathMLElement.cpp MimeSniff/MimeType.cpp Namespace.cpp NavigationTiming/EntryNames.cpp diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index 6237a38cd9..2bab4b6c8e 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -497,6 +497,10 @@ enum class LayoutMode; struct LayoutState; } +namespace Web::MathML { +class MathMLElement; +} + namespace Web::MimeSniff { class MimeType; } diff --git a/Userland/Libraries/LibWeb/MathML/MathMLElement.cpp b/Userland/Libraries/LibWeb/MathML/MathMLElement.cpp new file mode 100644 index 0000000000..039341a0d7 --- /dev/null +++ b/Userland/Libraries/LibWeb/MathML/MathMLElement.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023, Jonah Shafran + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include + +namespace Web::MathML { + +MathMLElement::~MathMLElement() = default; + +MathMLElement::MathMLElement(DOM::Document& document, DOM::QualifiedName qualified_name) + : DOM::Element(document, move(qualified_name)) +{ +} + +void MathMLElement::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype(realm, "MathMLElement")); + + m_dataset = MUST(HTML::DOMStringMap::create(*this)); +} + +} diff --git a/Userland/Libraries/LibWeb/MathML/MathMLElement.h b/Userland/Libraries/LibWeb/MathML/MathMLElement.h new file mode 100644 index 0000000000..fb076f42ea --- /dev/null +++ b/Userland/Libraries/LibWeb/MathML/MathMLElement.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023, Jonah Shafran + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include +#include + +namespace Web::MathML { + +class MathMLElement : public DOM::Element + , public HTML::GlobalEventHandlers { + WEB_PLATFORM_OBJECT(MathMLElement, Element); + +public: + virtual ~MathMLElement() override; + + HTML::DOMStringMap* dataset() { return m_dataset.ptr(); } + HTML::DOMStringMap const* dataset() const { return m_dataset.ptr(); } + +protected: + virtual DOM::EventTarget& global_event_handlers_to_event_target(FlyString const&) override { return *this; } + +private: + MathMLElement(DOM::Document&, DOM::QualifiedName); + + virtual void initialize(JS::Realm&) override; + + JS::GCPtr m_dataset; +}; + +} diff --git a/Userland/Libraries/LibWeb/MathML/MathMLElement.idl b/Userland/Libraries/LibWeb/MathML/MathMLElement.idl new file mode 100644 index 0000000000..3e12dd7211 --- /dev/null +++ b/Userland/Libraries/LibWeb/MathML/MathMLElement.idl @@ -0,0 +1,9 @@ +#import +#import +#import + +// https://w3c.github.io/mathml-core/#dom-and-javascript +[Exposed=Window] +interface MathMLElement : Element { }; +MathMLElement includes GlobalEventHandlers; +MathMLElement includes HTMLOrSVGElement; // FIXME: We technically use HTMLOrForeignElement which is a rename of HTMLOrSVGElement, when that change is upstreamed we should update here diff --git a/Userland/Libraries/LibWeb/idl_files.cmake b/Userland/Libraries/LibWeb/idl_files.cmake index 53295dbe21..473fe9308c 100644 --- a/Userland/Libraries/LibWeb/idl_files.cmake +++ b/Userland/Libraries/LibWeb/idl_files.cmake @@ -187,6 +187,7 @@ libweb_js_bindings(HighResolutionTime/Performance) libweb_js_bindings(Internals/Internals) libweb_js_bindings(IntersectionObserver/IntersectionObserver) libweb_js_bindings(IntersectionObserver/IntersectionObserverEntry) +libweb_js_bindings(MathML/MathMLElement) libweb_js_bindings(NavigationTiming/PerformanceTiming) libweb_js_bindings(PerformanceTimeline/PerformanceEntry) libweb_js_bindings(RequestIdleCallback/IdleDeadline)