LibWeb: Add SVGNumberList

This commit is contained in:
Jelle Raaijmakers 2025-11-05 15:59:22 +01:00 committed by Jelle Raaijmakers
parent 9991205403
commit c5e7276c2f
Notes: github-actions[bot] 2025-11-09 00:24:17 +00:00
9 changed files with 126 additions and 17 deletions

View file

@ -936,6 +936,7 @@ set(SOURCES
SVG/SVGMaskElement.cpp
SVG/SVGMetadataElement.cpp
SVG/SVGNumber.cpp
SVG/SVGNumberList.cpp
SVG/SVGPathElement.cpp
SVG/SVGPolygonElement.cpp
SVG/SVGPolylineElement.cpp

View file

@ -1118,6 +1118,7 @@ class SVGLineElement;
class SVGMaskElement;
class SVGMetadataElement;
class SVGNumber;
class SVGNumberList;
class SVGPathElement;
class SVGPolygonElement;
class SVGPolylineElement;

View file

@ -5,6 +5,7 @@
*/
#include <LibWeb/SVG/SVGList.h>
#include <LibWeb/SVG/SVGNumber.h>
#include <LibWeb/SVG/SVGTransform.h>
namespace Web::SVG {
@ -203,6 +204,7 @@ WebIDL::ExceptionOr<T> SVGList<T>::append_item(T new_item)
return new_item;
}
template class SVGList<GC::Ref<SVGNumber>>;
template class SVGList<GC::Ref<SVGTransform>>;
}

View file

@ -0,0 +1,49 @@
/*
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/SVGNumberListPrototype.h>
#include <LibWeb/SVG/SVGNumberList.h>
namespace Web::SVG {
GC_DEFINE_ALLOCATOR(SVGNumberList);
GC::Ref<SVGNumberList> SVGNumberList::create(JS::Realm& realm, Vector<GC::Ref<SVGNumber>> items, ReadOnlyList read_only)
{
return realm.create<SVGNumberList>(realm, move(items), read_only);
}
GC::Ref<SVGNumberList> SVGNumberList::create(JS::Realm& realm, ReadOnlyList read_only)
{
return realm.create<SVGNumberList>(realm, read_only);
}
SVGNumberList::SVGNumberList(JS::Realm& realm, Vector<GC::Ref<SVGNumber>> items, ReadOnlyList read_only)
: Bindings::PlatformObject(realm)
, SVGList(realm, move(items), read_only)
{
}
SVGNumberList::SVGNumberList(JS::Realm& realm, ReadOnlyList read_only)
: Bindings::PlatformObject(realm)
, SVGList(realm, read_only)
{
}
void SVGNumberList::initialize(JS::Realm& realm)
{
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGNumberList);
Base::initialize(realm);
}
void SVGNumberList::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);
SVGList::visit_edges(visitor);
}
}

View file

@ -0,0 +1,35 @@
/*
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/SVG/SVGList.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::SVG {
// https://www.w3.org/TR/SVG2/types.html#InterfaceSVGNumberList
class SVGNumberList final
: public Bindings::PlatformObject
, public SVGList<GC::Ref<SVGNumber>> {
WEB_PLATFORM_OBJECT(SVGNumberList, Bindings::PlatformObject);
GC_DECLARE_ALLOCATOR(SVGNumberList);
public:
[[nodiscard]] static GC::Ref<SVGNumberList> create(JS::Realm&, Vector<GC::Ref<SVGNumber>>, ReadOnlyList);
[[nodiscard]] static GC::Ref<SVGNumberList> create(JS::Realm&, ReadOnlyList);
virtual ~SVGNumberList() override = default;
private:
SVGNumberList(JS::Realm&, Vector<GC::Ref<SVGNumber>>, ReadOnlyList);
SVGNumberList(JS::Realm&, ReadOnlyList);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Visitor&) override;
};
}

View file

@ -0,0 +1,19 @@
#import <SVG/SVGNumber.idl>
// https://www.w3.org/TR/SVG2/types.html#InterfaceSVGNumberList
[Exposed=Window]
interface SVGNumberList {
readonly attribute unsigned long length;
readonly attribute unsigned long numberOfItems;
// AD-HOC: 'undefined' instead of 'void'
undefined clear();
SVGNumber initialize(SVGNumber newItem);
getter SVGNumber getItem(unsigned long index);
SVGNumber insertItemBefore(SVGNumber newItem, unsigned long index);
SVGNumber replaceItem(SVGNumber newItem, unsigned long index);
SVGNumber removeItem(unsigned long index);
SVGNumber appendItem(SVGNumber newItem);
setter void (unsigned long index, SVGNumber newItem);
};

View file

@ -404,6 +404,7 @@ libweb_js_bindings(SVG/SVGLinearGradientElement)
libweb_js_bindings(SVG/SVGMaskElement)
libweb_js_bindings(SVG/SVGMetadataElement)
libweb_js_bindings(SVG/SVGNumber)
libweb_js_bindings(SVG/SVGNumberList)
libweb_js_bindings(SVG/SVGPathElement)
libweb_js_bindings(SVG/SVGPolygonElement)
libweb_js_bindings(SVG/SVGPolylineElement)

View file

@ -398,6 +398,7 @@ SVGMaskElement
SVGMatrix
SVGMetadataElement
SVGNumber
SVGNumberList
SVGPathElement
SVGPoint
SVGPolygonElement

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 1781 tests
982 Pass
799 Fail
997 Pass
784 Fail
Pass idl_test setup
Pass idl_test validation
Pass Partial interface Document: original interface defined
@ -187,21 +187,21 @@ Fail SVGAngle interface: objects.svg.createSVGAngle() must inherit property "new
Fail SVGAngle interface: calling newValueSpecifiedUnits(unsigned short, float) on objects.svg.createSVGAngle() with too few arguments must throw TypeError
Fail SVGAngle interface: objects.svg.createSVGAngle() must inherit property "convertToSpecifiedUnits(unsigned short)" with the proper type
Fail SVGAngle interface: calling convertToSpecifiedUnits(unsigned short) on objects.svg.createSVGAngle() with too few arguments must throw TypeError
Fail SVGNumberList interface: existence and properties of interface object
Fail SVGNumberList interface object length
Fail SVGNumberList interface object name
Fail SVGNumberList interface: existence and properties of interface prototype object
Fail SVGNumberList interface: existence and properties of interface prototype object's "constructor" property
Fail SVGNumberList interface: existence and properties of interface prototype object's @@unscopables property
Fail SVGNumberList interface: attribute length
Fail SVGNumberList interface: attribute numberOfItems
Fail SVGNumberList interface: operation clear()
Fail SVGNumberList interface: operation initialize(SVGNumber)
Fail SVGNumberList interface: operation getItem(unsigned long)
Fail SVGNumberList interface: operation insertItemBefore(SVGNumber, unsigned long)
Fail SVGNumberList interface: operation replaceItem(SVGNumber, unsigned long)
Fail SVGNumberList interface: operation removeItem(unsigned long)
Fail SVGNumberList interface: operation appendItem(SVGNumber)
Pass SVGNumberList interface: existence and properties of interface object
Pass SVGNumberList interface object length
Pass SVGNumberList interface object name
Pass SVGNumberList interface: existence and properties of interface prototype object
Pass SVGNumberList interface: existence and properties of interface prototype object's "constructor" property
Pass SVGNumberList interface: existence and properties of interface prototype object's @@unscopables property
Pass SVGNumberList interface: attribute length
Pass SVGNumberList interface: attribute numberOfItems
Pass SVGNumberList interface: operation clear()
Pass SVGNumberList interface: operation initialize(SVGNumber)
Pass SVGNumberList interface: operation getItem(unsigned long)
Pass SVGNumberList interface: operation insertItemBefore(SVGNumber, unsigned long)
Pass SVGNumberList interface: operation replaceItem(SVGNumber, unsigned long)
Pass SVGNumberList interface: operation removeItem(unsigned long)
Pass SVGNumberList interface: operation appendItem(SVGNumber)
Fail SVGNumberList must be primary interface of objects.text.rotate.baseVal
Fail Stringification of objects.text.rotate.baseVal
Fail SVGNumberList interface: objects.text.rotate.baseVal must inherit property "length" with the proper type