LibWeb: Implement SVGLength's read-only property

An SVGLength can be read-only, e.g. all animVal values cannot be
modified. Implement this for all instantiations of SVGLength.

While we're here, add `fake_animated_length_fixme()` so we can easily
find all sites where we need to improve our animated length game.
This commit is contained in:
Jelle Raaijmakers 2025-08-26 16:51:46 +02:00 committed by Jelle Raaijmakers
parent f9a13ecb13
commit 676f5837b3
Notes: github-actions[bot] 2025-08-27 09:51:30 +00:00
16 changed files with 175 additions and 113 deletions

View file

@ -30,23 +30,32 @@ public:
static constexpr unsigned short SVG_LENGTHTYPE_PT = 9;
static constexpr unsigned short SVG_LENGTHTYPE_PC = 10;
[[nodiscard]] static GC::Ref<SVGLength> create(JS::Realm&, u8 unit_type, float value);
virtual ~SVGLength() override;
enum class ReadOnly : u8 {
Yes,
No,
};
u8 unit_type() const { return m_unit_type; }
[[nodiscard]] static GC::Ref<SVGLength> create(JS::Realm&, u8 unit_type, float value, ReadOnly);
virtual ~SVGLength() override;
float value() const { return m_value; }
WebIDL::ExceptionOr<void> set_value(float value);
[[nodiscard]] static GC::Ref<SVGLength> from_length_percentage(JS::Realm&, CSS::LengthPercentage const&);
u8 unit_type() const { return m_unit_type; }
ReadOnly read_only() const { return m_read_only; }
[[nodiscard]] static GC::Ref<SVGLength> from_length_percentage(JS::Realm&, CSS::LengthPercentage const&, ReadOnly);
private:
SVGLength(JS::Realm&, u8 unit_type, float value);
SVGLength(JS::Realm&, u8 unit_type, float value, ReadOnly);
virtual void initialize(JS::Realm&) override;
u8 m_unit_type { 0 };
float m_value { 0 };
u8 m_unit_type { 0 };
// https://svgwg.org/svg2-draft/types.html#ReadOnlyLength
ReadOnly m_read_only;
};
}