2022-03-21 14:20:48 -04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-09-02 14:04:59 +02:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2022-09-25 17:03:42 +01:00
|
|
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
2022-03-21 14:20:48 -04:00
|
|
|
|
|
|
|
namespace Web::SVG {
|
|
|
|
|
|
|
|
// https://www.w3.org/TR/SVG11/types.html#InterfaceSVGLength
|
2022-09-02 14:04:59 +02:00
|
|
|
class SVGLength : public Bindings::PlatformObject {
|
|
|
|
WEB_PLATFORM_OBJECT(SVGLength, Bindings::PlatformObject);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(SVGLength);
|
2022-03-21 14:20:48 -04:00
|
|
|
|
2022-09-02 14:04:59 +02:00
|
|
|
public:
|
2024-04-01 00:44:11 +01:00
|
|
|
// Same as SVGLength.idl
|
|
|
|
static constexpr unsigned short SVG_LENGTHTYPE_UNKNOWN = 0;
|
|
|
|
static constexpr unsigned short SVG_LENGTHTYPE_NUMBER = 1;
|
|
|
|
static constexpr unsigned short SVG_LENGTHTYPE_PERCENTAGE = 2;
|
|
|
|
static constexpr unsigned short SVG_LENGTHTYPE_EMS = 3;
|
|
|
|
static constexpr unsigned short SVG_LENGTHTYPE_EXS = 4;
|
|
|
|
static constexpr unsigned short SVG_LENGTHTYPE_PX = 5;
|
|
|
|
static constexpr unsigned short SVG_LENGTHTYPE_CM = 6;
|
|
|
|
static constexpr unsigned short SVG_LENGTHTYPE_MM = 7;
|
|
|
|
static constexpr unsigned short SVG_LENGTHTYPE_IN = 8;
|
|
|
|
static constexpr unsigned short SVG_LENGTHTYPE_PT = 9;
|
|
|
|
static constexpr unsigned short SVG_LENGTHTYPE_PC = 10;
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
[[nodiscard]] static GC::Ref<SVGLength> create(JS::Realm&, u8 unit_type, float value);
|
2022-09-02 14:04:59 +02:00
|
|
|
virtual ~SVGLength() override;
|
2022-03-21 14:20:48 -04:00
|
|
|
|
|
|
|
u8 unit_type() const { return m_unit_type; }
|
|
|
|
|
|
|
|
float value() const { return m_value; }
|
2022-09-25 17:03:42 +01:00
|
|
|
WebIDL::ExceptionOr<void> set_value(float value);
|
2022-03-21 14:20:48 -04:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
[[nodiscard]] static GC::Ref<SVGLength> from_length_percentage(JS::Realm&, CSS::LengthPercentage const&);
|
2024-03-03 20:33:40 +00:00
|
|
|
|
2022-03-21 14:20:48 -04:00
|
|
|
private:
|
2022-09-25 18:04:39 -06:00
|
|
|
SVGLength(JS::Realm&, u8 unit_type, float value);
|
2022-03-21 14:20:48 -04:00
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2023-01-10 06:28:20 -05:00
|
|
|
|
2022-03-21 14:20:48 -04:00
|
|
|
u8 m_unit_type { 0 };
|
|
|
|
float m_value { 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|