2022-03-21 14:20:48 -04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2022-09-25 18:04:39 -06:00
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
2022-03-21 14:20:48 -04:00
|
|
|
#include <LibWeb/SVG/SVGLength.h>
|
|
|
|
|
|
|
|
namespace Web::SVG {
|
|
|
|
|
2023-11-19 19:47:52 +01:00
|
|
|
JS_DEFINE_ALLOCATOR(SVGLength);
|
|
|
|
|
2023-08-13 13:05:26 +02:00
|
|
|
JS::NonnullGCPtr<SVGLength> SVGLength::create(JS::Realm& realm, u8 unit_type, float value)
|
2022-03-21 14:20:48 -04:00
|
|
|
{
|
2023-08-13 13:05:26 +02:00
|
|
|
return realm.heap().allocate<SVGLength>(realm, realm, unit_type, value);
|
2022-03-21 14:20:48 -04:00
|
|
|
}
|
|
|
|
|
2022-09-25 18:04:39 -06:00
|
|
|
SVGLength::SVGLength(JS::Realm& realm, u8 unit_type, float value)
|
|
|
|
: PlatformObject(realm)
|
2022-09-02 14:04:59 +02:00
|
|
|
, m_unit_type(unit_type)
|
2022-03-21 14:20:48 -04:00
|
|
|
, m_value(value)
|
|
|
|
{
|
2023-01-10 06:28:20 -05:00
|
|
|
}
|
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
void SVGLength::initialize(JS::Realm& realm)
|
2023-01-10 06:28:20 -05:00
|
|
|
{
|
2023-08-07 08:41:28 +02:00
|
|
|
Base::initialize(realm);
|
2023-11-22 12:55:21 +13:00
|
|
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGLengthPrototype>(realm, "SVGLength"_fly_string));
|
2022-03-21 14:20:48 -04:00
|
|
|
}
|
|
|
|
|
2022-09-02 14:04:59 +02:00
|
|
|
SVGLength::~SVGLength() = default;
|
|
|
|
|
2022-03-21 14:20:48 -04:00
|
|
|
// https://www.w3.org/TR/SVG11/types.html#__svg__SVGLength__value
|
2022-09-25 17:03:42 +01:00
|
|
|
WebIDL::ExceptionOr<void> SVGLength::set_value(float value)
|
2022-03-21 14:20:48 -04:00
|
|
|
{
|
|
|
|
// FIXME: Raise an exception if this <length> is read-only.
|
|
|
|
m_value = value;
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|