Serenity Operating System
1/*
2 * Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#include <LibWeb/Bindings/Intrinsics.h>
8#include <LibWeb/SVG/SVGAnimatedLength.h>
9
10namespace Web::SVG {
11
12WebIDL::ExceptionOr<JS::NonnullGCPtr<SVGAnimatedLength>> SVGAnimatedLength::create(JS::Realm& realm, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val)
13{
14 return MUST_OR_THROW_OOM(realm.heap().allocate<SVGAnimatedLength>(realm, realm, move(base_val), move(anim_val)));
15}
16
17SVGAnimatedLength::SVGAnimatedLength(JS::Realm& realm, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val)
18 : PlatformObject(realm)
19 , m_base_val(move(base_val))
20 , m_anim_val(move(anim_val))
21{
22 // The object referenced by animVal will always be distinct from the one referenced by baseVal, even when the attribute is not animated.
23 VERIFY(m_base_val.ptr() != m_anim_val.ptr());
24}
25
26SVGAnimatedLength::~SVGAnimatedLength() = default;
27
28JS::ThrowCompletionOr<void> SVGAnimatedLength::initialize(JS::Realm& realm)
29{
30 MUST_OR_THROW_OOM(Base::initialize(realm));
31 set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGAnimatedLengthPrototype>(realm, "SVGAnimatedLength"));
32
33 return {};
34}
35
36void SVGAnimatedLength::visit_edges(Cell::Visitor& visitor)
37{
38 Base::visit_edges(visitor);
39 visitor.visit(m_base_val.ptr());
40 visitor.visit(m_anim_val.ptr());
41}
42
43}