LibWeb: Add the MathML Element
This patch introduces the MathML element, which provides the interface all MathML elements are built from.
This commit is contained in:
parent
cce50b1841
commit
52d6df5ee5
Notes:
sideshowbarker
2024-07-17 01:28:15 +09:00
Author: https://github.com/Epigenetic Commit: https://github.com/SerenityOS/serenity/commit/52d6df5ee5 Pull-request: https://github.com/SerenityOS/serenity/pull/20269 Reviewed-by: https://github.com/AtkinsSJ
6 changed files with 78 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -497,6 +497,10 @@ enum class LayoutMode;
|
|||
struct LayoutState;
|
||||
}
|
||||
|
||||
namespace Web::MathML {
|
||||
class MathMLElement;
|
||||
}
|
||||
|
||||
namespace Web::MimeSniff {
|
||||
class MimeType;
|
||||
}
|
||||
|
|
27
Userland/Libraries/LibWeb/MathML/MathMLElement.cpp
Normal file
27
Userland/Libraries/LibWeb/MathML/MathMLElement.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Jonah Shafran <jonahshafran@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||
#include <LibWeb/MathML/MathMLElement.h>
|
||||
|
||||
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<Bindings::MathMLElementPrototype>(realm, "MathMLElement"));
|
||||
|
||||
m_dataset = MUST(HTML::DOMStringMap::create(*this));
|
||||
}
|
||||
|
||||
}
|
36
Userland/Libraries/LibWeb/MathML/MathMLElement.h
Normal file
36
Userland/Libraries/LibWeb/MathML/MathMLElement.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Jonah Shafran <jonahshafran@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/HTML/DOMStringMap.h>
|
||||
#include <LibWeb/HTML/GlobalEventHandlers.h>
|
||||
|
||||
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<HTML::DOMStringMap> m_dataset;
|
||||
};
|
||||
|
||||
}
|
9
Userland/Libraries/LibWeb/MathML/MathMLElement.idl
Normal file
9
Userland/Libraries/LibWeb/MathML/MathMLElement.idl
Normal file
|
@ -0,0 +1,9 @@
|
|||
#import <DOM/Element.idl>
|
||||
#import <DOM/EventHandler.idl>
|
||||
#import <HTML/HTMLElement.idl>
|
||||
|
||||
// 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
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue