Skip to content

Commit c0630c7

Browse files
committed
LibWeb: Add SVGAnimatedNumberList
1 parent c5e7276 commit c0630c7

File tree

8 files changed

+100
-11
lines changed

8 files changed

+100
-11
lines changed

Libraries/LibWeb/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,7 @@ set(SOURCES
900900
SVG/SVGAnimatedEnumeration.cpp
901901
SVG/SVGAnimatedLength.cpp
902902
SVG/SVGAnimatedNumber.cpp
903+
SVG/SVGAnimatedNumberList.cpp
903904
SVG/SVGAnimatedRect.cpp
904905
SVG/SVGAnimatedString.cpp
905906
SVG/SVGAnimatedTransformList.cpp

Libraries/LibWeb/Forward.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1092,8 +1092,10 @@ namespace Web::SVG {
10921092
class Path;
10931093
class SVGAnimatedEnumeration;
10941094
class SVGAnimatedLength;
1095-
class SVGAnimationElement;
1095+
class SVGAnimatedNumber;
1096+
class SVGAnimatedNumberList;
10961097
class SVGAnimatedRect;
1098+
class SVGAnimationElement;
10971099
class SVGCircleElement;
10981100
class SVGClipPathElement;
10991101
class SVGDecodedImageData;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
3+
*
4+
* SPDX-License-Identifier: BSD-2-Clause
5+
*/
6+
7+
#include <LibWeb/Bindings/Intrinsics.h>
8+
#include <LibWeb/Bindings/SVGAnimatedNumberListPrototype.h>
9+
#include <LibWeb/SVG/SVGAnimatedNumberList.h>
10+
11+
namespace Web::SVG {
12+
13+
GC_DEFINE_ALLOCATOR(SVGAnimatedNumberList);
14+
15+
GC::Ref<SVGAnimatedNumberList> SVGAnimatedNumberList::create(JS::Realm& realm, GC::Ref<SVGNumberList> base_val)
16+
{
17+
return realm.create<SVGAnimatedNumberList>(realm, base_val);
18+
}
19+
20+
SVGAnimatedNumberList::SVGAnimatedNumberList(JS::Realm& realm, GC::Ref<SVGNumberList> base_val)
21+
: PlatformObject(realm)
22+
, m_base_val(base_val)
23+
{
24+
}
25+
26+
void SVGAnimatedNumberList::initialize(JS::Realm& realm)
27+
{
28+
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGAnimatedNumberList);
29+
Base::initialize(realm);
30+
}
31+
32+
void SVGAnimatedNumberList::visit_edges(Visitor& visitor)
33+
{
34+
Base::visit_edges(visitor);
35+
visitor.visit(m_base_val);
36+
}
37+
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
3+
*
4+
* SPDX-License-Identifier: BSD-2-Clause
5+
*/
6+
7+
#pragma once
8+
9+
#include <LibWeb/Bindings/PlatformObject.h>
10+
#include <LibWeb/SVG/SVGNumberList.h>
11+
12+
namespace Web::SVG {
13+
14+
// https://svgwg.org/svg2-draft/types.html#InterfaceSVGAnimatedNumber
15+
class SVGAnimatedNumberList final : public Bindings::PlatformObject {
16+
WEB_PLATFORM_OBJECT(SVGAnimatedNumberList, Bindings::PlatformObject);
17+
GC_DECLARE_ALLOCATOR(SVGAnimatedNumberList);
18+
19+
public:
20+
[[nodiscard]] static GC::Ref<SVGAnimatedNumberList> create(JS::Realm&, GC::Ref<SVGNumberList>);
21+
virtual ~SVGAnimatedNumberList() override = default;
22+
23+
// https://www.w3.org/TR/SVG2/types.html#__svg__SVGAnimatedLengthList__baseVal
24+
GC::Ref<SVGNumberList> base_val() const { return m_base_val; }
25+
26+
// https://www.w3.org/TR/SVG2/types.html#__svg__SVGAnimatedLengthList__animVal
27+
GC::Ref<SVGNumberList> anim_val() const { return m_base_val; }
28+
29+
private:
30+
SVGAnimatedNumberList(JS::Realm&, GC::Ref<SVGNumberList>);
31+
32+
virtual void initialize(JS::Realm&) override;
33+
virtual void visit_edges(Visitor&) override;
34+
35+
GC::Ref<SVGNumberList> m_base_val;
36+
};
37+
38+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#import <SVG/SVGNumberList.idl>
2+
3+
// https://www.w3.org/TR/SVG2/types.html#InterfaceSVGAnimatedNumberList
4+
[Exposed=Window]
5+
interface SVGAnimatedNumberList {
6+
[SameObject] readonly attribute SVGNumberList baseVal;
7+
[SameObject] readonly attribute SVGNumberList animVal;
8+
};

Libraries/LibWeb/idl_files.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ libweb_js_bindings(SVG/SVGAElement)
372372
libweb_js_bindings(SVG/SVGAnimatedEnumeration)
373373
libweb_js_bindings(SVG/SVGAnimatedLength)
374374
libweb_js_bindings(SVG/SVGAnimatedNumber)
375+
libweb_js_bindings(SVG/SVGAnimatedNumberList)
375376
libweb_js_bindings(SVG/SVGAnimatedRect)
376377
libweb_js_bindings(SVG/SVGAnimatedString)
377378
libweb_js_bindings(SVG/SVGAnimatedTransformList)

Tests/LibWeb/Text/expected/all-window-properties.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ SVGAElement
365365
SVGAnimatedEnumeration
366366
SVGAnimatedLength
367367
SVGAnimatedNumber
368+
SVGAnimatedNumberList
368369
SVGAnimatedRect
369370
SVGAnimatedString
370371
SVGAnimatedTransformList

Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Harness status: OK
22

33
Found 1781 tests
44

5-
997 Pass
6-
784 Fail
5+
1005 Pass
6+
776 Fail
77
Pass idl_test setup
88
Pass idl_test validation
99
Pass Partial interface Document: original interface defined
@@ -362,14 +362,14 @@ Pass SVGAnimatedRect must be primary interface of objects.svg.viewBox
362362
Pass Stringification of objects.svg.viewBox
363363
Fail SVGAnimatedRect interface: objects.svg.viewBox must inherit property "baseVal" with the proper type
364364
Fail SVGAnimatedRect interface: objects.svg.viewBox must inherit property "animVal" with the proper type
365-
Fail SVGAnimatedNumberList interface: existence and properties of interface object
366-
Fail SVGAnimatedNumberList interface object length
367-
Fail SVGAnimatedNumberList interface object name
368-
Fail SVGAnimatedNumberList interface: existence and properties of interface prototype object
369-
Fail SVGAnimatedNumberList interface: existence and properties of interface prototype object's "constructor" property
370-
Fail SVGAnimatedNumberList interface: existence and properties of interface prototype object's @@unscopables property
371-
Fail SVGAnimatedNumberList interface: attribute baseVal
372-
Fail SVGAnimatedNumberList interface: attribute animVal
365+
Pass SVGAnimatedNumberList interface: existence and properties of interface object
366+
Pass SVGAnimatedNumberList interface object length
367+
Pass SVGAnimatedNumberList interface object name
368+
Pass SVGAnimatedNumberList interface: existence and properties of interface prototype object
369+
Pass SVGAnimatedNumberList interface: existence and properties of interface prototype object's "constructor" property
370+
Pass SVGAnimatedNumberList interface: existence and properties of interface prototype object's @@unscopables property
371+
Pass SVGAnimatedNumberList interface: attribute baseVal
372+
Pass SVGAnimatedNumberList interface: attribute animVal
373373
Fail SVGAnimatedNumberList must be primary interface of objects.text.rotate
374374
Fail Stringification of objects.text.rotate
375375
Fail SVGAnimatedNumberList interface: objects.text.rotate must inherit property "baseVal" with the proper type

0 commit comments

Comments
 (0)