Skip to content

Truly independent web browser

LibWeb: Add SVGPointList and the SVGAnimatedPoints mixin

Andreas Klingf289bff3bd55
diff --git a/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_point.rs b/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_point.rs
index efc042e2d08..e81562136b0 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_point.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/geometry/dom_point.rs
@@ -54,6 +54,12 @@ impl DOMPoint {
}
}
+ /// Sets the x and y coordinates, for an SVGPointList that synchronizes its points with a reflected attribute.
+ pub(crate) fn set_x_and_y(&self, x: f64, y: f64) {
+ self.point.set_x_coordinate(x);
+ self.point.set_y_coordinate(y);
+ }
+
/// https://drafts.fxtf.org/geometry/#dom-dompointreadonly-x
pub(crate) fn set_x(&self, _: &mut CallContext, value: f64) -> WebIdlResult<()> {
// For the DOMPoint interface, setting the x attribute must set the x coordinate to the new value.
diff --git a/Libraries/LibWeb/Bindings/Rust/src/geometry/exports.rs b/Libraries/LibWeb/Bindings/Rust/src/geometry/exports.rs
index 7b5a6a855b6..1de83351470 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/geometry/exports.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/geometry/exports.rs
@@ -74,6 +74,28 @@ pub unsafe extern "C" fn web_dom_point_read_only_create(
cell_into_abi(allocate(vm, DOMPointReadOnly::new(x, y, z, w)))
}
+/// Stores the coordinates x, y, z and w of the point, in that order.
+///
+/// # Safety
+///
+/// `point` must be the live cell of a DOMPoint.
+#[unsafe(no_mangle)]
+pub unsafe extern "C" fn web_dom_point_coordinates(point: *mut c_void, out_coordinates: &mut [f64; 4]) {
+ // SAFETY: The caller passes a live cell.
+ *out_coordinates = unsafe { object_from_abi::<DOMPoint>(point) }.parent().coordinates();
+}
+
+/// Sets the x and y coordinates of the point.
+///
+/// # Safety
+///
+/// `point` must be the live cell of a DOMPoint.
+#[unsafe(no_mangle)]
+pub unsafe extern "C" fn web_dom_point_set_x_and_y(point: *mut c_void, x: f64, y: f64) {
+ // SAFETY: The caller passes a live cell.
+ unsafe { object_from_abi::<DOMPoint>(point) }.set_x_and_y(x, y);
+}
+
/// # Safety
///
/// `vm` must be the live VM.
diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt
index ecf15f5840c..e0dc5fbfcba 100644
--- a/Libraries/LibWeb/CMakeLists.txt
+++ b/Libraries/LibWeb/CMakeLists.txt
@@ -925,6 +925,7 @@ set(SOURCES
SVG/SVGNumberList.cpp
SVG/SVGPathElement.cpp
SVG/SVGPatternElement.cpp
+ SVG/SVGPointList.cpp
SVG/SVGPolygonElement.cpp
SVG/SVGPolylineElement.cpp
SVG/SVGPreserveAspectRatio.cpp
diff --git a/Libraries/LibWeb/Geometry/DOMPoint.cpp b/Libraries/LibWeb/Geometry/DOMPoint.cpp
index 31b7a0b9b0d..61330e078ff 100644
--- a/Libraries/LibWeb/Geometry/DOMPoint.cpp
+++ b/Libraries/LibWeb/Geometry/DOMPoint.cpp
@@ -15,6 +15,8 @@ extern "C" {
// Defined in Bindings/Rust/src/geometry/exports.rs.
void* web_dom_point_create(JSVM*, double x, double y, double z, double w);
+void web_dom_point_coordinates(void const* point, Array<double, 4>* out_coordinates);
+void web_dom_point_set_x_and_y(void* point, double x, double y);
}
GC::Ref<DOMPoint> DOMPoint::create(double x, double y, double z, double w)
@@ -22,4 +24,23 @@ GC::Ref<DOMPoint> DOMPoint::create(double x, double y, double z, double w)
return GC::Ref { *static_cast<DOMPoint*>(web_dom_point_create(JS::HostABI::vm_to_abi(JS::VM::the()), x, y, z, w)) };
}
+double DOMPoint::x() const
+{
+ Array<double, 4> coordinates;
+ web_dom_point_coordinates(this, &coordinates);
+ return coordinates[0];
+}
+
+double DOMPoint::y() const
+{
+ Array<double, 4> coordinates;
+ web_dom_point_coordinates(this, &coordinates);
+ return coordinates[1];
+}
+
+void DOMPoint::set_x_and_y(double x, double y)
+{
+ web_dom_point_set_x_and_y(this, x, y);
+}
+
}
diff --git a/Libraries/LibWeb/Geometry/DOMPoint.h b/Libraries/LibWeb/Geometry/DOMPoint.h
index 4185977b41f..e5018772b93 100644
--- a/Libraries/LibWeb/Geometry/DOMPoint.h
+++ b/Libraries/LibWeb/Geometry/DOMPoint.h
@@ -21,6 +21,11 @@ class WEB_API DOMPoint final : public Bindings::RustInterfaceCell {
public:
static GC::Ref<DOMPoint> create(double x = 0, double y = 0, double z = 0, double w = 1);
+
+ double x() const;
+ double y() const;
+
+ void set_x_and_y(double x, double y);
};
}
diff --git a/Libraries/LibWeb/SVG/SVGAnimatedPoints.idl b/Libraries/LibWeb/SVG/SVGAnimatedPoints.idl
new file mode 100644
index 00000000000..b38b7385a2a
--- /dev/null
+++ b/Libraries/LibWeb/SVG/SVGAnimatedPoints.idl
@@ -0,0 +1,5 @@
+// https://svgwg.org/svg2-draft/shapes.html#InterfaceSVGAnimatedPoints
+interface mixin SVGAnimatedPoints {
+ [SameObject, ImplementedAs=points_for_bindings] readonly attribute SVGPointList points;
+ [SameObject] readonly attribute SVGPointList animatedPoints;
+};
diff --git a/Libraries/LibWeb/SVG/SVGList.cpp b/Libraries/LibWeb/SVG/SVGList.cpp
index 64435770a50..ee3ec85773a 100644
--- a/Libraries/LibWeb/SVG/SVGList.cpp
+++ b/Libraries/LibWeb/SVG/SVGList.cpp
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <LibWeb/Geometry/DOMPoint.h>
#include <LibWeb/SVG/SVGLength.h>
#include <LibWeb/SVG/SVGList.h>
#include <LibWeb/SVG/SVGNumber.h>
@@ -228,5 +229,6 @@ template class SVGList<GC::Ref<SVGLength>>;
template class SVGList<GC::Ref<SVGNumber>>;
template class SVGList<GC::Ref<SVGTransform>>;
template class SVGList<Utf16String>;
+template class SVGList<GC::Ref<Geometry::DOMPoint>>;
}
diff --git a/Libraries/LibWeb/SVG/SVGPointList.cpp b/Libraries/LibWeb/SVG/SVGPointList.cpp
new file mode 100644
index 00000000000..a61b1973ef0
--- /dev/null
+++ b/Libraries/LibWeb/SVG/SVGPointList.cpp
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <AK/TemporaryChange.h>
+#include <AK/Utf16StringBuilder.h>
+#include <LibGC/Heap.h>
+#include <LibWeb/CSS/Serialize.h>
+#include <LibWeb/Geometry/DOMPoint.h>
+#include <LibWeb/SVG/AttributeNames.h>
+#include <LibWeb/SVG/AttributeParsing.h>
+#include <LibWeb/SVG/SVGElement.h>
+#include <LibWeb/SVG/SVGPointList.h>
+
+namespace Web::SVG {
+
+GC_DEFINE_ALLOCATOR(SVGPointList);
+
+GC::Ref<SVGPointList> SVGPointList::create(GC::Ref<SVGElement> element, Utf16FlyString reflected_attribute, ReadOnlyList read_only)
+{
+ return GC::Heap::the().allocate<SVGPointList>(element, move(reflected_attribute), read_only);
+}
+
+SVGPointList::SVGPointList(GC::Ref<SVGElement> element, Utf16FlyString reflected_attribute, ReadOnlyList read_only)
+ : SVGList(read_only)
+ , m_element(element)
+ , m_reflected_attribute(move(reflected_attribute))
+{
+ synchronize();
+}
+
+void SVGPointList::visit_edges(Visitor& visitor)
+{
+ Base::visit_edges(visitor);
+ SVGList::visit_edges(visitor);
+ visitor.visit(m_element);
+}
+
+GC::Ref<Geometry::DOMPoint> SVGPointList::copy_if_not_detached(GC::Ref<Geometry::DOMPoint> point)
+{
+ // FIXME: A DOMPoint does not know which list it is an element of, so only a point that is an element of this list
+ // is known not to be detached. Also copy a point that is an element of another list.
+ if (!items().contains_slow(point))
+ return point;
+
+ // NB: The value of a point in a list is its x and y coordinates.
+ return Geometry::DOMPoint::create(point->x(), point->y());
+}
+
+// https://svgwg.org/svg2-draft/types.html#TermSynchronizeList
+void SVGPointList::synchronize()
+{
+ // NB: The list does not need to be synchronized with a value that it has just reserialized itself.
+ if (m_is_reserializing)
+ return;
+
+ // 1. Let value be the base value of the reflected content attribute (using the attribute's initial value if it is
+ // not present or invalid).
+ auto value = parse_points(m_element->get_attribute_value(m_reflected_attribute));
+
+ // FIXME: DOMPoint objects are not associated with the list they are an element of, so modifying one does not
+ // reserialize the reflected attribute, and a point of a list that is read only can still be modified.
+ synchronize_items(value, [] { return Geometry::DOMPoint::create(); }, [](GC::Ref<Geometry::DOMPoint> const& item, Gfx::FloatPoint const& point) { item->set_x_and_y(point.x(), point.y()); });
+}
+
+// https://svgwg.org/svg2-draft/types.html#TermReserialize
+void SVGPointList::reserialize_reflected_attribute()
+{
+ // 1. Let elements be the list of values in value.
+ // 2. Let serialized elements be a list of strings, where each string is formed based on the corresponding value in
+ // elements and its type:
+ // a DOMPoint object: The string value is computed as follows:
+ // 1. Let string be an empty string.
+ // 2. Let x and y be the values of the DOMPoint object's x and y coordinates, respectively.
+ // 3. Append to string an implementation specific string that, if parsed as <number> using CSS syntax, would
+ // return the number value closest to x, given the implementation's supported real number precision.
+ // 4. Append a single U+002C COMMA character to string.
+ // 5. Append to string an implementation specific string that, if parsed as <number> using CSS syntax, would
+ // return the number value closest to y, given the implementation's supported real number precision.
+ // 6. The string is string.
+ // 3. Set the content attribute to a string consisting of the strings in serialized elements joined and separated by
+ // single U+0020 SPACE characters.
+ // FIXME: The spec does not say how to serialize a coordinate that is not finite.
+ Utf16StringBuilder builder;
+ for (size_t index = 0; index < items().size(); ++index) {
+ if (index > 0)
+ builder.append_code_unit(' ');
+ CSS::serialize_a_number(builder, items()[index]->x());
+ builder.append_code_unit(',');
+ CSS::serialize_a_number(builder, items()[index]->y());
+ }
+
+ TemporaryChange change { m_is_reserializing, true };
+ m_element->set_attribute_value(m_reflected_attribute, builder.to_string());
+}
+
+// https://svgwg.org/svg2-draft/shapes.html#__svg__SVGAnimatedPoints__points
+GC::Ref<SVGPointList> SVGAnimatedPoints::points_for_bindings()
+{
+ // On getting points, an SVGPointList object is returned that reflects the base value of the reflected attribute.
+ if (!m_points_list)
+ m_points_list = SVGPointList::create(svg_animated_points_element(), AttributeNames::points, ReadOnlyList::No);
+ return *m_points_list;
+}
+
+// https://svgwg.org/svg2-draft/shapes.html#__svg__SVGAnimatedPoints__animatedPoints
+GC::Ref<SVGPointList> SVGAnimatedPoints::animated_points()
+{
+ // On getting animatedPoints, an SVGPointList object is returned that reflects the animated value of the reflected
+ // attribute.
+ // NB: List interface objects reflected through the animVal IDL attribute are always read only.
+ // FIXME: Reflect the animated value once SMIL animation can affect it.
+ if (!m_animated_points_list)
+ m_animated_points_list = SVGPointList::create(svg_animated_points_element(), AttributeNames::points, ReadOnlyList::Yes);
+ return *m_animated_points_list;
+}
+
+void SVGAnimatedPoints::visit_edges(GC::Cell::Visitor& visitor)
+{
+ visitor.visit(m_points_list);
+ visitor.visit(m_animated_points_list);
+}
+
+void SVGAnimatedPoints::attribute_changed(Utf16FlyString const& name, Optional<Utf16FlyString> const& namespace_)
+{
+ // https://svgwg.org/svg2-draft/types.html#SynchronizingReflectedValues
+ if (namespace_.has_value() || name != AttributeNames::points)
+ return;
+ if (m_points_list)
+ m_points_list->synchronize();
+ if (m_animated_points_list)
+ m_animated_points_list->synchronize();
+}
+
+}
diff --git a/Libraries/LibWeb/SVG/SVGPointList.h b/Libraries/LibWeb/SVG/SVGPointList.h
new file mode 100644
index 00000000000..3bc2de8988b
--- /dev/null
+++ b/Libraries/LibWeb/SVG/SVGPointList.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/Utf16FlyString.h>
+#include <LibWeb/Bindings/Wrappable.h>
+#include <LibWeb/Forward.h>
+#include <LibWeb/SVG/SVGList.h>
+
+namespace Web::SVG {
+
+// https://svgwg.org/svg2-draft/shapes.html#InterfaceSVGPointList
+class SVGPointList final
+ : public Bindings::GCAllocatedWrappable
+ , public SVGList<GC::Ref<Geometry::DOMPoint>> {
+ WEB_WRAPPABLE(SVGPointList, Bindings::GCAllocatedWrappable);
+ GC_DECLARE_ALLOCATOR(SVGPointList);
+
+public:
+ [[nodiscard]] static GC::Ref<SVGPointList> create(GC::Ref<SVGElement>, Utf16FlyString reflected_attribute, ReadOnlyList);
+ virtual ~SVGPointList() override = default;
+
+ // https://svgwg.org/svg2-draft/types.html#TermSynchronizeList
+ void synchronize();
+
+ // https://svgwg.org/svg2-draft/types.html#TermReserialize
+ virtual void reserialize_reflected_attribute() override;
+
+private:
+ SVGPointList(GC::Ref<SVGElement>, Utf16FlyString reflected_attribute, ReadOnlyList);
+
+ virtual void visit_edges(Visitor&) override;
+
+ virtual GC::Ref<Geometry::DOMPoint> copy_if_not_detached(GC::Ref<Geometry::DOMPoint>) override;
+
+ GC::Ref<SVGElement> m_element;
+ Utf16FlyString m_reflected_attribute;
+ bool m_is_reserializing { false };
+};
+
+// https://svgwg.org/svg2-draft/shapes.html#InterfaceSVGAnimatedPoints
+class SVGAnimatedPoints {
+public:
+ virtual ~SVGAnimatedPoints() = default;
+
+ GC::Ref<SVGPointList> points_for_bindings();
+ GC::Ref<SVGPointList> animated_points();
+
+protected:
+ void visit_edges(GC::Cell::Visitor&);
+ void attribute_changed(Utf16FlyString const& name, Optional<Utf16FlyString> const& namespace_);
+
+ virtual SVGElement& svg_animated_points_element() = 0;
+
+private:
+ GC::Ptr<SVGPointList> m_points_list;
+ GC::Ptr<SVGPointList> m_animated_points_list;
+};
+
+}
diff --git a/Libraries/LibWeb/SVG/SVGPointList.idl b/Libraries/LibWeb/SVG/SVGPointList.idl
new file mode 100644
index 00000000000..d5fbb2ee0c7
--- /dev/null
+++ b/Libraries/LibWeb/SVG/SVGPointList.idl
@@ -0,0 +1,16 @@
+// https://svgwg.org/svg2-draft/shapes.html#InterfaceSVGPointList
+[Exposed=Window]
+interface SVGPointList {
+
+ readonly attribute unsigned long length;
+ readonly attribute unsigned long numberOfItems;
+
+ undefined clear();
+ DOMPoint initialize(DOMPoint newItem);
+ getter DOMPoint getItem(unsigned long index);
+ DOMPoint insertItemBefore(DOMPoint newItem, unsigned long index);
+ DOMPoint replaceItem(DOMPoint newItem, unsigned long index);
+ DOMPoint removeItem(unsigned long index);
+ DOMPoint appendItem(DOMPoint newItem);
+ setter undefined (unsigned long index, DOMPoint newItem);
+};
diff --git a/Libraries/LibWeb/SVG/SVGPolygonElement.cpp b/Libraries/LibWeb/SVG/SVGPolygonElement.cpp
index 5ca2978ade6..569fde158ad 100644
--- a/Libraries/LibWeb/SVG/SVGPolygonElement.cpp
+++ b/Libraries/LibWeb/SVG/SVGPolygonElement.cpp
@@ -18,9 +18,16 @@ SVGPolygonElement::SVGPolygonElement(DOM::Document& document, DOM::QualifiedName
{
}
+void SVGPolygonElement::visit_edges(Cell::Visitor& visitor)
+{
+ Base::visit_edges(visitor);
+ SVGAnimatedPoints::visit_edges(visitor);
+}
+
void SVGPolygonElement::attribute_changed(Utf16FlyString const& name, Optional<Utf16String> const& old_value, Optional<Utf16String> const& value, Optional<Utf16FlyString> const& namespace_)
{
Base::attribute_changed(name, old_value, value, namespace_);
+ SVGAnimatedPoints::attribute_changed(name, namespace_);
if (name == SVG::AttributeNames::points) {
m_points = parse_points(value.value_or({}));
diff --git a/Libraries/LibWeb/SVG/SVGPolygonElement.h b/Libraries/LibWeb/SVG/SVGPolygonElement.h
index 22efacdb64a..b3a75c85f8f 100644
--- a/Libraries/LibWeb/SVG/SVGPolygonElement.h
+++ b/Libraries/LibWeb/SVG/SVGPolygonElement.h
@@ -7,10 +7,13 @@
#pragma once
#include <LibWeb/SVG/SVGGeometryElement.h>
+#include <LibWeb/SVG/SVGPointList.h>
namespace Web::SVG {
-class SVGPolygonElement final : public SVGGeometryElement {
+class SVGPolygonElement final
+ : public SVGGeometryElement
+ , public SVGAnimatedPoints {
WEB_WRAPPABLE(SVGPolygonElement, SVGGeometryElement);
GC_DECLARE_ALLOCATOR(SVGPolygonElement);
@@ -27,6 +30,11 @@ private:
SVGPolygonElement(DOM::Document&, DOM::QualifiedName);
+ virtual void visit_edges(Cell::Visitor&) override;
+
+ // ^SVGAnimatedPoints
+ virtual SVGElement& svg_animated_points_element() override { return *this; }
+
Vector<Gfx::FloatPoint> m_points;
};
diff --git a/Libraries/LibWeb/SVG/SVGPolygonElement.idl b/Libraries/LibWeb/SVG/SVGPolygonElement.idl
index 418bd2df5be..562ec5f3605 100644
--- a/Libraries/LibWeb/SVG/SVGPolygonElement.idl
+++ b/Libraries/LibWeb/SVG/SVGPolygonElement.idl
@@ -3,4 +3,4 @@
interface SVGPolygonElement : SVGGeometryElement {
};
-// SVGPolygonElement includes SVGAnimatedPoints;
+SVGPolygonElement includes SVGAnimatedPoints;
diff --git a/Libraries/LibWeb/SVG/SVGPolylineElement.cpp b/Libraries/LibWeb/SVG/SVGPolylineElement.cpp
index 9c77ca2728e..d5d1ed42958 100644
--- a/Libraries/LibWeb/SVG/SVGPolylineElement.cpp
+++ b/Libraries/LibWeb/SVG/SVGPolylineElement.cpp
@@ -18,9 +18,16 @@ SVGPolylineElement::SVGPolylineElement(DOM::Document& document, DOM::QualifiedNa
{
}
+void SVGPolylineElement::visit_edges(Cell::Visitor& visitor)
+{
+ Base::visit_edges(visitor);
+ SVGAnimatedPoints::visit_edges(visitor);
+}
+
void SVGPolylineElement::attribute_changed(Utf16FlyString const& name, Optional<Utf16String> const& old_value, Optional<Utf16String> const& value, Optional<Utf16FlyString> const& namespace_)
{
Base::attribute_changed(name, old_value, value, namespace_);
+ SVGAnimatedPoints::attribute_changed(name, namespace_);
if (name == SVG::AttributeNames::points) {
m_points = parse_points(value.value_or({}));
diff --git a/Libraries/LibWeb/SVG/SVGPolylineElement.h b/Libraries/LibWeb/SVG/SVGPolylineElement.h
index f3651a925ba..479d16f14f9 100644
--- a/Libraries/LibWeb/SVG/SVGPolylineElement.h
+++ b/Libraries/LibWeb/SVG/SVGPolylineElement.h
@@ -7,10 +7,13 @@
#pragma once
#include <LibWeb/SVG/SVGGeometryElement.h>
+#include <LibWeb/SVG/SVGPointList.h>
namespace Web::SVG {
-class SVGPolylineElement final : public SVGGeometryElement {
+class SVGPolylineElement final
+ : public SVGGeometryElement
+ , public SVGAnimatedPoints {
WEB_WRAPPABLE(SVGPolylineElement, SVGGeometryElement);
GC_DECLARE_ALLOCATOR(SVGPolylineElement);
@@ -27,6 +30,11 @@ private:
SVGPolylineElement(DOM::Document&, DOM::QualifiedName);
+ virtual void visit_edges(Cell::Visitor&) override;
+
+ // ^SVGAnimatedPoints
+ virtual SVGElement& svg_animated_points_element() override { return *this; }
+
Vector<Gfx::FloatPoint> m_points;
};
diff --git a/Libraries/LibWeb/SVG/SVGPolylineElement.idl b/Libraries/LibWeb/SVG/SVGPolylineElement.idl
index f62926648a8..29575cf2624 100644
--- a/Libraries/LibWeb/SVG/SVGPolylineElement.idl
+++ b/Libraries/LibWeb/SVG/SVGPolylineElement.idl
@@ -3,4 +3,4 @@
interface SVGPolylineElement : SVGGeometryElement {
};
-// SVGPolylineElement includes SVGAnimatedPoints;
+SVGPolylineElement includes SVGAnimatedPoints;
diff --git a/Libraries/LibWeb/idl_files.cmake b/Libraries/LibWeb/idl_files.cmake
index 56c439ba0f8..f1e2ddadc7c 100644
--- a/Libraries/LibWeb/idl_files.cmake
+++ b/Libraries/LibWeb/idl_files.cmake
@@ -502,6 +502,7 @@ libweb_js_bindings(SVG/SVGAnimatedLength)
libweb_js_bindings(SVG/SVGAnimatedLengthList)
libweb_js_bindings(SVG/SVGAnimatedNumber)
libweb_js_bindings(SVG/SVGAnimatedNumberList)
+libweb_js_bindings(SVG/SVGAnimatedPoints)
libweb_js_bindings(SVG/SVGAnimatedPreserveAspectRatio)
libweb_js_bindings(SVG/SVGAnimatedRect)
libweb_js_bindings(SVG/SVGAnimatedString)
@@ -560,6 +561,7 @@ libweb_js_bindings(SVG/SVGNumber)
libweb_js_bindings(SVG/SVGNumberList)
libweb_js_bindings(SVG/SVGPathElement)
libweb_js_bindings(SVG/SVGPatternElement)
+libweb_js_bindings(SVG/SVGPointList)
libweb_js_bindings(SVG/SVGPolygonElement)
libweb_js_bindings(SVG/SVGPolylineElement)
libweb_js_bindings(SVG/SVGPreserveAspectRatio)
diff --git a/Meta/Generators/libweb_bindings/named_and_indexed_properties.py b/Meta/Generators/libweb_bindings/named_and_indexed_properties.py
index e51cde2faff..6f4ed10367e 100644
--- a/Meta/Generators/libweb_bindings/named_and_indexed_properties.py
+++ b/Meta/Generators/libweb_bindings/named_and_indexed_properties.py
@@ -169,7 +169,7 @@ def indexed_property_getter_value_mode(interface: Interface) -> str:
return "empty_string"
if interface.name in ("CSSUnparsedValue", "DOMStringList", "DOMTokenList", "MediaList"):
return "optional"
- if interface.name in ("SVGLengthList", "SVGNumberList", "SVGStringList", "SVGTransformList"):
+ if interface.name in ("SVGLengthList", "SVGNumberList", "SVGPointList", "SVGStringList", "SVGTransformList"):
return "svg_list"
if interface.name in ("SourceBufferList",):
return "value"
@@ -293,7 +293,7 @@ def indexed_property_setter_call(interface: Interface, operation: SpecialOperati
return f"impl.set_value_of_indexed_property(index, {value_name})"
if interface.name in ("HTMLOptionsCollection", "HTMLSelectElement"):
return f"impl.set_value_of_indexed_property(index, {value_name})"
- if interface.name in ("SVGLengthList", "SVGNumberList", "SVGStringList", "SVGTransformList"):
+ if interface.name in ("SVGLengthList", "SVGNumberList", "SVGPointList", "SVGStringList", "SVGTransformList"):
return f"impl.replace_item({value_name}, index)"
return f"impl.{hook_name}(index, {value_name})"
@@ -303,7 +303,7 @@ def svg_list_indexed_property_setter_conversion(
includes: GeneratedIncludes,
value_parameter: OperationParameter,
) -> Optional[str]:
- if value_parameter.type.name not in ("SVGLength", "SVGNumber", "SVGTransform"):
+ if value_parameter.type.name not in ("DOMPoint", "SVGLength", "SVGNumber", "SVGTransform"):
return None
value_interface = context.interface(value_parameter.type)
@@ -364,7 +364,7 @@ def write_indexed_property_setter_implementation(
f" if (maybe_element)\n"
f" {value_name} = GC::Ref {{ *maybe_element }};\n"
)
- elif interface.name in ("SVGLengthList", "SVGNumberList", "SVGTransformList"):
+ elif interface.name in ("SVGLengthList", "SVGNumberList", "SVGPointList", "SVGTransformList"):
conversion = svg_list_indexed_property_setter_conversion(context, includes, value_parameter)
if conversion is None:
raise RuntimeError(f"Unsupported SVG list indexed property setter type on '{interface.name}'")
diff --git a/Tests/LibWeb/Text/expected/all-window-properties.txt b/Tests/LibWeb/Text/expected/all-window-properties.txt
index a164e0579cb..57124ba7c41 100644
--- a/Tests/LibWeb/Text/expected/all-window-properties.txt
+++ b/Tests/LibWeb/Text/expected/all-window-properties.txt
@@ -468,6 +468,7 @@ SVGNumberList
SVGPathElement
SVGPatternElement
SVGPoint
+SVGPointList
SVGPolygonElement
SVGPolylineElement
SVGPreserveAspectRatio
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 dd761cea265..aa97403a290 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
-1529 Pass
-251 Fail
+1569 Pass
+211 Fail
Pass idl_test setup
Pass idl_test validation
Pass Partial interface Document: original interface defined
@@ -996,50 +996,50 @@ Pass SVGElement interface: objects.line must inherit property "ownerSVGElement"
Pass SVGElement interface: objects.line must inherit property "viewportElement" with the proper type
Fail SVGElement interface: objects.line must inherit property "correspondingElement" with the proper type
Fail SVGElement interface: objects.line must inherit property "correspondingUseElement" with the proper type
-Fail SVGPointList interface: existence and properties of interface object
-Fail SVGPointList interface object length
-Fail SVGPointList interface object name
-Fail SVGPointList interface: existence and properties of interface prototype object
-Fail SVGPointList interface: existence and properties of interface prototype object's "constructor" property
-Fail SVGPointList interface: existence and properties of interface prototype object's @@unscopables property
-Fail SVGPointList interface: attribute length
-Fail SVGPointList interface: attribute numberOfItems
-Fail SVGPointList interface: operation clear()
-Fail SVGPointList interface: operation initialize(DOMPoint)
-Fail SVGPointList interface: operation getItem(unsigned long)
-Fail SVGPointList interface: operation insertItemBefore(DOMPoint, unsigned long)
-Fail SVGPointList interface: operation replaceItem(DOMPoint, unsigned long)
-Fail SVGPointList interface: operation removeItem(unsigned long)
-Fail SVGPointList interface: operation appendItem(DOMPoint)
-Fail SVGPointList must be primary interface of objects.polygon.points
-Fail Stringification of objects.polygon.points
-Fail SVGPointList interface: objects.polygon.points must inherit property "length" with the proper type
-Fail SVGPointList interface: objects.polygon.points must inherit property "numberOfItems" with the proper type
-Fail SVGPointList interface: objects.polygon.points must inherit property "clear()" with the proper type
-Fail SVGPointList interface: objects.polygon.points must inherit property "initialize(DOMPoint)" with the proper type
-Fail SVGPointList interface: calling initialize(DOMPoint) on objects.polygon.points with too few arguments must throw TypeError
-Fail SVGPointList interface: objects.polygon.points must inherit property "getItem(unsigned long)" with the proper type
-Fail SVGPointList interface: calling getItem(unsigned long) on objects.polygon.points with too few arguments must throw TypeError
-Fail SVGPointList interface: objects.polygon.points must inherit property "insertItemBefore(DOMPoint, unsigned long)" with the proper type
-Fail SVGPointList interface: calling insertItemBefore(DOMPoint, unsigned long) on objects.polygon.points with too few arguments must throw TypeError
-Fail SVGPointList interface: objects.polygon.points must inherit property "replaceItem(DOMPoint, unsigned long)" with the proper type
-Fail SVGPointList interface: calling replaceItem(DOMPoint, unsigned long) on objects.polygon.points with too few arguments must throw TypeError
-Fail SVGPointList interface: objects.polygon.points must inherit property "removeItem(unsigned long)" with the proper type
-Fail SVGPointList interface: calling removeItem(unsigned long) on objects.polygon.points with too few arguments must throw TypeError
-Fail SVGPointList interface: objects.polygon.points must inherit property "appendItem(DOMPoint)" with the proper type
-Fail SVGPointList interface: calling appendItem(DOMPoint) on objects.polygon.points with too few arguments must throw TypeError
+Pass SVGPointList interface: existence and properties of interface object
+Pass SVGPointList interface object length
+Pass SVGPointList interface object name
+Pass SVGPointList interface: existence and properties of interface prototype object
+Pass SVGPointList interface: existence and properties of interface prototype object's "constructor" property
+Pass SVGPointList interface: existence and properties of interface prototype object's @@unscopables property
+Pass SVGPointList interface: attribute length
+Pass SVGPointList interface: attribute numberOfItems
+Pass SVGPointList interface: operation clear()
+Pass SVGPointList interface: operation initialize(DOMPoint)
+Pass SVGPointList interface: operation getItem(unsigned long)
+Pass SVGPointList interface: operation insertItemBefore(DOMPoint, unsigned long)
+Pass SVGPointList interface: operation replaceItem(DOMPoint, unsigned long)
+Pass SVGPointList interface: operation removeItem(unsigned long)
+Pass SVGPointList interface: operation appendItem(DOMPoint)
+Pass SVGPointList must be primary interface of objects.polygon.points
+Pass Stringification of objects.polygon.points
+Pass SVGPointList interface: objects.polygon.points must inherit property "length" with the proper type
+Pass SVGPointList interface: objects.polygon.points must inherit property "numberOfItems" with the proper type
+Pass SVGPointList interface: objects.polygon.points must inherit property "clear()" with the proper type
+Pass SVGPointList interface: objects.polygon.points must inherit property "initialize(DOMPoint)" with the proper type
+Pass SVGPointList interface: calling initialize(DOMPoint) on objects.polygon.points with too few arguments must throw TypeError
+Pass SVGPointList interface: objects.polygon.points must inherit property "getItem(unsigned long)" with the proper type
+Pass SVGPointList interface: calling getItem(unsigned long) on objects.polygon.points with too few arguments must throw TypeError
+Pass SVGPointList interface: objects.polygon.points must inherit property "insertItemBefore(DOMPoint, unsigned long)" with the proper type
+Pass SVGPointList interface: calling insertItemBefore(DOMPoint, unsigned long) on objects.polygon.points with too few arguments must throw TypeError
+Pass SVGPointList interface: objects.polygon.points must inherit property "replaceItem(DOMPoint, unsigned long)" with the proper type
+Pass SVGPointList interface: calling replaceItem(DOMPoint, unsigned long) on objects.polygon.points with too few arguments must throw TypeError
+Pass SVGPointList interface: objects.polygon.points must inherit property "removeItem(unsigned long)" with the proper type
+Pass SVGPointList interface: calling removeItem(unsigned long) on objects.polygon.points with too few arguments must throw TypeError
+Pass SVGPointList interface: objects.polygon.points must inherit property "appendItem(DOMPoint)" with the proper type
+Pass SVGPointList interface: calling appendItem(DOMPoint) on objects.polygon.points with too few arguments must throw TypeError
Pass SVGPolylineElement interface: existence and properties of interface object
Pass SVGPolylineElement interface object length
Pass SVGPolylineElement interface object name
Pass SVGPolylineElement interface: existence and properties of interface prototype object
Pass SVGPolylineElement interface: existence and properties of interface prototype object's "constructor" property
Pass SVGPolylineElement interface: existence and properties of interface prototype object's @@unscopables property
-Fail SVGPolylineElement interface: attribute points
-Fail SVGPolylineElement interface: attribute animatedPoints
+Pass SVGPolylineElement interface: attribute points
+Pass SVGPolylineElement interface: attribute animatedPoints
Pass SVGPolylineElement must be primary interface of objects.polyline
Pass Stringification of objects.polyline
-Fail SVGPolylineElement interface: objects.polyline must inherit property "points" with the proper type
-Fail SVGPolylineElement interface: objects.polyline must inherit property "animatedPoints" with the proper type
+Pass SVGPolylineElement interface: objects.polyline must inherit property "points" with the proper type
+Pass SVGPolylineElement interface: objects.polyline must inherit property "animatedPoints" with the proper type
Pass SVGGeometryElement interface: objects.polyline must inherit property "pathLength" with the proper type
Pass SVGGeometryElement interface: objects.polyline must inherit property "isPointInFill(optional DOMPointInit)" with the proper type
Pass SVGGeometryElement interface: calling isPointInFill(optional DOMPointInit) on objects.polyline with too few arguments must throw TypeError
@@ -1066,12 +1066,12 @@ Pass SVGPolygonElement interface object name
Pass SVGPolygonElement interface: existence and properties of interface prototype object
Pass SVGPolygonElement interface: existence and properties of interface prototype object's "constructor" property
Pass SVGPolygonElement interface: existence and properties of interface prototype object's @@unscopables property
-Fail SVGPolygonElement interface: attribute points
-Fail SVGPolygonElement interface: attribute animatedPoints
+Pass SVGPolygonElement interface: attribute points
+Pass SVGPolygonElement interface: attribute animatedPoints
Pass SVGPolygonElement must be primary interface of objects.polygon
Pass Stringification of objects.polygon
-Fail SVGPolygonElement interface: objects.polygon must inherit property "points" with the proper type
-Fail SVGPolygonElement interface: objects.polygon must inherit property "animatedPoints" with the proper type
+Pass SVGPolygonElement interface: objects.polygon must inherit property "points" with the proper type
+Pass SVGPolygonElement interface: objects.polygon must inherit property "animatedPoints" with the proper type
Pass SVGGeometryElement interface: objects.polygon must inherit property "pathLength" with the proper type
Pass SVGGeometryElement interface: objects.polygon must inherit property "isPointInFill(optional DOMPointInit)" with the proper type
Pass SVGGeometryElement interface: calling isPointInFill(optional DOMPointInit) on objects.polygon with too few arguments must throw TypeError
diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGList-animVal-reflects-base-value.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGList-animVal-reflects-base-value.txt
index c8f49a470b7..fc108ffe29b 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGList-animVal-reflects-base-value.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGList-animVal-reflects-base-value.txt
@@ -2,8 +2,8 @@ Harness status: OK
Found 20 tests
-16 Pass
-4 Fail
+19 Pass
+1 Fail
Pass SVGNumberList (rotate on text): animVal read before an attribute change reports the new item count
Pass SVGNumberList (rotate on text): animVal read before an attribute change reports the new value
Pass SVGNumberList (rotate on text): the animVal list object survives an attribute change
@@ -14,10 +14,10 @@ Pass SVGLengthList (x on text): animVal read before an attribute change reports
Pass SVGLengthList (x on text): the animVal list object survives an attribute change
Pass SVGLengthList (x on text): animVal reports the new item count after a baseVal DOM change
Pass SVGLengthList (x on text): animVal items are read only
-Fail SVGPointList (points on polyline, animatedPoints): animVal read before an attribute change reports the new item count
-Fail SVGPointList (points on polyline, animatedPoints): animVal read before an attribute change reports the new value
+Pass SVGPointList (points on polyline, animatedPoints): animVal read before an attribute change reports the new item count
+Pass SVGPointList (points on polyline, animatedPoints): animVal read before an attribute change reports the new value
Pass SVGPointList (points on polyline, animatedPoints): the animVal list object survives an attribute change
-Fail SVGPointList (points on polyline, animatedPoints): animVal reports the new item count after a baseVal DOM change
+Pass SVGPointList (points on polyline, animatedPoints): animVal reports the new item count after a baseVal DOM change
Fail SVGPointList (points on polyline, animatedPoints): animVal items are read only
Pass SVGTransformList (gradientTransform on linearGradient): animVal read before an attribute change reports the new item count
Pass SVGTransformList (gradientTransform on linearGradient): animVal read before an attribute change reports the new value
diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGList-reflected-attribute-synchronize.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGList-reflected-attribute-synchronize.txt
index 94e85c69556..0e05c3c62b8 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGList-reflected-attribute-synchronize.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGList-reflected-attribute-synchronize.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 59 tests
-50 Pass
-9 Fail
+59 Pass
Pass SVGNumberList (rotate on text): getItem returns the same object for one index, with no attribute change
Pass SVGNumberList (rotate on text): a same-count change updates the values of the held items
Pass SVGNumberList (rotate on text): a same-count change keeps the held item in the list
@@ -24,16 +23,16 @@ Pass SVGLengthList (x on text): a shrink detaches the truncated item, which keep
Pass SVGLengthList (x on text): the truncated item stops reaching the element and stops being read only
Pass SVGLengthList (x on text): the list interface object survives the change
Pass SVGLengthList (x on text): an empty string empties the list and detaches every item
-Fail SVGPointList (points on polyline): getItem returns the same object for one index, with no attribute change
-Fail SVGPointList (points on polyline): a same-count change updates the values of the held items
-Fail SVGPointList (points on polyline): a same-count change keeps the held item in the list
-Fail SVGPointList (points on polyline): the held item is still attached after a same-count change
-Fail SVGPointList (points on polyline): a grow updates the held item and appends new ones
-Fail SVGPointList (points on polyline): a shrink updates the held items that are still in range
-Fail SVGPointList (points on polyline): a shrink detaches the truncated item, which keeps its value
-Fail SVGPointList (points on polyline): the truncated item stops reaching the element and stops being read only
+Pass SVGPointList (points on polyline): getItem returns the same object for one index, with no attribute change
+Pass SVGPointList (points on polyline): a same-count change updates the values of the held items
+Pass SVGPointList (points on polyline): a same-count change keeps the held item in the list
+Pass SVGPointList (points on polyline): the held item is still attached after a same-count change
+Pass SVGPointList (points on polyline): a grow updates the held item and appends new ones
+Pass SVGPointList (points on polyline): a shrink updates the held items that are still in range
+Pass SVGPointList (points on polyline): a shrink detaches the truncated item, which keeps its value
+Pass SVGPointList (points on polyline): the truncated item stops reaching the element and stops being read only
Pass SVGPointList (points on polyline): the list interface object survives the change
-Fail SVGPointList (points on polyline): an empty string empties the list and detaches every item
+Pass SVGPointList (points on polyline): an empty string empties the list and detaches every item
Pass SVGTransformList (transform on g): getItem returns the same object for one index, with no attribute change
Pass SVGTransformList (transform on g): a same-count change updates the values of the held items
Pass SVGTransformList (transform on g): a same-count change keeps the held item in the list
diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGPointList-error-handling.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGPointList-error-handling.txt
index df358f46cbd..d9a8ddd0ed3 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGPointList-error-handling.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGPointList-error-handling.txt
@@ -2,21 +2,20 @@ Harness status: OK
Found 16 tests
-2 Pass
-14 Fail
-Fail polyline with an odd number of coordinates drops the last one and keeps the rest
-Fail polyline whose points value begins with a non-numeric token renders nothing
-Fail polyline whose points value begins with a separator renders nothing
-Fail polyline with a points value of a single separator renders nothing
-Fail polyline with an empty points value renders nothing
-Fail polyline with a whitespace-only points value renders nothing
-Fail polyline with no points attribute renders nothing
+16 Pass
+Pass polyline with an odd number of coordinates drops the last one and keeps the rest
+Pass polyline whose points value begins with a non-numeric token renders nothing
+Pass polyline whose points value begins with a separator renders nothing
+Pass polyline with a points value of a single separator renders nothing
+Pass polyline with an empty points value renders nothing
+Pass polyline with a whitespace-only points value renders nothing
+Pass polyline with no points attribute renders nothing
Pass polyline with a points value in error does not rewrite the content attribute
-Fail polygon with an odd number of coordinates drops the last one and keeps the rest
-Fail polygon whose points value begins with a non-numeric token renders nothing
-Fail polygon whose points value begins with a separator renders nothing
-Fail polygon with a points value of a single separator renders nothing
-Fail polygon with an empty points value renders nothing
-Fail polygon with a whitespace-only points value renders nothing
-Fail polygon with no points attribute renders nothing
+Pass polygon with an odd number of coordinates drops the last one and keeps the rest
+Pass polygon whose points value begins with a non-numeric token renders nothing
+Pass polygon whose points value begins with a separator renders nothing
+Pass polygon with a points value of a single separator renders nothing
+Pass polygon with an empty points value renders nothing
+Pass polygon with a whitespace-only points value renders nothing
+Pass polygon with no points attribute renders nothing
Pass polygon with a points value in error does not rewrite the content attribute
\ No newline at end of file