2022-03-21 14:33:11 -04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2022-09-25 18:04:39 -06:00
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
2024-04-27 12:09:58 +12:00
|
|
|
#include <LibWeb/Bindings/SVGAnimatedLengthPrototype.h>
|
2022-03-21 14:33:11 -04:00
|
|
|
#include <LibWeb/SVG/SVGAnimatedLength.h>
|
|
|
|
|
|
|
|
namespace Web::SVG {
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DEFINE_ALLOCATOR(SVGAnimatedLength);
|
2023-11-19 19:47:52 +01:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ref<SVGAnimatedLength> SVGAnimatedLength::create(JS::Realm& realm, GC::Ref<SVGLength> base_val, GC::Ref<SVGLength> anim_val)
|
2022-03-21 14:33:11 -04:00
|
|
|
{
|
2025-08-26 16:51:46 +02:00
|
|
|
return realm.create<SVGAnimatedLength>(realm, base_val, anim_val);
|
2022-03-21 14:33:11 -04:00
|
|
|
}
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
SVGAnimatedLength::SVGAnimatedLength(JS::Realm& realm, GC::Ref<SVGLength> base_val, GC::Ref<SVGLength> anim_val)
|
2022-09-25 18:04:39 -06:00
|
|
|
: PlatformObject(realm)
|
2025-08-26 16:51:46 +02:00
|
|
|
, m_base_val(base_val)
|
|
|
|
, m_anim_val(anim_val)
|
2022-03-21 14:33:11 -04:00
|
|
|
{
|
2025-08-26 16:51:46 +02:00
|
|
|
// The object referenced by animVal will always be distinct from the one referenced by baseVal, even when the
|
|
|
|
// attribute is not animated.
|
2022-03-21 14:33:11 -04:00
|
|
|
VERIFY(m_base_val.ptr() != m_anim_val.ptr());
|
2025-08-26 16:51:46 +02:00
|
|
|
|
|
|
|
// https://svgwg.org/svg2-draft/types.html#InterfaceSVGLength
|
|
|
|
// SVGLength objects reflected through the animVal IDL attribute are always read only.
|
|
|
|
VERIFY(m_anim_val->read_only() == SVGLength::ReadOnly::Yes);
|
2022-03-21 14:33:11 -04:00
|
|
|
}
|
|
|
|
|
2022-09-02 14:04:59 +02:00
|
|
|
SVGAnimatedLength::~SVGAnimatedLength() = default;
|
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
void SVGAnimatedLength::initialize(JS::Realm& realm)
|
2023-01-10 06:28:20 -05:00
|
|
|
{
|
2024-03-16 13:13:08 +01:00
|
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGAnimatedLength);
|
2025-04-20 16:22:57 +02:00
|
|
|
Base::initialize(realm);
|
2023-01-10 06:28:20 -05:00
|
|
|
}
|
|
|
|
|
2025-08-26 16:51:46 +02:00
|
|
|
void SVGAnimatedLength::visit_edges(Visitor& visitor)
|
2022-09-02 14:04:59 +02:00
|
|
|
{
|
|
|
|
Base::visit_edges(visitor);
|
2023-11-19 16:18:00 +13:00
|
|
|
visitor.visit(m_base_val);
|
|
|
|
visitor.visit(m_anim_val);
|
2022-09-02 14:04:59 +02:00
|
|
|
}
|
|
|
|
|
2022-03-21 14:33:11 -04:00
|
|
|
}
|