summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/SVG/SVGLength.h
blob: 5e9c469aa23625e43e3dea7804fe0ea915856c87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/WebIDL/ExceptionOr.h>

namespace Web::SVG {

// https://www.w3.org/TR/SVG11/types.html#InterfaceSVGLength
class SVGLength : public Bindings::PlatformObject {
    WEB_PLATFORM_OBJECT(SVGLength, Bindings::PlatformObject);

public:
    static WebIDL::ExceptionOr<JS::NonnullGCPtr<SVGLength>> create(JS::Realm&, u8 unit_type, float value);
    virtual ~SVGLength() override;

    u8 unit_type() const { return m_unit_type; }

    float value() const { return m_value; }
    WebIDL::ExceptionOr<void> set_value(float value);

private:
    SVGLength(JS::Realm&, u8 unit_type, float value);

    virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;

    u8 m_unit_type { 0 };
    float m_value { 0 };
};

}