/src/serenity/Userland/Libraries/LibWeb/SVG/SVGAnimatedRect.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2024, Andreas Kling <kling@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #include <LibWeb/Bindings/ExceptionOrUtils.h> |
8 | | #include <LibWeb/Bindings/Intrinsics.h> |
9 | | #include <LibWeb/Bindings/SVGAnimatedRectPrototype.h> |
10 | | #include <LibWeb/SVG/SVGAnimatedRect.h> |
11 | | |
12 | | namespace Web::SVG { |
13 | | |
14 | | JS_DEFINE_ALLOCATOR(SVGAnimatedRect); |
15 | | |
16 | | SVGAnimatedRect::SVGAnimatedRect(JS::Realm& realm) |
17 | 0 | : Bindings::PlatformObject(realm) |
18 | 0 | { |
19 | 0 | } |
20 | | |
21 | 0 | SVGAnimatedRect::~SVGAnimatedRect() = default; |
22 | | |
23 | | void SVGAnimatedRect::initialize(JS::Realm& realm) |
24 | 0 | { |
25 | 0 | Base::initialize(realm); |
26 | 0 | WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGAnimatedRect); |
27 | 0 | m_base_val = Geometry::DOMRect::create(realm, { 0, 0, 0, 0 }); |
28 | 0 | m_anim_val = Geometry::DOMRect::create(realm, { 0, 0, 0, 0 }); |
29 | 0 | } |
30 | | |
31 | | void SVGAnimatedRect::visit_edges(Visitor& visitor) |
32 | 0 | { |
33 | 0 | Base::visit_edges(visitor); |
34 | 0 | visitor.visit(m_base_val); |
35 | 0 | visitor.visit(m_anim_val); |
36 | 0 | } |
37 | | |
38 | | JS::GCPtr<Geometry::DOMRect> SVGAnimatedRect::base_val() const |
39 | 0 | { |
40 | 0 | if (m_nulled) |
41 | 0 | return nullptr; |
42 | 0 | return m_base_val; |
43 | 0 | } |
44 | | |
45 | | JS::GCPtr<Geometry::DOMRect> SVGAnimatedRect::anim_val() const |
46 | 0 | { |
47 | 0 | if (m_nulled) |
48 | 0 | return nullptr; |
49 | 0 | return m_anim_val; |
50 | 0 | } |
51 | | |
52 | | void SVGAnimatedRect::set_nulled(bool nulled) |
53 | 0 | { |
54 | 0 | m_nulled = nulled; |
55 | 0 | } |
56 | | |
57 | | void SVGAnimatedRect::set_base_val(Gfx::DoubleRect const& rect) |
58 | 0 | { |
59 | 0 | m_base_val->set_x(rect.x()); |
60 | 0 | m_base_val->set_y(rect.y()); |
61 | 0 | m_base_val->set_width(rect.width()); |
62 | 0 | m_base_val->set_height(rect.height()); |
63 | 0 | } |
64 | | |
65 | | void SVGAnimatedRect::set_anim_val(Gfx::DoubleRect const& rect) |
66 | 0 | { |
67 | 0 | m_anim_val->set_x(rect.x()); |
68 | 0 | m_anim_val->set_y(rect.y()); |
69 | 0 | m_anim_val->set_width(rect.width()); |
70 | 0 | m_anim_val->set_height(rect.height()); |
71 | 0 | } |
72 | | |
73 | | } |