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
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

@ -158,9 +158,9 @@ GC::Ref<SVGAnimatedLength> SVGRectElement::x() const
{
// FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_x.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_x.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_x.value_or(0), SVGLength::ReadOnly::No);
auto anim_length = SVGLength::create(realm(), 0, m_x.value_or(0), SVGLength::ReadOnly::Yes);
return SVGAnimatedLength::create(realm(), base_length, anim_length);
}
// https://www.w3.org/TR/SVG11/shapes.html#RectElementYAttribute
@ -168,9 +168,9 @@ GC::Ref<SVGAnimatedLength> SVGRectElement::y() const
{
// FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_y.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_y.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_y.value_or(0), SVGLength::ReadOnly::No);
auto anim_length = SVGLength::create(realm(), 0, m_y.value_or(0), SVGLength::ReadOnly::Yes);
return SVGAnimatedLength::create(realm(), base_length, anim_length);
}
// https://www.w3.org/TR/SVG11/shapes.html#RectElementWidthAttribute
@ -178,9 +178,9 @@ GC::Ref<SVGAnimatedLength> SVGRectElement::width() const
{
// FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_width.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_width.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_width.value_or(0), SVGLength::ReadOnly::No);
auto anim_length = SVGLength::create(realm(), 0, m_width.value_or(0), SVGLength::ReadOnly::Yes);
return SVGAnimatedLength::create(realm(), base_length, anim_length);
}
// https://www.w3.org/TR/SVG11/shapes.html#RectElementHeightAttribute
@ -188,9 +188,9 @@ GC::Ref<SVGAnimatedLength> SVGRectElement::height() const
{
// FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_height.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_height.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_height.value_or(0), SVGLength::ReadOnly::No);
auto anim_length = SVGLength::create(realm(), 0, m_height.value_or(0), SVGLength::ReadOnly::Yes);
return SVGAnimatedLength::create(realm(), base_length, anim_length);
}
// https://www.w3.org/TR/SVG11/shapes.html#RectElementRXAttribute
@ -198,9 +198,9 @@ GC::Ref<SVGAnimatedLength> SVGRectElement::rx() const
{
// FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0), SVGLength::ReadOnly::No);
auto anim_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0), SVGLength::ReadOnly::Yes);
return SVGAnimatedLength::create(realm(), base_length, anim_length);
}
// https://www.w3.org/TR/SVG11/shapes.html#RectElementRYAttribute
@ -208,9 +208,9 @@ GC::Ref<SVGAnimatedLength> SVGRectElement::ry() const
{
// FIXME: Populate the unit type when it is parsed (0 here is "unknown").
// FIXME: Create a proper animated value when animations are supported.
auto base_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0));
auto anim_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0));
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
auto base_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0), SVGLength::ReadOnly::No);
auto anim_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0), SVGLength::ReadOnly::Yes);
return SVGAnimatedLength::create(realm(), base_length, anim_length);
}
}