Skip to content

Commit 527a293

Browse files
gmtaawesomekling
authored andcommitted
LibWeb: Implement SVGAnimatedLengthList
1 parent 797e6dd commit 527a293

File tree

8 files changed

+98
-10
lines changed

8 files changed

+98
-10
lines changed

Libraries/LibWeb/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@ set(SOURCES
901901
SVG/SVGAElement.cpp
902902
SVG/SVGAnimatedEnumeration.cpp
903903
SVG/SVGAnimatedLength.cpp
904+
SVG/SVGAnimatedLengthList.cpp
904905
SVG/SVGAnimatedNumber.cpp
905906
SVG/SVGAnimatedNumberList.cpp
906907
SVG/SVGAnimatedRect.cpp

Libraries/LibWeb/Forward.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,7 @@ namespace Web::SVG {
10941094
class Path;
10951095
class SVGAnimatedEnumeration;
10961096
class SVGAnimatedLength;
1097+
class SVGAnimatedLengthList;
10971098
class SVGAnimatedNumber;
10981099
class SVGAnimatedNumberList;
10991100
class SVGAnimatedRect;
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/SVGAnimatedLengthListPrototype.h>
9+
#include <LibWeb/SVG/SVGAnimatedLengthList.h>
10+
11+
namespace Web::SVG {
12+
13+
GC_DEFINE_ALLOCATOR(SVGAnimatedLengthList);
14+
15+
GC::Ref<SVGAnimatedLengthList> SVGAnimatedLengthList::create(JS::Realm& realm, GC::Ref<SVGLengthList> base_val)
16+
{
17+
return realm.create<SVGAnimatedLengthList>(realm, base_val);
18+
}
19+
20+
SVGAnimatedLengthList::SVGAnimatedLengthList(JS::Realm& realm, GC::Ref<SVGLengthList> base_val)
21+
: PlatformObject(realm)
22+
, m_base_val(base_val)
23+
{
24+
}
25+
26+
void SVGAnimatedLengthList::initialize(JS::Realm& realm)
27+
{
28+
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGAnimatedLengthList);
29+
Base::initialize(realm);
30+
}
31+
32+
void SVGAnimatedLengthList::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/SVGLengthList.h>
11+
12+
namespace Web::SVG {
13+
14+
// https://svgwg.org/svg2-draft/types.html#InterfaceSVGAnimatedLengthList
15+
class SVGAnimatedLengthList final : public Bindings::PlatformObject {
16+
WEB_PLATFORM_OBJECT(SVGAnimatedLengthList, Bindings::PlatformObject);
17+
GC_DECLARE_ALLOCATOR(SVGAnimatedLengthList);
18+
19+
public:
20+
[[nodiscard]] static GC::Ref<SVGAnimatedLengthList> create(JS::Realm&, GC::Ref<SVGLengthList>);
21+
virtual ~SVGAnimatedLengthList() override = default;
22+
23+
// https://svgwg.org/svg2-draft/types.html#__svg__SVGAnimatedLengthList__baseVal
24+
GC::Ref<SVGLengthList> base_val() const { return m_base_val; }
25+
26+
// https://svgwg.org/svg2-draft/types.html#__svg__SVGAnimatedLengthList__animVal
27+
GC::Ref<SVGLengthList> anim_val() const { return m_base_val; }
28+
29+
private:
30+
SVGAnimatedLengthList(JS::Realm&, GC::Ref<SVGLengthList>);
31+
32+
virtual void initialize(JS::Realm&) override;
33+
virtual void visit_edges(Visitor&) override;
34+
35+
GC::Ref<SVGLengthList> 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/SVGLengthList.idl>
2+
3+
// https://svgwg.org/svg2-draft/types.html#InterfaceSVGAnimatedLengthList
4+
[Exposed=Window]
5+
interface SVGAnimatedLengthList {
6+
[SameObject] readonly attribute SVGLengthList baseVal;
7+
[SameObject] readonly attribute SVGLengthList animVal;
8+
};

Libraries/LibWeb/idl_files.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ libweb_js_bindings(TrustedTypes/TrustedTypePolicyFactory)
371371
libweb_js_bindings(SVG/SVGAElement)
372372
libweb_js_bindings(SVG/SVGAnimatedEnumeration)
373373
libweb_js_bindings(SVG/SVGAnimatedLength)
374+
libweb_js_bindings(SVG/SVGAnimatedLengthList)
374375
libweb_js_bindings(SVG/SVGAnimatedNumber)
375376
libweb_js_bindings(SVG/SVGAnimatedNumberList)
376377
libweb_js_bindings(SVG/SVGAnimatedRect)

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 @@ Response
365365
SVGAElement
366366
SVGAnimatedEnumeration
367367
SVGAnimatedLength
368+
SVGAnimatedLengthList
368369
SVGAnimatedNumber
369370
SVGAnimatedNumberList
370371
SVGAnimatedRect

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-
1020 Pass
6-
761 Fail
5+
1028 Pass
6+
753 Fail
77
Pass idl_test setup
88
Pass idl_test validation
99
Pass Partial interface Document: original interface defined
@@ -374,14 +374,14 @@ 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
376376
Fail SVGAnimatedNumberList interface: objects.text.rotate must inherit property "animVal" with the proper type
377-
Fail SVGAnimatedLengthList interface: existence and properties of interface object
378-
Fail SVGAnimatedLengthList interface object length
379-
Fail SVGAnimatedLengthList interface object name
380-
Fail SVGAnimatedLengthList interface: existence and properties of interface prototype object
381-
Fail SVGAnimatedLengthList interface: existence and properties of interface prototype object's "constructor" property
382-
Fail SVGAnimatedLengthList interface: existence and properties of interface prototype object's @@unscopables property
383-
Fail SVGAnimatedLengthList interface: attribute baseVal
384-
Fail SVGAnimatedLengthList interface: attribute animVal
377+
Pass SVGAnimatedLengthList interface: existence and properties of interface object
378+
Pass SVGAnimatedLengthList interface object length
379+
Pass SVGAnimatedLengthList interface object name
380+
Pass SVGAnimatedLengthList interface: existence and properties of interface prototype object
381+
Pass SVGAnimatedLengthList interface: existence and properties of interface prototype object's "constructor" property
382+
Pass SVGAnimatedLengthList interface: existence and properties of interface prototype object's @@unscopables property
383+
Pass SVGAnimatedLengthList interface: attribute baseVal
384+
Pass SVGAnimatedLengthList interface: attribute animVal
385385
Fail SVGAnimatedLengthList must be primary interface of objects.text.x
386386
Fail Stringification of objects.text.x
387387
Fail SVGAnimatedLengthList interface: objects.text.x must inherit property "baseVal" with the proper type

0 commit comments

Comments
 (0)