Truly independent web browser
LibWeb: Implement SVGTransform and make SVGTransformList reflect
Andreas Kling4cd781c50f74
diff --git a/Libraries/LibWeb/Bindings/Rust/src/geometry/exports.rs b/Libraries/LibWeb/Bindings/Rust/src/geometry/exports.rsindex d5135079094..7b5a6a855b6 100644--- a/Libraries/LibWeb/Bindings/Rust/src/geometry/exports.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/geometry/exports.rs@@ -208,6 +208,19 @@ pub unsafe extern "C" fn web_dom_matrix_read_only_to_string(matrix: *mut c_void,true}+/// Sets the elements m11, m12, m13, m14, m21, ..., m44 of the matrix, in that order, and whether it is 2D.+///+/// # Safety+///+/// `matrix` must be the live cell of a DOMMatrix.+#[unsafe(no_mangle)]+pub unsafe extern "C" fn web_dom_matrix_set_elements(matrix: *mut c_void, elements: &[f64; 16], is_2d: bool) {+ // SAFETY: The caller passes a live cell.+ let matrix = unsafe { object_from_abi::<DOMMatrix>(matrix) }.parent();+ matrix.set_matrix(Matrix4::from_column_major(*elements));+ matrix.set_is_2d(is_2d);+}+/// Post-multiplies the other matrix to the matrix, as multiplySelf() does with the DOMMatrix of a dictionary.////// # Safetydiff --git a/Libraries/LibWeb/Geometry/DOMMatrix.cpp b/Libraries/LibWeb/Geometry/DOMMatrix.cppindex 051e878d11b..58e37d913c6 100644--- a/Libraries/LibWeb/Geometry/DOMMatrix.cpp+++ b/Libraries/LibWeb/Geometry/DOMMatrix.cpp@@ -18,6 +18,7 @@ void* web_dom_matrix_create(JSVM*, Array<double, 16> const* elements, bool is_2dvoid* web_dom_matrix_create_from_read_only(JSVM*, void const* matrix);void web_dom_matrix_multiply_self(void* matrix, void const* other);void web_dom_matrix_rotate_axis_angle_self(void* matrix, double x, double y, double z, double angle);+void web_dom_matrix_set_elements(void* matrix, Array<double, 16> const* elements, bool is_2d);}GC::Ref<DOMMatrix> DOMMatrix::create()@@ -61,4 +62,9 @@ void DOMMatrix::rotate_axis_angle_self(double x, double y, double z, double anglweb_dom_matrix_rotate_axis_angle_self(this, x, y, z, angle);}+void DOMMatrix::set_elements(Array<double, 16> const& elements, bool is_2d)+{+ web_dom_matrix_set_elements(this, &elements, is_2d);+}+}diff --git a/Libraries/LibWeb/Geometry/DOMMatrix.h b/Libraries/LibWeb/Geometry/DOMMatrix.hindex 2535e23ca79..40ec72c9c27 100644--- a/Libraries/LibWeb/Geometry/DOMMatrix.h+++ b/Libraries/LibWeb/Geometry/DOMMatrix.h@@ -37,6 +37,9 @@ public:// https://drafts.fxtf.org/geometry/#dom-dommatrix-rotateaxisangleselfvoid rotate_axis_angle_self(double x, double y, double z, double angle);++ // Sets the elements m11, m12, m13, m14, m21, ..., m44, in that order, and whether the matrix is 2D.+ void set_elements(Array<double, 16> const& elements, bool is_2d);};}diff --git a/Libraries/LibWeb/SVG/SVGAnimatedTransformList.cpp b/Libraries/LibWeb/SVG/SVGAnimatedTransformList.cppindex da1f1a09ce9..7a2bdbec234 100644--- a/Libraries/LibWeb/SVG/SVGAnimatedTransformList.cpp+++ b/Libraries/LibWeb/SVG/SVGAnimatedTransformList.cpp@@ -11,8 +11,14 @@ namespace Web::SVG {GC_DEFINE_ALLOCATOR(SVGAnimatedTransformList);-GC::Ref<SVGAnimatedTransformList> SVGAnimatedTransformList::create(GC::Ref<SVGTransformList> base_val, GC::Ref<SVGTransformList> anim_val)+// https://svgwg.org/svg2-draft/coords.html#InterfaceSVGAnimatedTransformList+GC::Ref<SVGAnimatedTransformList> SVGAnimatedTransformList::create(GC::Ref<SVGElement> element, Utf16FlyString reflected_attribute){+ // On getting baseVal or animVal, an SVGTransformList object is returned that reflects the given presentation+ // attribute.+ // NB: List interface objects reflected through the animVal IDL attribute are always read only.+ auto base_val = SVGTransformList::create(element, reflected_attribute, ReadOnlyList::No);+ auto anim_val = SVGTransformList::create(element, move(reflected_attribute), ReadOnlyList::Yes);return GC::Heap::the().allocate<SVGAnimatedTransformList>(base_val, anim_val);}@@ -29,4 +35,10 @@ void SVGAnimatedTransformList::visit_edges(Cell::Visitor& visitor)visitor.visit(m_anim_val);}+void SVGAnimatedTransformList::synchronize()+{+ m_base_val->synchronize();+ m_anim_val->synchronize();+}+}diff --git a/Libraries/LibWeb/SVG/SVGAnimatedTransformList.h b/Libraries/LibWeb/SVG/SVGAnimatedTransformList.hindex 64b9eaaa96f..1836d3fa538 100644--- a/Libraries/LibWeb/SVG/SVGAnimatedTransformList.h+++ b/Libraries/LibWeb/SVG/SVGAnimatedTransformList.h@@ -19,7 +19,7 @@ class SVGAnimatedTransformList final : public Bindings::GCAllocatedWrappable {public:static constexpr size_t base_val_offset() { return offsetof(SVGAnimatedTransformList, m_base_val); }static constexpr size_t anim_val_offset() { return offsetof(SVGAnimatedTransformList, m_anim_val); }- [[nodiscard]] static GC::Ref<SVGAnimatedTransformList> create(GC::Ref<SVGTransformList> base_val, GC::Ref<SVGTransformList> anim_val);+ [[nodiscard]] static GC::Ref<SVGAnimatedTransformList> create(GC::Ref<SVGElement>, Utf16FlyString reflected_attribute);virtual ~SVGAnimatedTransformList() override = default;GC::Ref<SVGTransformList> base_val() const@@ -32,6 +32,9 @@ public:return m_anim_val;}+ // https://svgwg.org/svg2-draft/types.html#SynchronizingReflectedValues+ void synchronize();+private:SVGAnimatedTransformList(GC::Ref<SVGTransformList> base_val, GC::Ref<SVGTransformList> anim_val);diff --git a/Libraries/LibWeb/SVG/SVGGradientElement.cpp b/Libraries/LibWeb/SVG/SVGGradientElement.cppindex 79adb91e1ae..a8b641dc5ce 100644--- a/Libraries/LibWeb/SVG/SVGGradientElement.cpp+++ b/Libraries/LibWeb/SVG/SVGGradientElement.cpp@@ -8,6 +8,7 @@#include <LibWeb/DOM/Document.h>#include <LibWeb/SVG/AttributeNames.h>#include <LibWeb/SVG/FragmentIdentifier.h>+#include <LibWeb/SVG/SVGAnimatedTransformList.h>#include <LibWeb/SVG/SVGGradientElement.h>#include <LibWeb/SVG/SVGGraphicsElement.h>#include <LibWeb/SVG/SVGUnitTypes.h>@@ -33,6 +34,8 @@ void SVGGradientElement::attribute_changed(Utf16FlyString const& name, Optional<} else {m_gradient_transform = {};}+ if (m_gradient_transform_for_bindings)+ m_gradient_transform_for_bindings->synchronize();}}@@ -155,6 +158,18 @@ void SVGGradientElement::visit_edges(Cell::Visitor& visitor){Base::visit_edges(visitor);SVGURIReferenceMixin::visit_edges(visitor);+ visitor.visit(m_gradient_transform_for_bindings);+}++// https://svgwg.org/svg2-draft/pservers.html#__svg__SVGGradientElement__gradientTransform+GC::Ref<SVGAnimatedTransformList> SVGGradientElement::gradient_transform_for_bindings()+{+ // The gradientTransform IDL attribute reflects the computed value of the transform property and the+ // 'gradientTransform' presentation attribute for ‘linearGradient’ and ‘radialGradient’ elements.+ // FIXME: Reflect the computed value of the transform property rather than only the presentation attribute.+ if (!m_gradient_transform_for_bindings)+ m_gradient_transform_for_bindings = SVGAnimatedTransformList::create(*this, AttributeNames::gradientTransform);+ return *m_gradient_transform_for_bindings;}// https://svgwg.org/svg2-draft/pservers.html#__svg__SVGGradientElement__gradientUnitsdiff --git a/Libraries/LibWeb/SVG/SVGGradientElement.h b/Libraries/LibWeb/SVG/SVGGradientElement.hindex 40d142006c0..b563551e698 100644--- a/Libraries/LibWeb/SVG/SVGGradientElement.h+++ b/Libraries/LibWeb/SVG/SVGGradientElement.h@@ -16,6 +16,8 @@namespace Web::SVG {+class SVGAnimatedTransformList;+class SVGGradientElement: public SVGElement, public SVGURIReferenceMixin<SupportsXLinkHref::Yes> {@@ -43,6 +45,7 @@ public:GC::Ref<SVGAnimatedEnumeration> gradient_units_for_bindings();GC::Ref<SVGAnimatedEnumeration> spread_method_for_bindings();+ GC::Ref<SVGAnimatedTransformList> gradient_transform_for_bindings();protected:SVGGradientElement(DOM::Document&, DOM::QualifiedName);@@ -88,6 +91,7 @@ private:Optional<SpreadMethod> m_spread_method = {};Optional<Gfx::AffineTransform> m_gradient_transform = {};+ GC::Ptr<SVGAnimatedTransformList> m_gradient_transform_for_bindings;};}diff --git a/Libraries/LibWeb/SVG/SVGGradientElement.idl b/Libraries/LibWeb/SVG/SVGGradientElement.idlindex 07ef69e86d2..febc29e56c5 100644--- a/Libraries/LibWeb/SVG/SVGGradientElement.idl+++ b/Libraries/LibWeb/SVG/SVGGradientElement.idl@@ -9,7 +9,7 @@ interface SVGGradientElement : SVGElement {const unsigned short SVG_SPREADMETHOD_REPEAT = 3;[SameObject, ImplementedAs=gradient_units_for_bindings] readonly attribute SVGAnimatedEnumeration gradientUnits;- [FIXME, SameObject] readonly attribute SVGAnimatedTransformList gradientTransform;+ [SameObject, ImplementedAs=gradient_transform_for_bindings] readonly attribute SVGAnimatedTransformList gradientTransform;[SameObject, ImplementedAs=spread_method_for_bindings] readonly attribute SVGAnimatedEnumeration spreadMethod;};diff --git a/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp b/Libraries/LibWeb/SVG/SVGGraphicsElement.cppindex 4d816e3df44..1c7fa98c7d9 100644--- a/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp+++ b/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp@@ -38,6 +38,7 @@ void SVGGraphicsElement::visit_edges(Cell::Visitor& visitor)Base::visit_edges(visitor);visitor.visit(m_required_extensions);visitor.visit(m_system_language);+ visitor.visit(m_transform);}void SVGGraphicsElement::attribute_changed(Utf16FlyString const& name, Optional<Utf16String> const& old_value, Optional<Utf16String> const& value, Optional<Utf16FlyString> const& namespace_)@@ -53,6 +54,8 @@ void SVGGraphicsElement::attribute_changed(Utf16FlyString const& name, Optional<m_required_extensions->synchronize();else if (name == AttributeNames::systemLanguage && m_system_language)m_system_language->synchronize();+ else if (name == AttributeNames::transform && m_transform)+ m_transform->synchronize();}// https://svgwg.org/svg2-draft/types.html#__svg__SVGTests__requiredExtensions@@ -219,12 +222,15 @@ WebIDL::ExceptionOr<GC::Ref<Geometry::DOMRect>> SVGGraphicsElement::get_b_box(Bireturn Geometry::DOMRect::create(rect);}-GC::Ref<SVGAnimatedTransformList> SVGGraphicsElement::transform() const+// https://svgwg.org/svg2-draft/types.html#__svg__SVGGraphicsElement__transform+GC::Ref<SVGAnimatedTransformList> SVGGraphicsElement::transform(){- dbgln("(STUBBED) SVGGraphicsElement::transform(). Called on: {}", debug_description());- auto base_val = SVGTransformList::create(ReadOnlyList::Yes);- auto anim_val = SVGTransformList::create(ReadOnlyList::Yes);- return SVGAnimatedTransformList::create(base_val, anim_val);+ // The transform IDL attribute reflects the computed value of the transform property and its corresponding+ // ‘transform’ presentation attribute.+ // FIXME: Reflect the computed value of the transform property rather than only the presentation attribute.+ if (!m_transform)+ m_transform = SVGAnimatedTransformList::create(*this, AttributeNames::transform);+ return *m_transform;}// https://svgwg.org/svg2-draft/types.html#__svg__SVGGraphicsElement__getScreenCTMdiff --git a/Libraries/LibWeb/SVG/SVGGraphicsElement.h b/Libraries/LibWeb/SVG/SVGGraphicsElement.hindex c665f38a37e..6965b17dde9 100644--- a/Libraries/LibWeb/SVG/SVGGraphicsElement.h+++ b/Libraries/LibWeb/SVG/SVGGraphicsElement.h@@ -41,7 +41,7 @@ public:}WebIDL::ExceptionOr<GC::Ref<Geometry::DOMRect>> get_b_box(Bindings::SVGBoundingBoxOptions const&);- GC::Ref<SVGAnimatedTransformList> transform() const;+ GC::Ref<SVGAnimatedTransformList> transform();GC::Ptr<Geometry::DOMMatrix> get_ctm();GC::Ptr<Geometry::DOMMatrix> get_screen_ctm();@@ -64,6 +64,7 @@ private:GC::Ptr<SVGStringList> m_required_extensions;GC::Ptr<SVGStringList> m_system_language;+ GC::Ptr<SVGAnimatedTransformList> m_transform;};Gfx::AffineTransform transform_from_transform_list(ReadonlySpan<Transform> transform_list);diff --git a/Libraries/LibWeb/SVG/SVGPatternElement.cpp b/Libraries/LibWeb/SVG/SVGPatternElement.cppindex bd7369c9989..5656502c7f0 100644--- a/Libraries/LibWeb/SVG/SVGPatternElement.cpp+++ b/Libraries/LibWeb/SVG/SVGPatternElement.cpp@@ -13,6 +13,7 @@#include <LibWeb/SVG/AttributeNames.h>#include <LibWeb/SVG/AttributeParsing.h>#include <LibWeb/SVG/FragmentIdentifier.h>+#include <LibWeb/SVG/SVGAnimatedTransformList.h>#include <LibWeb/SVG/SVGGraphicsElement.h>#include <LibWeb/SVG/SVGPatternElement.h>#include <LibWeb/SVG/SVGUnitTypes.h>@@ -36,6 +37,18 @@ void SVGPatternElement::visit_edges(Cell::Visitor& visitor)Base::visit_edges(visitor);SVGURIReferenceMixin::visit_edges(visitor);SVGFitToViewBox::visit_edges(visitor);+ visitor.visit(m_pattern_transform_for_bindings);+}++// https://svgwg.org/svg2-draft/pservers.html#__svg__SVGPatternElement__patternTransform+GC::Ref<SVGAnimatedTransformList> SVGPatternElement::pattern_transform_for_bindings()+{+ // The patternTransform IDL attribute reflects the computed value of the transform property and the+ // ‘patternTransform’ presentation attribute.+ // FIXME: Reflect the computed value of the transform property rather than only the presentation attribute.+ if (!m_pattern_transform_for_bindings)+ m_pattern_transform_for_bindings = SVGAnimatedTransformList::create(*this, AttributeNames::patternTransform);+ return *m_pattern_transform_for_bindings;}void SVGPatternElement::attribute_changed(Utf16FlyString const& name, Optional<Utf16String> const& old_value, Optional<Utf16String> const& value, Optional<Utf16FlyString> const& namespace_)@@ -53,6 +66,8 @@ void SVGPatternElement::attribute_changed(Utf16FlyString const& name, Optional<U} else {m_pattern_transform = {};}+ if (m_pattern_transform_for_bindings)+ m_pattern_transform_for_bindings->synchronize();} else if (name == AttributeNames::x) {m_x = parse_number_percentage(value.value_or({}));} else if (name == AttributeNames::y) {diff --git a/Libraries/LibWeb/SVG/SVGPatternElement.h b/Libraries/LibWeb/SVG/SVGPatternElement.hindex ab04a24ae4d..eeba4ff9771 100644--- a/Libraries/LibWeb/SVG/SVGPatternElement.h+++ b/Libraries/LibWeb/SVG/SVGPatternElement.h@@ -21,6 +21,8 @@namespace Web::SVG {+class SVGAnimatedTransformList;+class SVGPatternElement: public SVGElement, public SVGFitToViewBox@@ -53,6 +55,7 @@ public:GC::Ref<SVGAnimatedEnumeration> pattern_units_for_bindings();GC::Ref<SVGAnimatedEnumeration> pattern_content_units_for_bindings();+ GC::Ref<SVGAnimatedTransformList> pattern_transform_for_bindings();// https://w3c.github.io/svgwg/svg2-draft/pservers.html#__svg__SVGPatternElement__xREFLECT_ANIMATED_LENGTH_ATTRIBUTE(x, Horizontal, SVGLengthValue::number(0));@@ -99,6 +102,7 @@ private:Optional<SVGUnits> m_pattern_units;Optional<SVGUnits> m_pattern_content_units;Optional<Gfx::AffineTransform> m_pattern_transform;+ GC::Ptr<SVGAnimatedTransformList> m_pattern_transform_for_bindings;Optional<NumberPercentage> m_x;Optional<NumberPercentage> m_y;Optional<NumberPercentage> m_width;diff --git a/Libraries/LibWeb/SVG/SVGPatternElement.idl b/Libraries/LibWeb/SVG/SVGPatternElement.idlindex b27585667d0..31a243ded34 100644--- a/Libraries/LibWeb/SVG/SVGPatternElement.idl+++ b/Libraries/LibWeb/SVG/SVGPatternElement.idl@@ -3,7 +3,7 @@interface SVGPatternElement : SVGElement {[SameObject, ImplementedAs=pattern_units_for_bindings] readonly attribute SVGAnimatedEnumeration patternUnits;[SameObject, ImplementedAs=pattern_content_units_for_bindings] readonly attribute SVGAnimatedEnumeration patternContentUnits;- [FIXME, SameObject] readonly attribute SVGAnimatedTransformList patternTransform;+ [SameObject, ImplementedAs=pattern_transform_for_bindings] readonly attribute SVGAnimatedTransformList patternTransform;[SameObject] readonly attribute SVGAnimatedLength x;[SameObject] readonly attribute SVGAnimatedLength y;[SameObject] readonly attribute SVGAnimatedLength width;diff --git a/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Libraries/LibWeb/SVG/SVGSVGElement.cppindex a37c83ac879..c6da73055df 100644--- a/Libraries/LibWeb/SVG/SVGSVGElement.cpp+++ b/Libraries/LibWeb/SVG/SVGSVGElement.cpp@@ -361,9 +361,26 @@ GC::Ref<Geometry::DOMRect> SVGSVGElement::create_svg_rect() constGC::Ref<SVGTransform> SVGSVGElement::create_svg_transform() const{+ // A new, detached SVGTransform object whose value is matrix(1, 0, 0, 1, 0, 0).return SVGTransform::create();}+// https://svgwg.org/svg2-draft/struct.html#__svg__SVGSVGElement__createSVGTransformFromMatrix+WebIDL::ExceptionOr<GC::Ref<SVGTransform>> SVGSVGElement::create_svg_transform_from_matrix(Bindings::DOMMatrix2DInit const& matrix) const+{+ // Its behavior is the same as the createSVGTransformFromMatrix method on SVGTransformList.+ // https://svgwg.org/svg2-draft/coords.html#__svg__SVGTransformList__createSVGTransformFromMatrix+ // 1. Let transform be a newly created SVGTransform object that is detached.+ auto transform = SVGTransform::create();++ // 2. Follow the steps that would be run if the setMatrix method on transform were called, passing matrix as its+ // argument.+ TRY(transform->set_matrix(matrix));++ // 3. Return transform.+ return transform;+}+// https://www.w3.org/TR/SVG2/coords.html#SizingSVGInCSSOptional<CSSPixelFraction> SVGSVGElement::view_box_natural_aspect_ratio(SVGSVGElement const& svg_root){diff --git a/Libraries/LibWeb/SVG/SVGSVGElement.h b/Libraries/LibWeb/SVG/SVGSVGElement.hindex 8ef322f16b5..350042ed18f 100644--- a/Libraries/LibWeb/SVG/SVGSVGElement.h+++ b/Libraries/LibWeb/SVG/SVGSVGElement.h@@ -74,6 +74,7 @@ public:GC::Ref<Geometry::DOMMatrix> create_svg_matrix() const;GC::Ref<Geometry::DOMRect> create_svg_rect() const;GC::Ref<SVGTransform> create_svg_transform() const;+ WebIDL::ExceptionOr<GC::Ref<SVGTransform>> create_svg_transform_from_matrix(Bindings::DOMMatrix2DInit const&) const;// Deprecated methods that have no effect when called, but which are kept for compatibility reasons.WebIDL::UnsignedLong suspend_redraw(WebIDL::UnsignedLong max_wait_milliseconds) constdiff --git a/Libraries/LibWeb/SVG/SVGSVGElement.idl b/Libraries/LibWeb/SVG/SVGSVGElement.idlindex a18ba86beee..0c219ef4ed7 100644--- a/Libraries/LibWeb/SVG/SVGSVGElement.idl+++ b/Libraries/LibWeb/SVG/SVGSVGElement.idl@@ -23,7 +23,7 @@ interface SVGSVGElement : SVGGraphicsElement {[NewObject] DOMMatrix createSVGMatrix();[NewObject] DOMRect createSVGRect();[NewObject] SVGTransform createSVGTransform();- [FIXME, NewObject] SVGTransform createSVGTransformFromMatrix(optional DOMMatrix2DInit matrix = {});+ [NewObject] SVGTransform createSVGTransformFromMatrix(optional DOMMatrix2DInit matrix = {});Element? getElementById(DOMString elementId);diff --git a/Libraries/LibWeb/SVG/SVGTransform.cpp b/Libraries/LibWeb/SVG/SVGTransform.cppindex 8e6a3bbb762..8ba37aaf2ad 100644--- a/Libraries/LibWeb/SVG/SVGTransform.cpp+++ b/Libraries/LibWeb/SVG/SVGTransform.cpp@@ -5,75 +5,287 @@* SPDX-License-Identifier: BSD-2-Clause*/+#include <AK/Math.h>#include <LibGC/Heap.h>+#include <LibWeb/Bindings/DOMMatrixReadOnly.h>+#include <LibWeb/Geometry/DOMMatrix.h>#include <LibWeb/SVG/SVGTransform.h>+#include <LibWeb/SVG/SVGTransformList.h>namespace Web::SVG {GC_DEFINE_ALLOCATOR(SVGTransform);+// NB: The elements are m11, m12, m13, m14, m21, ..., m44, and a 2D matrix is matrix(m11, m12, m21, m22, m41, m42).+static Array<double, 16> elements_from_2d_matrix(double a, double b, double c, double d, double e, double f)+{+ return { a, b, 0, 0, c, d, 0, 0, 0, 0, 1, 0, e, f, 0, 1 };+}++SVGTransform::Value SVGTransform::Value::from_transform(Transform const& transform)+{+ // NB: The matrix is computed in double precision, so that it matches the transform function value as closely as+ // possible.+ return transform.operation.visit(+ [](Transform::Translate const& translate) {+ return Value { Type::Translate, 0, elements_from_2d_matrix(1, 0, 0, 1, translate.x, translate.y), true };+ },+ [](Transform::Scale const& scale) {+ return Value { Type::Scale, 0, elements_from_2d_matrix(scale.x, 0, 0, scale.y, 0, 0), true };+ },+ [](Transform::Rotate const& rotate) {+ // NB: This is translate(cx, cy) rotate(angle) translate(-cx, -cy).+ auto radians = AK::to_radians(static_cast<double>(rotate.a));+ auto cosine = AK::cos(radians);+ auto sine = AK::sin(radians);+ double cx = rotate.x;+ double cy = rotate.y;+ return Value { Type::Rotate, rotate.a, elements_from_2d_matrix(cosine, sine, -sine, cosine, cx - (cosine * cx) + (sine * cy), cy - (sine * cx) - (cosine * cy)), true };+ },+ [](Transform::SkewX const& skew_x) {+ return Value { Type::SkewX, skew_x.a, elements_from_2d_matrix(1, 0, AK::tan(AK::to_radians(static_cast<double>(skew_x.a))), 1, 0, 0), true };+ },+ [](Transform::SkewY const& skew_y) {+ return Value { Type::SkewY, skew_y.a, elements_from_2d_matrix(1, AK::tan(AK::to_radians(static_cast<double>(skew_y.a))), 0, 1, 0, 0), true };+ },+ [](Transform::Matrix const& matrix) {+ return Value { Type::Matrix, 0, elements_from_2d_matrix(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f), true };+ });+}++SVGTransform::Value SVGTransform::Value::from_matrix(Array<double, 16> const& elements, bool is_2d)+{+ // A matrix(…) value if the matrix is 2D, and otherwise a matrix3d(…) value, whose type is SVG_TRANSFORM_UNKNOWN.+ return Value { is_2d ? Type::Matrix : Type::Unknown, 0, elements, is_2d };+}++Gfx::AffineTransform SVGTransform::Value::affine_transform() const+{+ return { static_cast<float>(elements[0]), static_cast<float>(elements[1]), static_cast<float>(elements[4]), static_cast<float>(elements[5]), static_cast<float>(elements[12]), static_cast<float>(elements[13]) };+}+GC::Ref<SVGTransform> SVGTransform::create(){- return GC::Heap::the().allocate<SVGTransform>();+ return create(Value {});+}++GC::Ref<SVGTransform> SVGTransform::create(Value value)+{+ return GC::Heap::the().allocate<SVGTransform>(value);}-SVGTransform::SVGTransform()+SVGTransform::SVGTransform(Value value)+ : m_value(value){}SVGTransform::~SVGTransform() = default;-// https://svgwg.org/svg2-draft/single-page.html#coords-__svg__SVGTransform__type-SVGTransform::Type SVGTransform::type()+void SVGTransform::visit_edges(Cell::Visitor& visitor)+{+ Base::visit_edges(visitor);+ visitor.visit(m_matrix);+ visitor.visit(m_list);+}++SVGTransform::Value SVGTransform::value() const+{+ // An SVGTransform object's matrix object is always kept synchronized with its value.+ // FIXME: Have the matrix object update the value when it is modified, so that a presentation attribute that the+ // transform reflects is reserialized at that point. For now, the value catches up when it is next read.+ // FIXME: It should not be possible to modify the matrix object of a read only SVGTransform. Until it is prevented,+ // changes to it are not adopted into the value, so that a read only SVGTransform cannot be modified.+ if (m_matrix && m_read_only == ReadOnly::No) {+ auto elements = m_matrix->elements();+ auto is_2d = m_matrix->is2d();+ if (elements != m_value.elements || is_2d != m_value.is_2d)+ m_value = Value::from_matrix(elements, is_2d);+ }+ return m_value;+}++void SVGTransform::set_value(Value value)+{+ m_value = value;+ if (m_matrix)+ m_matrix->set_elements(m_value.elements, m_value.is_2d);+}++void SVGTransform::set_value_from_reflected_attribute(Value value)+{+ // 3. Set item's value to v.+ // 4. If item is an SVGTransform object, then set the components of its matrix object to match the new transform+ // function value.+ set_value(value);+}++// https://svgwg.org/svg2-draft/types.html#TermAttach+void SVGTransform::attach(GC::Ref<SVGTransformList> list, ReadOnly read_only)+{+ // Associate the SVGTransform with the element that the list interface object is associated with. Set the+ // SVGTransform to reflect an element of a presentation attribute value.+ // NB: Items of a list that is read only are read only too.+ m_list = list;+ m_read_only = read_only;+}++// https://svgwg.org/svg2-draft/types.html#TermDetach+void SVGTransform::detach()+{+ // Set the SVGTransform to no longer be associated with any element. If the SVGTransform is read only, set it to be+ // no longer read only.+ m_list = nullptr;+ m_read_only = ReadOnly::No;+}++// https://svgwg.org/svg2-draft/coords.html#__svg__SVGTransform__type+SVGTransform::Type SVGTransform::type() const{- dbgln("FIXME: Implement SVGTransform::type()");- return SVGTransform::Type::Unknown;+ // 1. If the SVGTransform's value is a matrix(…), translate(…), scale(…), rotate(…), skewX(…) or skewY(…) function,+ // then return the corresponding constant value from the transform type table above.+ // 2. Otherwise, return SVG_TRANSFORM_UNKNOWN.+ return value().type;}-// https://svgwg.org/svg2-draft/single-page.html#coords-__svg__SVGTransform__angle-float SVGTransform::angle()+// https://svgwg.org/svg2-draft/coords.html#__svg__SVGTransform__matrix+GC::Ref<Geometry::DOMMatrix> SVGTransform::matrix(){- dbgln("FIXME: Implement SVGTransform::angle()");+ // The matrix IDL attribute represents the transform as a 4x4 homogeneous matrix, and on getting returns the+ // SVGTransform's matrix object. When the matrix object is first created, its values are set to match the+ // SVGTransform's transform function value, and is set to reflects the SVGTransform.+ if (!m_matrix) {+ Gfx::DoubleMatrix4x4 matrix;+ for (size_t row = 0; row < 4; ++row) {+ for (size_t column = 0; column < 4; ++column)+ matrix[row, column] = m_value.elements[(column * 4) + row];+ }+ m_matrix = Geometry::DOMMatrix::create(matrix, m_value.is_2d);+ }+ return *m_matrix;+}++// https://svgwg.org/svg2-draft/coords.html#__svg__SVGTransform__angle+float SVGTransform::angle() const+{+ // 1. If the SVGTransform object's value is a rotate(…), skewX(…) or skewY(…) function, return its angle argument+ // in degrees.+ auto value = this->value();+ if (value.type == Type::Rotate || value.type == Type::SkewX || value.type == Type::SkewY)+ return value.angle;++ // 2. Otherwise, return 0.return 0;}-// https://svgwg.org/svg2-draft/single-page.html#coords-__svg__SVGTransform__setTranslate-void SVGTransform::set_translate(float tx, float ty)+WebIDL::ExceptionOr<void> SVGTransform::set_value_and_reserialize(Value value)+{+ // 1. If the SVGTransform object is read only, then throw a NoModificationAllowedError.+ if (m_read_only == ReadOnly::Yes)+ return WebIDL::NoModificationAllowedError::create("Cannot modify a read-only SVGTransform"_utf16);++ // 2. Set the SVGTransform object's value to a new transform function value.+ // 3. Set the components of the SVGTransform object's matrix object to match the new transform function value.+ set_value(value);++ // 4. If the SVGTransform object reflects an element of a presentation attribute value, then reserialize the+ // reflected attribute.+ if (m_list)+ m_list->reserialize_reflected_attribute();+ return {};+}++// https://drafts.fxtf.org/geometry/#validate-and-fixup-2d+static WebIDL::ExceptionOr<Array<double, 6>> validate_and_fixup_2d(Bindings::DOMMatrix2DInit const& dict)+{+ // 1. If if at least one of the following conditions are true for dict, then throw a TypeError exception and abort+ // these steps.+ // - a and m11 are both present and SameValueZero(a, m11) is false.+ // - b and m12 are both present and SameValueZero(b, m12) is false.+ // - c and m21 are both present and SameValueZero(c, m21) is false.+ // - d and m22 are both present and SameValueZero(d, m22) is false.+ // - e and m41 are both present and SameValueZero(e, m41) is false.+ // - f and m42 are both present and SameValueZero(f, m42) is false.+ auto same_value_zero = [](double x, double y) { return (isnan(x) && isnan(y)) || x == y; };+ auto conflicts = [&](Optional<double> const& x, Optional<double> const& y) {+ return x.has_value() && y.has_value() && !same_value_zero(*x, *y);+ };+ if (conflicts(dict.a, dict.m11) || conflicts(dict.b, dict.m12) || conflicts(dict.c, dict.m21)+ || conflicts(dict.d, dict.m22) || conflicts(dict.e, dict.m41) || conflicts(dict.f, dict.m42))+ return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "DOMMatrix2DInit has conflicting members"_utf16 };++ // 2. If m11 is not present then set it to the value of member a, or value 1 if a is also not present.+ // 3. If m12 is not present then set it to the value of member b, or value 0 if b is also not present.+ // 4. If m21 is not present then set it to the value of member c, or value 0 if c is also not present.+ // 5. If m22 is not present then set it to the value of member d, or value 1 if d is also not present.+ // 6. If m41 is not present then set it to the value of member e, or value 0 if e is also not present.+ // 7. If m42 is not present then set it to the value of member f, or value 0 if f is also not present.+ return Array<double, 6> {+ dict.m11.value_or(dict.a.value_or(1)),+ dict.m12.value_or(dict.b.value_or(0)),+ dict.m21.value_or(dict.c.value_or(0)),+ dict.m22.value_or(dict.d.value_or(1)),+ dict.m41.value_or(dict.e.value_or(0)),+ dict.m42.value_or(dict.f.value_or(0)),+ };+}++// https://svgwg.org/svg2-draft/coords.html#__svg__SVGTransform__setMatrix+WebIDL::ExceptionOr<void> SVGTransform::set_matrix(Bindings::DOMMatrix2DInit const& matrix)+{+ // 1. If the SVGTransform object is read only, then throw a NoModificationAllowedError.+ if (m_read_only == ReadOnly::Yes)+ return WebIDL::NoModificationAllowedError::create("Cannot modify a read-only SVGTransform"_utf16);++ // 2. Let newMatrix be the result of DOMMatrixReadOnly.fromMatrix(matrix), including the validate and fix-up steps+ // for missing values. If that method throws an error, then re-throw that error and abort these steps.+ // NB: A DOMMatrix2DInit always results in a 2D matrix.+ auto new_matrix = TRY(validate_and_fixup_2d(matrix));++ // 3. If newMatrix.is2D() would return true, then set the SVGTransform object's value to a matrix(…) value that+ // represents the same matrix as newMatrix.+ // 4. In either case, matrix object gets synchronized to the SVGTransform object's value.+ set_value(Value { Type::Matrix, 0, { new_matrix[0], new_matrix[1], 0, 0, new_matrix[2], new_matrix[3], 0, 0, 0, 0, 1, 0, new_matrix[4], new_matrix[5], 0, 1 }, true });++ // 5. If the SVGTransform object reflects a presentation attribute value of an element, then reserialize the+ // reflected attribute.+ if (m_list)+ m_list->reserialize_reflected_attribute();+ return {};+}++// https://svgwg.org/svg2-draft/coords.html#__svg__SVGTransform__setTranslate+WebIDL::ExceptionOr<void> SVGTransform::set_translate(float tx, float ty){- (void)tx;- (void)ty;- dbgln("FIXME: Implement SVGTransform::set_translate(float tx, float ty)");+ // setTranslate(tx, ty): the new transform function value is translate(tx, ty)+ return set_value_and_reserialize(Value::from_transform({ Transform::Translate { tx, ty } }));}-// https://svgwg.org/svg2-draft/single-page.html#coords-__svg__SVGTransform__setScale-void SVGTransform::set_scale(float sx, float sy)+// https://svgwg.org/svg2-draft/coords.html#__svg__SVGTransform__setScale+WebIDL::ExceptionOr<void> SVGTransform::set_scale(float sx, float sy){- (void)sx;- (void)sy;- dbgln("FIXME: Implement SVGTransform::set_scale(float sx, float sy)");+ // setScale(sx, sy): the new transform function value is scale(sx, sy)+ return set_value_and_reserialize(Value::from_transform({ Transform::Scale { sx, sy } }));}-// https://svgwg.org/svg2-draft/single-page.html#coords-__svg__SVGTransform__setRotate-void SVGTransform::set_rotate(float angle, float cx, float cy)+// https://svgwg.org/svg2-draft/coords.html#__svg__SVGTransform__setRotate+WebIDL::ExceptionOr<void> SVGTransform::set_rotate(float angle, float cx, float cy){- (void)angle;- (void)cx;- (void)cy;- dbgln("FIXME: Implement SVGTransform::set_rotate(float angle, float cx, float cy)");+ // setRotate(angle, cx, cy): the new transform function value is rotate(angle, cx, cy)+ return set_value_and_reserialize(Value::from_transform({ Transform::Rotate { angle, cx, cy } }));}-// https://svgwg.org/svg2-draft/single-page.html#coords-__svg__SVGTransform__setSkewX-void SVGTransform::set_skew_x(float angle)+// https://svgwg.org/svg2-draft/coords.html#__svg__SVGTransform__setSkewX+WebIDL::ExceptionOr<void> SVGTransform::set_skew_x(float angle){- (void)angle;- dbgln("FIXME: Implement SVGTransform::set_skew_x(float angle)");+ // setSkewX(angle): the new transform function value is skewX(angle)+ return set_value_and_reserialize(Value::from_transform({ Transform::SkewX { angle } }));}-// https://svgwg.org/svg2-draft/single-page.html#coords-__svg__SVGTransform__setSkewY-void SVGTransform::set_skew_y(float angle)+// https://svgwg.org/svg2-draft/coords.html#__svg__SVGTransform__setSkewY+WebIDL::ExceptionOr<void> SVGTransform::set_skew_y(float angle){- (void)angle;- dbgln("FIXME: Implement SVGTransform::set_skew_y(float angle)");+ // setSkewY(angle): the new transform function value is skewY(angle)+ return set_value_and_reserialize(Value::from_transform({ Transform::SkewY { angle } }));}}diff --git a/Libraries/LibWeb/SVG/SVGTransform.h b/Libraries/LibWeb/SVG/SVGTransform.hindex f8bb87a696f..30c39714e9b 100644--- a/Libraries/LibWeb/SVG/SVGTransform.h+++ b/Libraries/LibWeb/SVG/SVGTransform.h@@ -7,20 +7,27 @@#pragma once+#include <AK/Array.h>+#include <LibGfx/AffineTransform.h>#include <LibWeb/Bindings/Wrappable.h>+#include <LibWeb/Forward.h>+#include <LibWeb/SVG/AttributeParsing.h>+#include <LibWeb/WebIDL/ExceptionOr.h>++namespace Web::Bindings {++struct DOMMatrix2DInit;++}namespace Web::SVG {-// FIXME: This class is just a stub.-// https://svgwg.org/svg2-draft/single-page.html#coords-InterfaceSVGTransform+// https://svgwg.org/svg2-draft/coords.html#InterfaceSVGTransformclass SVGTransform final : public Bindings::GCAllocatedWrappable {WEB_WRAPPABLE(SVGTransform, Bindings::GCAllocatedWrappable);GC_DECLARE_ALLOCATOR(SVGTransform);public:- [[nodiscard]] static GC::Ref<SVGTransform> create();- virtual ~SVGTransform() override;-enum class Type : u16 {Unknown = 0,Matrix = 1,@@ -31,17 +38,72 @@ public:SkewY = 6,};- Type type();- float angle();+ enum class ReadOnly : u8 {+ Yes,+ No,+ };++ // A <transform-function> value: its type, the angle argument of a rotate(), skewX() or skewY() function, and its+ // matrix as the elements m11, m12, m13, m14, m21, ..., m44, in that order.+ struct Value {+ Type type { Type::Matrix };+ float angle { 0 };+ Array<double, 16> elements { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };+ bool is_2d { true };- void set_translate(float tx, float ty);- void set_scale(float sx, float sy);- void set_rotate(float angle, float cx, float cy);- void set_skew_x(float angle);- void set_skew_y(float angle);+ static Value from_transform(Transform const&);+ static Value from_matrix(Array<double, 16> const& elements, bool is_2d);+ Gfx::AffineTransform affine_transform() const;++ bool operator==(Value const&) const = default;+ };++ // A new, detached SVGTransform object whose value is matrix(1, 0, 0, 1, 0, 0).+ [[nodiscard]] static GC::Ref<SVGTransform> create();+ [[nodiscard]] static GC::Ref<SVGTransform> create(Value);+ virtual ~SVGTransform() override;++ Type type() const;+ GC::Ref<Geometry::DOMMatrix> matrix();+ float angle() const;++ WebIDL::ExceptionOr<void> set_matrix(Bindings::DOMMatrix2DInit const&);+ WebIDL::ExceptionOr<void> set_translate(float tx, float ty);+ WebIDL::ExceptionOr<void> set_scale(float sx, float sy);+ WebIDL::ExceptionOr<void> set_rotate(float angle, float cx, float cy);+ WebIDL::ExceptionOr<void> set_skew_x(float angle);+ WebIDL::ExceptionOr<void> set_skew_y(float angle);++ Value value() const;++ // https://svgwg.org/svg2-draft/types.html#TermAttach+ void attach(GC::Ref<SVGTransformList>, ReadOnly);++ // https://svgwg.org/svg2-draft/types.html#TermDetach+ void detach();++ bool is_detached() const { return !m_list; }++ // Sets the value when the list this transform belongs to is synchronized with its reflected attribute.+ void set_value_from_reflected_attribute(Value);private:- SVGTransform();+ explicit SVGTransform(Value);++ virtual void visit_edges(Cell::Visitor&) override;++ WebIDL::ExceptionOr<void> set_value_and_reserialize(Value);+ void set_value(Value);++ mutable Value m_value;++ // https://svgwg.org/svg2-draft/coords.html#TransformMatrixObject+ GC::Ptr<Geometry::DOMMatrix> m_matrix;++ // The list this transform is an element of, if it reflects an element of a presentation attribute value.+ GC::Ptr<SVGTransformList> m_list;++ ReadOnly m_read_only { ReadOnly::No };};}diff --git a/Libraries/LibWeb/SVG/SVGTransform.idl b/Libraries/LibWeb/SVG/SVGTransform.idlindex 865177bf2f4..b72d9b8104c 100644--- a/Libraries/LibWeb/SVG/SVGTransform.idl+++ b/Libraries/LibWeb/SVG/SVGTransform.idl@@ -11,10 +11,10 @@ interface SVGTransform {const unsigned short SVG_TRANSFORM_SKEWY = 6;readonly attribute unsigned short type;- [FIXME, SameObject] readonly attribute DOMMatrix matrix;+ [SameObject] readonly attribute DOMMatrix matrix;readonly attribute float angle;- [FIXME] undefined setMatrix(optional DOMMatrix2DInit matrix = {});+ undefined setMatrix(optional DOMMatrix2DInit matrix = {});undefined setTranslate(float tx, float ty);undefined setScale(float sx, float sy);undefined setRotate(float angle, float cx, float cy);diff --git a/Libraries/LibWeb/SVG/SVGTransformList.cpp b/Libraries/LibWeb/SVG/SVGTransformList.cppindex dfd1f0e5ee1..8bef99e19c1 100644--- a/Libraries/LibWeb/SVG/SVGTransformList.cpp+++ b/Libraries/LibWeb/SVG/SVGTransformList.cpp@@ -5,38 +5,155 @@* SPDX-License-Identifier: BSD-2-Clause*/+#include <AK/TemporaryChange.h>+#include <AK/Utf16StringBuilder.h>#include <LibGC/Heap.h>-#include <LibWeb/SVG/SVGTransform.h>+#include <LibWeb/Geometry/DOMMatrix.h>+#include <LibWeb/SVG/AttributeParsing.h>+#include <LibWeb/SVG/SVGElement.h>#include <LibWeb/SVG/SVGTransformList.h>namespace Web::SVG {GC_DEFINE_ALLOCATOR(SVGTransformList);-GC::Ref<SVGTransformList> SVGTransformList::create(GC::Ref<List> items, ReadOnlyList read_only)+GC::Ref<SVGTransformList> SVGTransformList::create(GC::Ref<SVGElement> element, Utf16FlyString reflected_attribute, ReadOnlyList read_only){- return GC::Heap::the().allocate<SVGTransformList>(items, read_only);+ return GC::Heap::the().allocate<SVGTransformList>(element, move(reflected_attribute), read_only);}-GC::Ref<SVGTransformList> SVGTransformList::create(ReadOnlyList read_only)+SVGTransformList::SVGTransformList(GC::Ref<SVGElement> element, Utf16FlyString reflected_attribute, ReadOnlyList read_only)+ : SVGList(read_only)+ , m_element(element)+ , m_reflected_attribute(move(reflected_attribute)){- return GC::Heap::the().allocate<SVGTransformList>(read_only);+ synchronize();}-SVGTransformList::SVGTransformList(GC::Ref<List> items, ReadOnlyList read_only)- : SVGList(move(items->elements()), read_only)+void SVGTransformList::visit_edges(Visitor& visitor){+ Base::visit_edges(visitor);+ SVGList::visit_edges(visitor);+ visitor.visit(m_element);}-SVGTransformList::SVGTransformList(ReadOnlyList read_only)- : SVGList(read_only)+void SVGTransformList::attach(GC::Ref<SVGTransform> const& transform){+ transform->attach(*this, read_only() == ReadOnlyList::Yes ? SVGTransform::ReadOnly::Yes : SVGTransform::ReadOnly::No);}-void SVGTransformList::visit_edges(Visitor& visitor)+void SVGTransformList::detach(GC::Ref<SVGTransform> const& transform){- Base::visit_edges(visitor);- SVGList::visit_edges(visitor);+ transform->detach();+}++GC::Ref<SVGTransform> SVGTransformList::copy_if_not_detached(GC::Ref<SVGTransform> transform)+{+ if (transform->is_detached())+ return transform;+ return SVGTransform::create(transform->value());+}++// https://svgwg.org/svg2-draft/types.html#TermSynchronizeList+void SVGTransformList::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).+ // NB: The initial value of the transform presentation attributes is none, which is also what an invalid value is+ // treated as. A value of none has no transform functions.+ Vector<SVGTransform::Value> value;+ if (auto transforms = parse_transform(m_element->get_attribute_value(m_reflected_attribute)); transforms.has_value()) {+ value.ensure_capacity(transforms->size());+ for (auto const& transform : *transforms)+ value.unchecked_append(SVGTransform::Value::from_transform(transform));+ }++ synchronize_items(value, [] { return SVGTransform::create(); }, [](GC::Ref<SVGTransform> const& item, SVGTransform::Value const& transform) { item->set_value_from_reflected_attribute(transform); });+}++// https://svgwg.org/svg2-draft/types.html#TermReserialize+void SVGTransformList::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 SVGTransform object: The string is the serialization of the SVGTransform object's matrix object.+ // 3. Set the content attribute to a string consisting of the strings in serialized elements joined and separated by+ // single U+0020 SPACE characters.+ Utf16StringBuilder builder;+ for (size_t index = 0; index < items().size(); ++index) {+ auto serialization = items()[index]->matrix()->to_string();+ // AD-HOC: The serialization of a matrix object throws if one of its components is not finite, and the spec+ // does not say what to do then. We leave out such an item.+ if (serialization.is_error())+ continue;+ if (!builder.is_empty())+ builder.append_code_unit(' ');+ builder.append(serialization.value());+ }++ TemporaryChange change { m_is_reserializing, true };+ m_element->set_attribute_value(m_reflected_attribute, builder.to_string());+}++// https://svgwg.org/svg2-draft/coords.html#__svg__SVGTransformList__createSVGTransformFromMatrix+WebIDL::ExceptionOr<GC::Ref<SVGTransform>> SVGTransformList::create_svg_transform_from_matrix(Bindings::DOMMatrix2DInit const& matrix)+{+ // 1. Let transform be a newly created SVGTransform object that is detached.+ auto transform = SVGTransform::create();++ // 2. Follow the steps that would be run if the setMatrix method on transform were called, passing matrix as its+ // argument.+ TRY(transform->set_matrix(matrix));++ // 3. Return transform.+ return transform;+}++// https://svgwg.org/svg2-draft/coords.html#__svg__SVGTransformList__consolidate+WebIDL::ExceptionOr<GC::Ptr<SVGTransform>> SVGTransformList::consolidate()+{+ // 1. If the SVGTransformList object is read only, then throw a NoModificationAllowedError.+ if (read_only() == ReadOnlyList::Yes)+ return WebIDL::NoModificationAllowedError::create("Cannot modify a read-only list"_utf16);++ // 2. If the list is empty, return null.+ if (items().is_empty())+ return nullptr;++ // 3. Detach and then remove all elements in the list.+ // NB: The matrix is computed from the elements before they are removed.+ // 4. Let transform be a newly created SVGTransform object.+ // 5. Let matrix be the matrix value obtained by beginning with an identity matrix, and then post-multiplying the+ // value of the matrix object for each SVGTransform in the list, in order.+ auto matrix = Geometry::DOMMatrix::create();+ for (auto const& item : items())+ matrix->multiply_self(item->matrix());+ for (auto const& item : items())+ detach(item);+ mutable_items().clear();++ // 6. Set the components of transform's matrix object to the component values in matrix.+ // 7. If transform's matrix object would return true from its is2d method, then set transform's value to a+ // matrix(…) value that represents the same matrix as the matrix object.+ // 8. Otherwise, set transform's value to a matrix3d(…) value that represents the same matrix as the matrix object.+ auto transform = SVGTransform::create(SVGTransform::Value::from_matrix(matrix->elements(), matrix->is2d()));++ // 9. Attach transform to this SVGTransformList.+ attach(transform);++ // 10. Append transform to this list.+ mutable_items().append(transform);++ // 11. If the list reflects a presentation attribute, then reserialize the reflected attribute.+ reserialize_reflected_attribute();++ // 12. Return transform.+ return transform;}}diff --git a/Libraries/LibWeb/SVG/SVGTransformList.h b/Libraries/LibWeb/SVG/SVGTransformList.hindex e77f00bd114..8b80b17f68e 100644--- a/Libraries/LibWeb/SVG/SVGTransformList.h+++ b/Libraries/LibWeb/SVG/SVGTransformList.h@@ -7,14 +7,14 @@#pragma once-#include <LibGC/HeapVector.h>+#include <AK/Utf16FlyString.h>#include <LibWeb/Bindings/Wrappable.h>#include <LibWeb/SVG/SVGList.h>#include <LibWeb/SVG/SVGTransform.h>namespace Web::SVG {-// https://svgwg.org/svg2-draft/single-page.html#coords-InterfaceSVGTransformList+// https://svgwg.org/svg2-draft/coords.html#InterfaceSVGTransformListclass SVGTransformList final: public Bindings::GCAllocatedWrappable, public SVGList<GC::Ref<SVGTransform>> {@@ -22,17 +22,30 @@ class SVGTransformList finalGC_DECLARE_ALLOCATOR(SVGTransformList);public:- using List = GC::HeapVector<GC::Ref<SVGTransform>>;-- [[nodiscard]] static GC::Ref<SVGTransformList> create(GC::Ref<List>, ReadOnlyList);- [[nodiscard]] static GC::Ref<SVGTransformList> create(ReadOnlyList);+ [[nodiscard]] static GC::Ref<SVGTransformList> create(GC::Ref<SVGElement>, Utf16FlyString reflected_attribute, ReadOnlyList);virtual ~SVGTransformList() override = default;+ WebIDL::ExceptionOr<GC::Ref<SVGTransform>> create_svg_transform_from_matrix(Bindings::DOMMatrix2DInit const&);+ WebIDL::ExceptionOr<GC::Ptr<SVGTransform>> consolidate();++ // 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:- SVGTransformList(GC::Ref<List>, ReadOnlyList);- explicit SVGTransformList(ReadOnlyList);+ SVGTransformList(GC::Ref<SVGElement>, Utf16FlyString reflected_attribute, ReadOnlyList);virtual void visit_edges(Visitor&) override;++ virtual void attach(GC::Ref<SVGTransform> const&) override;+ virtual void detach(GC::Ref<SVGTransform> const&) override;+ virtual GC::Ref<SVGTransform> copy_if_not_detached(GC::Ref<SVGTransform>) override;++ GC::Ref<SVGElement> m_element;+ Utf16FlyString m_reflected_attribute;+ bool m_is_reserializing { false };};}diff --git a/Libraries/LibWeb/SVG/SVGTransformList.idl b/Libraries/LibWeb/SVG/SVGTransformList.idlindex 5779732e9e9..2f9a93da4bc 100644--- a/Libraries/LibWeb/SVG/SVGTransformList.idl+++ b/Libraries/LibWeb/SVG/SVGTransformList.idl@@ -14,6 +14,6 @@ interface SVGTransformList {setter undefined (unsigned long index, SVGTransform newItem);// Additional methods not common to other list interfaces.- [FIXME] SVGTransform createSVGTransformFromMatrix(optional DOMMatrix2DInit matrix = {});- [FIXME] SVGTransform? consolidate();+ SVGTransform createSVGTransformFromMatrix(optional DOMMatrix2DInit matrix = {});+ SVGTransform? consolidate();};diff --git a/Tests/LibWeb/Text/expected/SVG/svg-transform-list-indexed-setter.txt b/Tests/LibWeb/Text/expected/SVG/svg-transform-list-indexed-setter.txtindex 464e8b17d7e..2af16e71622 100644--- a/Tests/LibWeb/Text/expected/SVG/svg-transform-list-indexed-setter.txt+++ b/Tests/LibWeb/Text/expected/SVG/svg-transform-list-indexed-setter.txt@@ -1,5 +1,5 @@baseVal === animVal: falseinitial length: 0-transform type: 0-new index: NoModificationAllowedError: Cannot modify a read-only list+transform type: 1+new index: IndexSizeError: List index out of boundswrong type: TypeError: Value must be an SVGTransformdiff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/coordinate-systems/SVGTransformList.list-01.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/coordinate-systems/SVGTransformList.list-01.txtindex 79d051bd985..b184abec33f 100644--- a/Tests/LibWeb/Text/expected/wpt-import/svg/coordinate-systems/SVGTransformList.list-01.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/svg/coordinate-systems/SVGTransformList.list-01.txt@@ -2,19 +2,18 @@ Harness status: OKFound 14 tests-6 Pass-8 Fail-Fail SVGTransformList interface, animVal distinct from baseVal+14 Pass+Pass SVGTransformList interface, animVal distinct from baseValPass SVGTransformList interface, animVal is read-only-Fail SVGTransformList interface, legacy getters / list length+Pass SVGTransformList interface, legacy getters / list lengthPass SVGTransformList interface, initialize() invalid arguments-Fail SVGTransformList interface, getItem() arguments+Pass SVGTransformList interface, getItem() argumentsPass SVGTransformList interface, insertItemBefore() invalid arguments-Fail SVGTransformList interface, insertItemBefore()+Pass SVGTransformList interface, insertItemBefore()Pass SVGTransformList interface, replaceItem() invalid argumentsPass SVGTransformList interface, indexed setter-Fail SVGTransformList interface, replaceItem()-Fail SVGTransformList interface, removeItem()+Pass SVGTransformList interface, replaceItem()+Pass SVGTransformList interface, removeItem()Pass SVGTransformList interface, appendItem() invalid arguments-Fail SVGTransformList interface, appendItem()-Fail SVGTransformList interface, clear()\ No newline at end of file+Pass SVGTransformList interface, appendItem()+Pass SVGTransformList interface, clear()\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txtindex 7902a116969..dd761cea265 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-1490 Pass-290 Fail+1529 Pass+251 FailPass idl_test setupPass idl_test validationPass Partial interface Document: original interface defined@@ -424,7 +424,7 @@ Pass SVGSVGElement interface: operation createSVGPoint()Pass SVGSVGElement interface: operation createSVGMatrix()Pass SVGSVGElement interface: operation createSVGRect()Pass SVGSVGElement interface: operation createSVGTransform()-Fail SVGSVGElement interface: operation createSVGTransformFromMatrix(optional DOMMatrix2DInit)+Pass SVGSVGElement interface: operation createSVGTransformFromMatrix(optional DOMMatrix2DInit)Pass SVGSVGElement interface: operation getElementById(DOMString)Pass SVGSVGElement interface: operation suspendRedraw(unsigned long)Pass SVGSVGElement interface: operation unsuspendRedraw(unsigned long)@@ -461,8 +461,8 @@ Pass SVGSVGElement interface: objects.svg must inherit property "createSVGPoint(Pass SVGSVGElement interface: objects.svg must inherit property "createSVGMatrix()" with the proper typePass SVGSVGElement interface: objects.svg must inherit property "createSVGRect()" with the proper typePass SVGSVGElement interface: objects.svg must inherit property "createSVGTransform()" with the proper type-Fail SVGSVGElement interface: objects.svg must inherit property "createSVGTransformFromMatrix(optional DOMMatrix2DInit)" with the proper type-Fail SVGSVGElement interface: calling createSVGTransformFromMatrix(optional DOMMatrix2DInit) on objects.svg with too few arguments must throw TypeError+Pass SVGSVGElement interface: objects.svg must inherit property "createSVGTransformFromMatrix(optional DOMMatrix2DInit)" with the proper type+Pass SVGSVGElement interface: calling createSVGTransformFromMatrix(optional DOMMatrix2DInit) on objects.svg with too few arguments must throw TypeErrorPass SVGSVGElement interface: objects.svg must inherit property "getElementById(DOMString)" with the proper typePass SVGSVGElement interface: calling getElementById(DOMString) on objects.svg with too few arguments must throw TypeErrorPass SVGSVGElement interface: objects.svg must inherit property "suspendRedraw(unsigned long)" with the proper type@@ -703,9 +703,9 @@ Pass SVGTransform interface: constant SVG_TRANSFORM_SKEWX on interface prototypePass SVGTransform interface: constant SVG_TRANSFORM_SKEWY on interface objectPass SVGTransform interface: constant SVG_TRANSFORM_SKEWY on interface prototype objectPass SVGTransform interface: attribute type-Fail SVGTransform interface: attribute matrix+Pass SVGTransform interface: attribute matrixPass SVGTransform interface: attribute angle-Fail SVGTransform interface: operation setMatrix(optional DOMMatrix2DInit)+Pass SVGTransform interface: operation setMatrix(optional DOMMatrix2DInit)Pass SVGTransform interface: operation setTranslate(float, float)Pass SVGTransform interface: operation setScale(float, float)Pass SVGTransform interface: operation setRotate(float, float, float)@@ -721,10 +721,10 @@ Pass SVGTransform interface: objects.svg.createSVGTransform() must inherit propePass SVGTransform interface: objects.svg.createSVGTransform() must inherit property "SVG_TRANSFORM_SKEWX" with the proper typePass SVGTransform interface: objects.svg.createSVGTransform() must inherit property "SVG_TRANSFORM_SKEWY" with the proper typePass SVGTransform interface: objects.svg.createSVGTransform() must inherit property "type" with the proper type-Fail SVGTransform interface: objects.svg.createSVGTransform() must inherit property "matrix" with the proper type+Pass SVGTransform interface: objects.svg.createSVGTransform() must inherit property "matrix" with the proper typePass SVGTransform interface: objects.svg.createSVGTransform() must inherit property "angle" with the proper type-Fail SVGTransform interface: objects.svg.createSVGTransform() must inherit property "setMatrix(optional DOMMatrix2DInit)" with the proper type-Fail SVGTransform interface: calling setMatrix(optional DOMMatrix2DInit) on objects.svg.createSVGTransform() with too few arguments must throw TypeError+Pass SVGTransform interface: objects.svg.createSVGTransform() must inherit property "setMatrix(optional DOMMatrix2DInit)" with the proper type+Pass SVGTransform interface: calling setMatrix(optional DOMMatrix2DInit) on objects.svg.createSVGTransform() with too few arguments must throw TypeErrorPass SVGTransform interface: objects.svg.createSVGTransform() must inherit property "setTranslate(float, float)" with the proper typePass SVGTransform interface: calling setTranslate(float, float) on objects.svg.createSVGTransform() with too few arguments must throw TypeErrorPass SVGTransform interface: objects.svg.createSVGTransform() must inherit property "setScale(float, float)" with the proper type@@ -750,28 +750,28 @@ Pass SVGTransformList interface: operation insertItemBefore(SVGTransform, unsignPass SVGTransformList interface: operation replaceItem(SVGTransform, unsigned long)Pass SVGTransformList interface: operation removeItem(unsigned long)Pass SVGTransformList interface: operation appendItem(SVGTransform)-Fail SVGTransformList interface: operation createSVGTransformFromMatrix(optional DOMMatrix2DInit)-Fail SVGTransformList interface: operation consolidate()-Fail SVGTransformList must be primary interface of objects.pattern.patternTransform.baseVal-Fail Stringification of objects.pattern.patternTransform.baseVal-Fail SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "length" with the proper type-Fail SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "numberOfItems" with the proper type-Fail SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "clear()" with the proper type-Fail SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "initialize(SVGTransform)" with the proper type-Fail SVGTransformList interface: calling initialize(SVGTransform) on objects.pattern.patternTransform.baseVal with too few arguments must throw TypeError-Fail SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "getItem(unsigned long)" with the proper type-Fail SVGTransformList interface: calling getItem(unsigned long) on objects.pattern.patternTransform.baseVal with too few arguments must throw TypeError-Fail SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "insertItemBefore(SVGTransform, unsigned long)" with the proper type-Fail SVGTransformList interface: calling insertItemBefore(SVGTransform, unsigned long) on objects.pattern.patternTransform.baseVal with too few arguments must throw TypeError-Fail SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "replaceItem(SVGTransform, unsigned long)" with the proper type-Fail SVGTransformList interface: calling replaceItem(SVGTransform, unsigned long) on objects.pattern.patternTransform.baseVal with too few arguments must throw TypeError-Fail SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "removeItem(unsigned long)" with the proper type-Fail SVGTransformList interface: calling removeItem(unsigned long) on objects.pattern.patternTransform.baseVal with too few arguments must throw TypeError-Fail SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "appendItem(SVGTransform)" with the proper type-Fail SVGTransformList interface: calling appendItem(SVGTransform) on objects.pattern.patternTransform.baseVal with too few arguments must throw TypeError-Fail SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "createSVGTransformFromMatrix(optional DOMMatrix2DInit)" with the proper type-Fail SVGTransformList interface: calling createSVGTransformFromMatrix(optional DOMMatrix2DInit) on objects.pattern.patternTransform.baseVal with too few arguments must throw TypeError-Fail SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "consolidate()" with the proper type+Pass SVGTransformList interface: operation createSVGTransformFromMatrix(optional DOMMatrix2DInit)+Pass SVGTransformList interface: operation consolidate()+Pass SVGTransformList must be primary interface of objects.pattern.patternTransform.baseVal+Pass Stringification of objects.pattern.patternTransform.baseVal+Pass SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "length" with the proper type+Pass SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "numberOfItems" with the proper type+Pass SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "clear()" with the proper type+Pass SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "initialize(SVGTransform)" with the proper type+Pass SVGTransformList interface: calling initialize(SVGTransform) on objects.pattern.patternTransform.baseVal with too few arguments must throw TypeError+Pass SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "getItem(unsigned long)" with the proper type+Pass SVGTransformList interface: calling getItem(unsigned long) on objects.pattern.patternTransform.baseVal with too few arguments must throw TypeError+Pass SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "insertItemBefore(SVGTransform, unsigned long)" with the proper type+Pass SVGTransformList interface: calling insertItemBefore(SVGTransform, unsigned long) on objects.pattern.patternTransform.baseVal with too few arguments must throw TypeError+Pass SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "replaceItem(SVGTransform, unsigned long)" with the proper type+Pass SVGTransformList interface: calling replaceItem(SVGTransform, unsigned long) on objects.pattern.patternTransform.baseVal with too few arguments must throw TypeError+Pass SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "removeItem(unsigned long)" with the proper type+Pass SVGTransformList interface: calling removeItem(unsigned long) on objects.pattern.patternTransform.baseVal with too few arguments must throw TypeError+Pass SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "appendItem(SVGTransform)" with the proper type+Pass SVGTransformList interface: calling appendItem(SVGTransform) on objects.pattern.patternTransform.baseVal with too few arguments must throw TypeError+Pass SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "createSVGTransformFromMatrix(optional DOMMatrix2DInit)" with the proper type+Pass SVGTransformList interface: calling createSVGTransformFromMatrix(optional DOMMatrix2DInit) on objects.pattern.patternTransform.baseVal with too few arguments must throw TypeError+Pass SVGTransformList interface: objects.pattern.patternTransform.baseVal must inherit property "consolidate()" with the proper typePass SVGAnimatedTransformList interface: existence and properties of interface objectPass SVGAnimatedTransformList interface object lengthPass SVGAnimatedTransformList interface object name@@ -780,10 +780,10 @@ Pass SVGAnimatedTransformList interface: existence and properties of interface pPass SVGAnimatedTransformList interface: existence and properties of interface prototype object's @@unscopables propertyPass SVGAnimatedTransformList interface: attribute baseValPass SVGAnimatedTransformList interface: attribute animVal-Fail SVGAnimatedTransformList must be primary interface of objects.pattern.patternTransform-Fail Stringification of objects.pattern.patternTransform-Fail SVGAnimatedTransformList interface: objects.pattern.patternTransform must inherit property "baseVal" with the proper type-Fail SVGAnimatedTransformList interface: objects.pattern.patternTransform must inherit property "animVal" with the proper type+Pass SVGAnimatedTransformList must be primary interface of objects.pattern.patternTransform+Pass Stringification of objects.pattern.patternTransform+Pass SVGAnimatedTransformList interface: objects.pattern.patternTransform must inherit property "baseVal" with the proper type+Pass SVGAnimatedTransformList interface: objects.pattern.patternTransform must inherit property "animVal" with the proper typePass SVGPreserveAspectRatio interface: existence and properties of interface objectPass SVGPreserveAspectRatio interface object lengthPass SVGPreserveAspectRatio interface object name@@ -1421,7 +1421,7 @@ Pass SVGGradientElement interface: constant SVG_SPREADMETHOD_REFLECT on interfacPass SVGGradientElement interface: constant SVG_SPREADMETHOD_REPEAT on interface objectPass SVGGradientElement interface: constant SVG_SPREADMETHOD_REPEAT on interface prototype objectPass SVGGradientElement interface: attribute gradientUnits-Fail SVGGradientElement interface: attribute gradientTransform+Pass SVGGradientElement interface: attribute gradientTransformPass SVGGradientElement interface: attribute spreadMethodPass SVGGradientElement interface: attribute hrefPass SVGLinearGradientElement interface: existence and properties of interface object@@ -1445,7 +1445,7 @@ Pass SVGGradientElement interface: objects.linearGradient must inherit propertyPass SVGGradientElement interface: objects.linearGradient must inherit property "SVG_SPREADMETHOD_REFLECT" with the proper typePass SVGGradientElement interface: objects.linearGradient must inherit property "SVG_SPREADMETHOD_REPEAT" with the proper typePass SVGGradientElement interface: objects.linearGradient must inherit property "gradientUnits" with the proper type-Fail SVGGradientElement interface: objects.linearGradient must inherit property "gradientTransform" with the proper type+Pass SVGGradientElement interface: objects.linearGradient must inherit property "gradientTransform" with the proper typePass SVGGradientElement interface: objects.linearGradient must inherit property "spreadMethod" with the proper typePass SVGGradientElement interface: objects.linearGradient must inherit property "href" with the proper typePass SVGElement interface: objects.linearGradient must inherit property "className" with the proper type@@ -1478,7 +1478,7 @@ Pass SVGGradientElement interface: objects.radialGradient must inherit propertyPass SVGGradientElement interface: objects.radialGradient must inherit property "SVG_SPREADMETHOD_REFLECT" with the proper typePass SVGGradientElement interface: objects.radialGradient must inherit property "SVG_SPREADMETHOD_REPEAT" with the proper typePass SVGGradientElement interface: objects.radialGradient must inherit property "gradientUnits" with the proper type-Fail SVGGradientElement interface: objects.radialGradient must inherit property "gradientTransform" with the proper type+Pass SVGGradientElement interface: objects.radialGradient must inherit property "gradientTransform" with the proper typePass SVGGradientElement interface: objects.radialGradient must inherit property "spreadMethod" with the proper typePass SVGGradientElement interface: objects.radialGradient must inherit property "href" with the proper typePass SVGElement interface: objects.radialGradient must inherit property "className" with the proper type@@ -1509,7 +1509,7 @@ Pass SVGPatternElement interface: existence and properties of interface prototypPass SVGPatternElement interface: existence and properties of interface prototype object's @@unscopables propertyPass SVGPatternElement interface: attribute patternUnitsPass SVGPatternElement interface: attribute patternContentUnits-Fail SVGPatternElement interface: attribute patternTransform+Pass SVGPatternElement interface: attribute patternTransformPass SVGPatternElement interface: attribute xPass SVGPatternElement interface: attribute yPass SVGPatternElement interface: attribute width@@ -1521,7 +1521,7 @@ Pass SVGPatternElement must be primary interface of objects.patternPass Stringification of objects.patternPass SVGPatternElement interface: objects.pattern must inherit property "patternUnits" with the proper typePass SVGPatternElement interface: objects.pattern must inherit property "patternContentUnits" with the proper type-Fail SVGPatternElement interface: objects.pattern must inherit property "patternTransform" with the proper type+Pass SVGPatternElement interface: objects.pattern must inherit property "patternTransform" with the proper typePass SVGPatternElement interface: objects.pattern must inherit property "x" with the proper typePass SVGPatternElement interface: objects.pattern must inherit property "y" with the proper typePass SVGPatternElement interface: objects.pattern must inherit property "width" with the proper typediff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/types/SameObject-identity.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/types/SameObject-identity.txtindex e424bd095ca..9ac8fa2ba17 100644--- a/Tests/LibWeb/Text/expected/wpt-import/svg/types/SameObject-identity.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/svg/types/SameObject-identity.txt@@ -1,9 +1,9 @@-Harness status: Error+Harness status: OK-Found 66 tests+Found 81 tests-64 Pass-2 Fail+80 Pass+1 FailPass SVGAnimatedLength: rect.xPass SVGAnimatedLength: rect.yPass SVGAnimatedLength: rect.width@@ -66,7 +66,22 @@ Pass SVGAnimatedEnumeration: tp.spacingPass SVGAnimatedEnumeration: text.lengthAdjustPass SVGAnimatedAngle: mk.orientAnglePass SVGAnimatedAngle.baseVal: mk.orientAngle.baseVal-Fail SVGAnimatedTransformList: rect.transform-Fail SVGAnimatedTransformList.baseVal: rect.transform.baseVal+Pass SVGAnimatedTransformList: rect.transform+Pass SVGAnimatedTransformList.baseVal: rect.transform.baseValPass SVGAnimatedTransformList: pat.patternTransform-Pass SVGAnimatedTransformList: lg.gradientTransform\ No newline at end of file+Pass SVGAnimatedTransformList: lg.gradientTransform+Pass SVGTransform.matrix (held transform)+Pass SVGAnimatedString: use.href+Pass SVGAnimatedString: rect.className+Pass SVGAnimatedString: anchor.target+Pass SVGAnimatedRect: root.viewBox+Pass SVGAnimatedRect.baseVal (DOMRect): root.viewBox.baseVal+Pass SVGAnimatedRect.animVal (DOMRectReadOnly): root.viewBox.animVal+Pass SVGAnimatedPreserveAspectRatio: root.preserveAspectRatio+Pass SVGAnimatedPreserveAspectRatio.baseVal: root.preserveAspectRatio.baseVal+Pass SVGPointList: poly.points+Pass SVGPointList: poly.animatedPoints+Pass SVGStringList: rect.requiredExtensions+Pass SVGStringList: rect.systemLanguage+Fail DOMPointReadOnly: root.currentTranslate+Pass DOMTokenList: anchor.relList\ No newline at end of filediff --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.txtindex 442f4ec2baf..c8f49a470b7 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: OKFound 20 tests-11 Pass-9 Fail+16 Pass+4 FailPass SVGNumberList (rotate on text): animVal read before an attribute change reports the new item countPass SVGNumberList (rotate on text): animVal read before an attribute change reports the new valuePass SVGNumberList (rotate on text): the animVal list object survives an attribute change@@ -19,8 +19,8 @@ Fail SVGPointList (points on polyline, animatedPoints): animVal read before an aPass SVGPointList (points on polyline, animatedPoints): the animVal list object survives an attribute changeFail SVGPointList (points on polyline, animatedPoints): animVal reports the new item count after a baseVal DOM changeFail SVGPointList (points on polyline, animatedPoints): animVal items are read only-Fail SVGTransformList (gradientTransform on linearGradient): animVal read before an attribute change reports the new item count-Fail SVGTransformList (gradientTransform on linearGradient): animVal read before an attribute change reports the new value-Fail SVGTransformList (gradientTransform on linearGradient): the animVal list object survives an attribute change-Fail SVGTransformList (gradientTransform on linearGradient): animVal reports the new item count after a baseVal DOM change-Fail SVGTransformList (gradientTransform on linearGradient): animVal items are read only\ No newline at end of file+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+Pass SVGTransformList (gradientTransform on linearGradient): the animVal list object survives an attribute change+Pass SVGTransformList (gradientTransform on linearGradient): animVal reports the new item count after a baseVal DOM change+Pass SVGTransformList (gradientTransform on linearGradient): animVal items are read only\ No newline at end of filediff --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.txtindex bac5eafca29..94e85c69556 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,8 @@ Harness status: OKFound 59 tests-22 Pass-37 Fail+50 Pass+9 FailPass SVGNumberList (rotate on text): getItem returns the same object for one index, with no attribute changePass SVGNumberList (rotate on text): a same-count change updates the values of the held itemsPass SVGNumberList (rotate on text): a same-count change keeps the held item in the list@@ -34,32 +34,32 @@ Fail SVGPointList (points on polyline): a shrink detaches the truncated item, whFail SVGPointList (points on polyline): the truncated item stops reaching the element and stops being read onlyPass SVGPointList (points on polyline): the list interface object survives the changeFail SVGPointList (points on polyline): an empty string empties the list and detaches every item-Fail SVGTransformList (transform on g): getItem returns the same object for one index, with no attribute change-Fail SVGTransformList (transform on g): a same-count change updates the values of the held items-Fail SVGTransformList (transform on g): a same-count change keeps the held item in the list-Fail SVGTransformList (transform on g): the held item is still attached after a same-count change-Fail SVGTransformList (transform on g): a grow updates the held item and appends new ones-Fail SVGTransformList (transform on g): a shrink updates the held items that are still in range-Fail SVGTransformList (transform on g): a shrink detaches the truncated item, which keeps its value-Fail SVGTransformList (transform on g): the truncated item stops reaching the element and stops being read only-Fail SVGTransformList (transform on g): the list interface object survives the change-Fail SVGTransformList (transform on g): an empty string empties the list and detaches every item-Fail SVGTransformList (gradientTransform on linearGradient): getItem returns the same object for one index, with no attribute change-Fail SVGTransformList (gradientTransform on linearGradient): a same-count change updates the values of the held items-Fail SVGTransformList (gradientTransform on linearGradient): a same-count change keeps the held item in the list-Fail SVGTransformList (gradientTransform on linearGradient): the held item is still attached after a same-count change-Fail SVGTransformList (gradientTransform on linearGradient): a grow updates the held item and appends new ones-Fail SVGTransformList (gradientTransform on linearGradient): a shrink updates the held items that are still in range-Fail SVGTransformList (gradientTransform on linearGradient): a shrink detaches the truncated item, which keeps its value-Fail SVGTransformList (gradientTransform on linearGradient): the truncated item stops reaching the element and stops being read only-Fail SVGTransformList (gradientTransform on linearGradient): the list interface object survives the change-Fail SVGTransformList (gradientTransform on linearGradient): an empty string empties the list and detaches every item-Fail SVGTransformList (transform): a changed transform function keeps the held item in the list-Fail SVGTransformList (transform): a changed transform function updates the held item's type and matrix-Fail SVGTransformList (transform): swapping two transform functions keeps both held items-Fail SVGTransformList (transform): an empty list detaches every item-Fail SVGTransformList (gradientTransform): a changed transform function keeps the held item in the list-Fail SVGTransformList (gradientTransform): a changed transform function updates the held item's type and matrix-Fail SVGTransformList (gradientTransform): swapping two transform functions keeps both held items-Fail SVGTransformList (gradientTransform): an empty list 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+Pass SVGTransformList (transform on g): the held item is still attached after a same-count change+Pass SVGTransformList (transform on g): a grow updates the held item and appends new ones+Pass SVGTransformList (transform on g): a shrink updates the held items that are still in range+Pass SVGTransformList (transform on g): a shrink detaches the truncated item, which keeps its value+Pass SVGTransformList (transform on g): the truncated item stops reaching the element and stops being read only+Pass SVGTransformList (transform on g): the list interface object survives the change+Pass SVGTransformList (transform on g): an empty string empties the list and detaches every item+Pass SVGTransformList (gradientTransform on linearGradient): getItem returns the same object for one index, with no attribute change+Pass SVGTransformList (gradientTransform on linearGradient): a same-count change updates the values of the held items+Pass SVGTransformList (gradientTransform on linearGradient): a same-count change keeps the held item in the list+Pass SVGTransformList (gradientTransform on linearGradient): the held item is still attached after a same-count change+Pass SVGTransformList (gradientTransform on linearGradient): a grow updates the held item and appends new ones+Pass SVGTransformList (gradientTransform on linearGradient): a shrink updates the held items that are still in range+Pass SVGTransformList (gradientTransform on linearGradient): a shrink detaches the truncated item, which keeps its value+Pass SVGTransformList (gradientTransform on linearGradient): the truncated item stops reaching the element and stops being read only+Pass SVGTransformList (gradientTransform on linearGradient): the list interface object survives the change+Pass SVGTransformList (gradientTransform on linearGradient): an empty string empties the list and detaches every item+Pass SVGTransformList (transform): a changed transform function keeps the held item in the list+Pass SVGTransformList (transform): a changed transform function updates the held item's type and matrix+Pass SVGTransformList (transform): swapping two transform functions keeps both held items+Pass SVGTransformList (transform): an empty list detaches every item+Pass SVGTransformList (gradientTransform): a changed transform function keeps the held item in the list+Pass SVGTransformList (gradientTransform): a changed transform function updates the held item's type and matrix+Pass SVGTransformList (gradientTransform): swapping two transform functions keeps both held items+Pass SVGTransformList (gradientTransform): an empty list detaches every itemPass SVGStringList: a change replaces the list rather than updating items\ No newline at end of file