Skip to content

Truly independent web browser

LibWeb: Create SVGMPathElement for <mpath> elements

Jelle Raaijmakers42d5aaa590b7
diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt
index c0c748a5069..61e3a66e837 100644
--- a/Libraries/LibWeb/CMakeLists.txt
+++ b/Libraries/LibWeb/CMakeLists.txt
@@ -938,6 +938,7 @@ set(SOURCES
SVG/SVGList.cpp
SVG/SVGMaskElement.cpp
SVG/SVGMetadataElement.cpp
+ SVG/SVGMPathElement.cpp
SVG/SVGNumber.cpp
SVG/SVGNumberList.cpp
SVG/SVGPathElement.cpp
diff --git a/Libraries/LibWeb/DOM/ElementFactory.cpp b/Libraries/LibWeb/DOM/ElementFactory.cpp
index 2c5e0926f51..37810011a21 100644
--- a/Libraries/LibWeb/DOM/ElementFactory.cpp
+++ b/Libraries/LibWeb/DOM/ElementFactory.cpp
@@ -125,6 +125,7 @@
#include <LibWeb/SVG/SVGImageElement.h>
#include <LibWeb/SVG/SVGLineElement.h>
#include <LibWeb/SVG/SVGLinearGradientElement.h>
+#include <LibWeb/SVG/SVGMPathElement.h>
#include <LibWeb/SVG/SVGMaskElement.h>
#include <LibWeb/SVG/SVGMetadataElement.h>
#include <LibWeb/SVG/SVGPathElement.h>
@@ -574,6 +575,8 @@ static GC::Ref<SVG::SVGElement> create_svg_element(Document& document, Qualified
return create_element_on_heap<SVG::SVGMaskElement>(document, move(qualified_name));
if (local_name == SVG::TagNames::metadata)
return create_element_on_heap<SVG::SVGMetadataElement>(document, move(qualified_name));
+ if (local_name == SVG::TagNames::mpath)
+ return create_element_on_heap<SVG::SVGMPathElement>(document, move(qualified_name));
if (local_name == SVG::TagNames::path)
return create_element_on_heap<SVG::SVGPathElement>(document, move(qualified_name));
if (local_name == SVG::TagNames::pattern)
diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h
index 92fdc276640..2947a732903 100644
--- a/Libraries/LibWeb/Forward.h
+++ b/Libraries/LibWeb/Forward.h
@@ -1177,6 +1177,7 @@ class SVGLengthList;
class SVGLineElement;
class SVGMaskElement;
class SVGMetadataElement;
+class SVGMPathElement;
class SVGNumber;
class SVGNumberList;
class SVGPathElement;
diff --git a/Libraries/LibWeb/SVG/SVGMPathElement.cpp b/Libraries/LibWeb/SVG/SVGMPathElement.cpp
new file mode 100644
index 00000000000..1ba556b8015
--- /dev/null
+++ b/Libraries/LibWeb/SVG/SVGMPathElement.cpp
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibWeb/SVG/SVGMPathElement.h>
+
+namespace Web::SVG {
+
+GC_DEFINE_ALLOCATOR(SVGMPathElement);
+
+SVGMPathElement::SVGMPathElement(DOM::Document& document, DOM::QualifiedName qualified_name)
+ : SVGElement(document, move(qualified_name))
+{
+}
+
+void SVGMPathElement::visit_edges(Cell::Visitor& visitor)
+{
+ Base::visit_edges(visitor);
+ SVGURIReferenceMixin::visit_edges(visitor);
+}
+
+}
diff --git a/Libraries/LibWeb/SVG/SVGMPathElement.h b/Libraries/LibWeb/SVG/SVGMPathElement.h
new file mode 100644
index 00000000000..cea796fd182
--- /dev/null
+++ b/Libraries/LibWeb/SVG/SVGMPathElement.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <LibWeb/SVG/SVGElement.h>
+#include <LibWeb/SVG/SVGURIReference.h>
+
+namespace Web::SVG {
+
+class SVGMPathElement final
+ : public SVGElement
+ , public SVGURIReferenceMixin<SupportsXLinkHref::Yes> {
+ WEB_WRAPPABLE(SVGMPathElement, SVGElement);
+ GC_DECLARE_ALLOCATOR(SVGMPathElement);
+
+private:
+ SVGMPathElement(DOM::Document&, DOM::QualifiedName);
+
+ virtual void visit_edges(Cell::Visitor&) override;
+};
+
+}
diff --git a/Libraries/LibWeb/SVG/SVGMPathElement.idl b/Libraries/LibWeb/SVG/SVGMPathElement.idl
new file mode 100644
index 00000000000..f7dfc499914
--- /dev/null
+++ b/Libraries/LibWeb/SVG/SVGMPathElement.idl
@@ -0,0 +1,6 @@
+// https://svgwg.org/specs/animations/#InterfaceSVGMPathElement
+[Exposed=Window]
+interface SVGMPathElement : SVGElement {
+};
+
+SVGMPathElement includes SVGURIReference;
diff --git a/Libraries/LibWeb/SVG/TagNames.h b/Libraries/LibWeb/SVG/TagNames.h
index 031af961c31..15a613495dd 100644
--- a/Libraries/LibWeb/SVG/TagNames.h
+++ b/Libraries/LibWeb/SVG/TagNames.h
@@ -44,6 +44,7 @@ namespace Web::SVG::TagNames {
__ENUMERATE_SVG_TAG(linearGradient, "linearGradient") \
__ENUMERATE_SVG_TAG(mask, "mask") \
__ENUMERATE_SVG_TAG(metadata, "metadata") \
+ __ENUMERATE_SVG_TAG(mpath, "mpath") \
__ENUMERATE_SVG_TAG(path, "path") \
__ENUMERATE_SVG_TAG(pattern, "pattern") \
__ENUMERATE_SVG_TAG(polygon, "polygon") \
diff --git a/Libraries/LibWeb/idl_files.cmake b/Libraries/LibWeb/idl_files.cmake
index 0fccb876fb2..43e85bfefd4 100644
--- a/Libraries/LibWeb/idl_files.cmake
+++ b/Libraries/LibWeb/idl_files.cmake
@@ -537,6 +537,7 @@ libweb_js_bindings(SVG/SVGLinearGradientElement)
libweb_js_bindings(SVG/SVGLineElement)
libweb_js_bindings(SVG/SVGMaskElement)
libweb_js_bindings(SVG/SVGMetadataElement)
+libweb_js_bindings(SVG/SVGMPathElement)
libweb_js_bindings(SVG/SVGNumber)
libweb_js_bindings(SVG/SVGNumberList)
libweb_js_bindings(SVG/SVGPathElement)
diff --git a/Tests/LibWeb/Text/expected/all-window-properties.txt b/Tests/LibWeb/Text/expected/all-window-properties.txt
index 00c47ca8b03..c49b83798b2 100644
--- a/Tests/LibWeb/Text/expected/all-window-properties.txt
+++ b/Tests/LibWeb/Text/expected/all-window-properties.txt
@@ -445,6 +445,7 @@ SVGLength
SVGLengthList
SVGLineElement
SVGLinearGradientElement
+SVGMPathElement
SVGMaskElement
SVGMatrix
SVGMetadataElement
diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txt
index 78edfe8f4ab..c15235857c5 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txt
@@ -2,8 +2,8 @@ Harness status: OK
Found 1780 tests
-1158 Pass
-622 Fail
+1168 Pass
+612 Fail
Pass idl_test setup
Pass idl_test validation
Pass Partial interface Document: original interface defined
@@ -1740,16 +1740,16 @@ Pass SVGElement interface: objects.animateMotion must inherit property "ownerSVG
Pass SVGElement interface: objects.animateMotion must inherit property "viewportElement" with the proper type
Fail SVGElement interface: objects.animateMotion must inherit property "correspondingElement" with the proper type
Fail SVGElement interface: objects.animateMotion must inherit property "correspondingUseElement" with the proper type
-Fail SVGMPathElement interface: existence and properties of interface object
-Fail SVGMPathElement interface object length
-Fail SVGMPathElement interface object name
-Fail SVGMPathElement interface: existence and properties of interface prototype object
-Fail SVGMPathElement interface: existence and properties of interface prototype object's "constructor" property
-Fail SVGMPathElement interface: existence and properties of interface prototype object's @@unscopables property
-Fail SVGMPathElement interface: attribute href
-Fail SVGMPathElement must be primary interface of objects.mpath
-Fail Stringification of objects.mpath
-Fail SVGMPathElement interface: objects.mpath must inherit property "href" with the proper type
+Pass SVGMPathElement interface: existence and properties of interface object
+Pass SVGMPathElement interface object length
+Pass SVGMPathElement interface object name
+Pass SVGMPathElement interface: existence and properties of interface prototype object
+Pass SVGMPathElement interface: existence and properties of interface prototype object's "constructor" property
+Pass SVGMPathElement interface: existence and properties of interface prototype object's @@unscopables property
+Pass SVGMPathElement interface: attribute href
+Pass SVGMPathElement must be primary interface of objects.mpath
+Pass Stringification of objects.mpath
+Pass SVGMPathElement interface: objects.mpath must inherit property "href" with the proper type
Pass SVGElement interface: objects.mpath must inherit property "className" with the proper type
Pass SVGElement interface: objects.mpath must inherit property "ownerSVGElement" with the proper type
Pass SVGElement interface: objects.mpath must inherit property "viewportElement" with the proper type