Truly independent web browser
LibWeb: Create SVGSetElement for <set> elements
Jelle Raaijmakers1678f3867999
diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txtindex 26fdfe9f82f..44ea69a011e 100644--- a/Libraries/LibWeb/CMakeLists.txt+++ b/Libraries/LibWeb/CMakeLists.txt@@ -944,6 +944,7 @@ set(SOURCESSVG/SVGRadialGradientElement.cppSVG/SVGRectElement.cppSVG/SVGScriptElement.cpp+ SVG/SVGSetElement.cppSVG/SVGStopElement.cppSVG/SVGStyleElement.cppSVG/SVGSVGElement.cppdiff --git a/Libraries/LibWeb/DOM/ElementFactory.cpp b/Libraries/LibWeb/DOM/ElementFactory.cppindex 0932bbbe2cb..1c2810a5bef 100644--- a/Libraries/LibWeb/DOM/ElementFactory.cpp+++ b/Libraries/LibWeb/DOM/ElementFactory.cpp@@ -134,6 +134,7 @@#include <LibWeb/SVG/SVGRectElement.h>#include <LibWeb/SVG/SVGSVGElement.h>#include <LibWeb/SVG/SVGScriptElement.h>+#include <LibWeb/SVG/SVGSetElement.h>#include <LibWeb/SVG/SVGStopElement.h>#include <LibWeb/SVG/SVGStyleElement.h>#include <LibWeb/SVG/SVGSwitchElement.h>@@ -584,6 +585,8 @@ static GC::Ref<SVG::SVGElement> create_svg_element(Document& document, Qualifiedreturn create_element_on_heap<SVG::SVGRectElement>(document, move(qualified_name));if (local_name == SVG::TagNames::g)return create_element_on_heap<SVG::SVGGElement>(document, move(qualified_name));+ if (local_name == SVG::TagNames::set)+ return create_element_on_heap<SVG::SVGSetElement>(document, move(qualified_name));if (local_name == SVG::TagNames::stop)return create_element_on_heap<SVG::SVGStopElement>(document, move(qualified_name));if (local_name == SVG::TagNames::style)diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.hindex 6776c2440b0..e462e6dc618 100644--- a/Libraries/LibWeb/Forward.h+++ b/Libraries/LibWeb/Forward.h@@ -1182,6 +1182,7 @@ class SVGPolygonElement;class SVGPolylineElement;class SVGRectElement;class SVGScriptElement;+class SVGSetElement;class SVGSVGElement;class SVGSwitchElement;class SVGSymbolElement;diff --git a/Libraries/LibWeb/SVG/SVGAnimationElement.cpp b/Libraries/LibWeb/SVG/SVGAnimationElement.cppindex dcbbbc8faf2..ffb9ec93d9a 100644--- a/Libraries/LibWeb/SVG/SVGAnimationElement.cpp+++ b/Libraries/LibWeb/SVG/SVGAnimationElement.cpp@@ -11,8 +11,6 @@namespace Web::SVG {-GC_DEFINE_ALLOCATOR(SVGAnimationElement);-SVGAnimationElement::SVGAnimationElement(DOM::Document& document, DOM::QualifiedName name): SVGElement(document, name){diff --git a/Libraries/LibWeb/SVG/SVGAnimationElement.h b/Libraries/LibWeb/SVG/SVGAnimationElement.hindex 523381139e3..558d55a7e06 100644--- a/Libraries/LibWeb/SVG/SVGAnimationElement.h+++ b/Libraries/LibWeb/SVG/SVGAnimationElement.h@@ -12,10 +12,10 @@namespace Web::SVG {-class SVGAnimationElement final : public SVGElement {+class SVGAnimationElement : public SVGElement {WEB_WRAPPABLE(SVGAnimationElement, SVGElement);- GC_DECLARE_ALLOCATOR(SVGAnimationElement);+public:void set_onbegin(GC::Ptr<WebIDL::CallbackType>);GC::Ptr<WebIDL::CallbackType> onbegin();@@ -25,7 +25,7 @@ class SVGAnimationElement final : public SVGElement {void set_onrepeat(GC::Ptr<WebIDL::CallbackType>);GC::Ptr<WebIDL::CallbackType> onrepeat();-private:+protected:SVGAnimationElement(DOM::Document&, DOM::QualifiedName);};diff --git a/Libraries/LibWeb/SVG/SVGSetElement.cpp b/Libraries/LibWeb/SVG/SVGSetElement.cppnew file mode 100644index 00000000000..91eac9a4784--- /dev/null+++ b/Libraries/LibWeb/SVG/SVGSetElement.cpp@@ -0,0 +1,18 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#include <LibWeb/SVG/SVGSetElement.h>++namespace Web::SVG {++GC_DEFINE_ALLOCATOR(SVGSetElement);++SVGSetElement::SVGSetElement(DOM::Document& document, DOM::QualifiedName qualified_name)+ : SVGAnimationElement(document, move(qualified_name))+{+}++}diff --git a/Libraries/LibWeb/SVG/SVGSetElement.h b/Libraries/LibWeb/SVG/SVGSetElement.hnew file mode 100644index 00000000000..a2daf65ab19--- /dev/null+++ b/Libraries/LibWeb/SVG/SVGSetElement.h@@ -0,0 +1,21 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#pragma once++#include <LibWeb/SVG/SVGAnimationElement.h>++namespace Web::SVG {++class SVGSetElement final : public SVGAnimationElement {+ WEB_WRAPPABLE(SVGSetElement, SVGAnimationElement);+ GC_DECLARE_ALLOCATOR(SVGSetElement);++private:+ SVGSetElement(DOM::Document&, DOM::QualifiedName);+};++}diff --git a/Libraries/LibWeb/SVG/SVGSetElement.idl b/Libraries/LibWeb/SVG/SVGSetElement.idlnew file mode 100644index 00000000000..b94863d5331--- /dev/null+++ b/Libraries/LibWeb/SVG/SVGSetElement.idl@@ -0,0 +1,4 @@+// https://svgwg.org/specs/animations/#InterfaceSVGSetElement+[Exposed=Window]+interface SVGSetElement : SVGAnimationElement {+};diff --git a/Libraries/LibWeb/SVG/TagNames.h b/Libraries/LibWeb/SVG/TagNames.hindex 9fd7980dff1..f58bbeb50b5 100644--- a/Libraries/LibWeb/SVG/TagNames.h+++ b/Libraries/LibWeb/SVG/TagNames.h@@ -50,6 +50,7 @@ namespace Web::SVG::TagNames {__ENUMERATE_SVG_TAG(radialGradient, "radialGradient") \__ENUMERATE_SVG_TAG(rect, "rect") \__ENUMERATE_SVG_TAG(script, "script") \+ __ENUMERATE_SVG_TAG(set, "set") \__ENUMERATE_SVG_TAG(stop, "stop") \__ENUMERATE_SVG_TAG(style, "style") \__ENUMERATE_SVG_TAG(svg, "svg") \diff --git a/Libraries/LibWeb/idl_files.cmake b/Libraries/LibWeb/idl_files.cmakeindex 1fce0ddfecf..221d99cab78 100644--- a/Libraries/LibWeb/idl_files.cmake+++ b/Libraries/LibWeb/idl_files.cmake@@ -545,6 +545,7 @@ libweb_js_bindings(SVG/SVGPolylineElement)libweb_js_bindings(SVG/SVGRadialGradientElement)libweb_js_bindings(SVG/SVGRectElement)libweb_js_bindings(SVG/SVGScriptElement)+libweb_js_bindings(SVG/SVGSetElement)libweb_js_bindings(SVG/SVGStopElement)libweb_js_bindings(SVG/SVGStyleElement)libweb_js_bindings(SVG/SVGSVGElement)diff --git a/Tests/LibWeb/Text/expected/all-window-properties.txt b/Tests/LibWeb/Text/expected/all-window-properties.txtindex 7e4beba3df3..3269ced0dc7 100644--- a/Tests/LibWeb/Text/expected/all-window-properties.txt+++ b/Tests/LibWeb/Text/expected/all-window-properties.txt@@ -459,6 +459,7 @@ SVGRectSVGRectElementSVGSVGElementSVGScriptElement+SVGSetElementSVGStopElementSVGStyleElementSVGSwitchElementdiff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txtindex 831f5a35c78..73232da2fe5 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: OKFound 1780 tests-1113 Pass-667 Fail+1124 Pass+656 FailPass idl_test setupPass idl_test validationPass Partial interface Document: original interface defined@@ -1684,18 +1684,18 @@ Pass SVGElement interface: objects.animate must inherit property "ownerSVGElemenPass SVGElement interface: objects.animate must inherit property "viewportElement" with the proper typeFail SVGElement interface: objects.animate must inherit property "correspondingElement" with the proper typeFail SVGElement interface: objects.animate must inherit property "correspondingUseElement" with the proper type-Fail SVGSetElement interface: existence and properties of interface object-Fail SVGSetElement interface object length-Fail SVGSetElement interface object name-Fail SVGSetElement interface: existence and properties of interface prototype object-Fail SVGSetElement interface: existence and properties of interface prototype object's "constructor" property-Fail SVGSetElement interface: existence and properties of interface prototype object's @@unscopables property-Fail SVGSetElement must be primary interface of objects.set-Fail Stringification of objects.set+Pass SVGSetElement interface: existence and properties of interface object+Pass SVGSetElement interface object length+Pass SVGSetElement interface object name+Pass SVGSetElement interface: existence and properties of interface prototype object+Pass SVGSetElement interface: existence and properties of interface prototype object's "constructor" property+Pass SVGSetElement interface: existence and properties of interface prototype object's @@unscopables property+Pass SVGSetElement must be primary interface of objects.set+Pass Stringification of objects.setFail SVGAnimationElement interface: objects.set must inherit property "targetElement" with the proper type-Fail SVGAnimationElement interface: objects.set must inherit property "onbegin" with the proper type-Fail SVGAnimationElement interface: objects.set must inherit property "onend" with the proper type-Fail SVGAnimationElement interface: objects.set must inherit property "onrepeat" with the proper type+Pass SVGAnimationElement interface: objects.set must inherit property "onbegin" with the proper type+Pass SVGAnimationElement interface: objects.set must inherit property "onend" with the proper type+Pass SVGAnimationElement interface: objects.set must inherit property "onrepeat" with the proper typeFail SVGAnimationElement interface: objects.set must inherit property "getStartTime()" with the proper typeFail SVGAnimationElement interface: objects.set must inherit property "getCurrentTime()" with the proper typeFail SVGAnimationElement interface: objects.set must inherit property "getSimpleDuration()" with the proper type