2023-04-18 18:51:00 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2023, MacDue <macdue@dueutil.tech>
|
2025-07-10 17:13:52 +02:00
|
|
|
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
2023-04-18 18:51:00 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2025-07-10 17:13:52 +02:00
|
|
|
#include <LibWeb/SVG/SVGElement.h>
|
2023-04-18 18:51:00 +01:00
|
|
|
|
|
|
|
namespace Web::SVG {
|
|
|
|
|
2025-07-10 17:13:52 +02:00
|
|
|
// https://svgwg.org/svg2-draft/types.html#InterfaceSVGAnimatedNumber
|
2023-04-18 18:51:00 +01:00
|
|
|
class SVGAnimatedNumber final : public Bindings::PlatformObject {
|
|
|
|
WEB_PLATFORM_OBJECT(SVGAnimatedNumber, Bindings::PlatformObject);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(SVGAnimatedNumber);
|
2023-04-18 18:51:00 +01:00
|
|
|
|
|
|
|
public:
|
2025-07-10 17:13:52 +02:00
|
|
|
enum class SupportsSecondValue : u8 {
|
|
|
|
Yes,
|
|
|
|
No,
|
|
|
|
};
|
|
|
|
enum class ValueRepresented : u8 {
|
|
|
|
First,
|
|
|
|
Second,
|
|
|
|
};
|
|
|
|
|
|
|
|
[[nodiscard]] static GC::Ref<SVGAnimatedNumber> create(JS::Realm&, GC::Ref<SVGElement>,
|
|
|
|
FlyString reflected_attribute, float initial_value, SupportsSecondValue = SupportsSecondValue::No,
|
|
|
|
ValueRepresented = ValueRepresented::First);
|
2023-04-18 18:51:00 +01:00
|
|
|
virtual ~SVGAnimatedNumber() override;
|
|
|
|
|
2025-07-10 17:13:52 +02:00
|
|
|
float base_val() const;
|
|
|
|
void set_base_val(float);
|
2023-04-18 18:51:00 +01:00
|
|
|
|
2025-07-10 17:13:52 +02:00
|
|
|
float anim_val() const;
|
2023-04-18 18:51:00 +01:00
|
|
|
|
|
|
|
private:
|
2025-07-10 17:13:52 +02:00
|
|
|
SVGAnimatedNumber(JS::Realm&, GC::Ref<SVGElement>, FlyString, float, SupportsSecondValue, ValueRepresented);
|
2023-04-18 18:51:00 +01:00
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2025-07-10 17:13:52 +02:00
|
|
|
virtual void visit_edges(Visitor&) override;
|
2023-04-18 18:51:00 +01:00
|
|
|
|
2025-07-10 17:13:52 +02:00
|
|
|
float parse_value_or_initial(StringView) const;
|
|
|
|
float get_base_or_anim_value() const;
|
|
|
|
|
|
|
|
GC::Ref<SVGElement> m_element;
|
|
|
|
FlyString m_reflected_attribute;
|
|
|
|
float m_initial_value;
|
|
|
|
SupportsSecondValue m_supports_second_value;
|
|
|
|
ValueRepresented m_value_represented;
|
2023-04-18 18:51:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|