mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Implement SVGLengthList
This commit is contained in:
parent
832e953c67
commit
797e6dd4eb
Notes:
github-actions[bot]
2025-11-20 22:16:40 +00:00
Author: https://github.com/gmta
Commit: 797e6dd4eb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6878
11 changed files with 126 additions and 18 deletions
49
Libraries/LibWeb/SVG/SVGLengthList.cpp
Normal file
49
Libraries/LibWeb/SVG/SVGLengthList.cpp
Normal 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/SVGLengthListPrototype.h>
|
||||
#include <LibWeb/SVG/SVGLengthList.h>
|
||||
|
||||
namespace Web::SVG {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(SVGLengthList);
|
||||
|
||||
GC::Ref<SVGLengthList> SVGLengthList::create(JS::Realm& realm, Vector<GC::Ref<SVGLength>> items, ReadOnlyList read_only)
|
||||
{
|
||||
return realm.create<SVGLengthList>(realm, move(items), read_only);
|
||||
}
|
||||
|
||||
GC::Ref<SVGLengthList> SVGLengthList::create(JS::Realm& realm, ReadOnlyList read_only)
|
||||
{
|
||||
return realm.create<SVGLengthList>(realm, read_only);
|
||||
}
|
||||
|
||||
SVGLengthList::SVGLengthList(JS::Realm& realm, Vector<GC::Ref<SVGLength>> items, ReadOnlyList read_only)
|
||||
: Bindings::PlatformObject(realm)
|
||||
, SVGList(realm, move(items), read_only)
|
||||
{
|
||||
}
|
||||
|
||||
SVGLengthList::SVGLengthList(JS::Realm& realm, ReadOnlyList read_only)
|
||||
: Bindings::PlatformObject(realm)
|
||||
, SVGList(realm, read_only)
|
||||
{
|
||||
}
|
||||
|
||||
void SVGLengthList::initialize(JS::Realm& realm)
|
||||
{
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGLengthList);
|
||||
Base::initialize(realm);
|
||||
}
|
||||
|
||||
void SVGLengthList::visit_edges(Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
SVGList::visit_edges(visitor);
|
||||
}
|
||||
|
||||
}
|
||||
34
Libraries/LibWeb/SVG/SVGLengthList.h
Normal file
34
Libraries/LibWeb/SVG/SVGLengthList.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/SVG/SVGLength.h>
|
||||
#include <LibWeb/SVG/SVGList.h>
|
||||
|
||||
namespace Web::SVG {
|
||||
|
||||
// https://svgwg.org/svg2-draft/types.html#InterfaceSVGLengthList
|
||||
class SVGLengthList final
|
||||
: public Bindings::PlatformObject
|
||||
, public SVGList<GC::Ref<SVGLength>> {
|
||||
WEB_PLATFORM_OBJECT(SVGLengthList, Bindings::PlatformObject);
|
||||
GC_DECLARE_ALLOCATOR(SVGLengthList);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<SVGLengthList> create(JS::Realm& realm, Vector<GC::Ref<SVGLength>>, ReadOnlyList);
|
||||
[[nodiscard]] static GC::Ref<SVGLengthList> create(JS::Realm& realm, ReadOnlyList);
|
||||
virtual ~SVGLengthList() override = default;
|
||||
|
||||
private:
|
||||
SVGLengthList(JS::Realm&, Vector<GC::Ref<SVGLength>>, ReadOnlyList);
|
||||
SVGLengthList(JS::Realm&, ReadOnlyList);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
};
|
||||
|
||||
}
|
||||
18
Libraries/LibWeb/SVG/SVGLengthList.idl
Normal file
18
Libraries/LibWeb/SVG/SVGLengthList.idl
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#import <SVG/SVGLength.idl>
|
||||
|
||||
// https://svgwg.org/svg2-draft/types.html#InterfaceSVGLengthList
|
||||
[Exposed=Window]
|
||||
interface SVGLengthList {
|
||||
|
||||
readonly attribute unsigned long length;
|
||||
readonly attribute unsigned long numberOfItems;
|
||||
|
||||
undefined clear();
|
||||
SVGLength initialize(SVGLength newItem);
|
||||
getter SVGLength getItem(unsigned long index);
|
||||
SVGLength insertItemBefore(SVGLength newItem, unsigned long index);
|
||||
SVGLength replaceItem(SVGLength newItem, unsigned long index);
|
||||
SVGLength removeItem(unsigned long index);
|
||||
SVGLength appendItem(SVGLength newItem);
|
||||
setter undefined (unsigned long index, SVGLength newItem);
|
||||
};
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/SVG/SVGLength.h>
|
||||
#include <LibWeb/SVG/SVGList.h>
|
||||
#include <LibWeb/SVG/SVGNumber.h>
|
||||
#include <LibWeb/SVG/SVGTransform.h>
|
||||
|
|
@ -204,6 +205,7 @@ WebIDL::ExceptionOr<T> SVGList<T>::append_item(T new_item)
|
|||
return new_item;
|
||||
}
|
||||
|
||||
template class SVGList<GC::Ref<SVGLength>>;
|
||||
template class SVGList<GC::Ref<SVGNumber>>;
|
||||
template class SVGList<GC::Ref<SVGTransform>>;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/SVGTransformListPrototype.h>
|
||||
#include <LibWeb/SVG/SVGTransformList.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::SVG {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue