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/SVGLength.h>
9
10namespace Web::SVG {
11
12WebIDL::ExceptionOr<JS::NonnullGCPtr<SVGLength>> SVGLength::create(JS::Realm& realm, u8 unit_type, float value)
13{
14 return MUST_OR_THROW_OOM(realm.heap().allocate<SVGLength>(realm, realm, unit_type, value));
15}
16
17SVGLength::SVGLength(JS::Realm& realm, u8 unit_type, float value)
18 : PlatformObject(realm)
19 , m_unit_type(unit_type)
20 , m_value(value)
21{
22}
23
24JS::ThrowCompletionOr<void> SVGLength::initialize(JS::Realm& realm)
25{
26 MUST_OR_THROW_OOM(Base::initialize(realm));
27 set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGLengthPrototype>(realm, "SVGLength"));
28
29 return {};
30}
31
32SVGLength::~SVGLength() = default;
33
34// https://www.w3.org/TR/SVG11/types.html#__svg__SVGLength__value
35WebIDL::ExceptionOr<void> SVGLength::set_value(float value)
36{
37 // FIXME: Raise an exception if this <length> is read-only.
38 m_value = value;
39 return {};
40}
41
42}