1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:48:12 +00:00

LibWeb: Expose SVGEllipseElement attributes to JS

This commit is contained in:
Sam Atkins 2022-03-22 16:57:00 +00:00 committed by Andreas Kling
parent 1a3d6c68ef
commit ccee8953d0
3 changed files with 51 additions and 4 deletions

View file

@ -75,4 +75,44 @@ Gfx::Path& SVGEllipseElement::get_path()
return m_path.value();
}
// https://www.w3.org/TR/SVG11/shapes.html#EllipseElementCXAttribute
NonnullRefPtr<SVGAnimatedLength> SVGEllipseElement::cx() 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(0, m_center_x.value_or(0));
auto anim_length = SVGLength::create(0, m_center_x.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length));
}
// https://www.w3.org/TR/SVG11/shapes.html#EllipseElementCYAttribute
NonnullRefPtr<SVGAnimatedLength> SVGEllipseElement::cy() 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(0, m_center_y.value_or(0));
auto anim_length = SVGLength::create(0, m_center_y.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length));
}
// https://www.w3.org/TR/SVG11/shapes.html#EllipseElementRXAttribute
NonnullRefPtr<SVGAnimatedLength> SVGEllipseElement::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(0, m_radius_x.value_or(0));
auto anim_length = SVGLength::create(0, m_radius_x.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length));
}
// https://www.w3.org/TR/SVG11/shapes.html#EllipseElementRYAttribute
NonnullRefPtr<SVGAnimatedLength> SVGEllipseElement::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(0, m_radius_y.value_or(0));
auto anim_length = SVGLength::create(0, m_radius_y.value_or(0));
return SVGAnimatedLength::create(move(base_length), move(anim_length));
}
}

View file

@ -6,6 +6,7 @@
#pragma once
#include <LibWeb/SVG/SVGAnimatedLength.h>
#include <LibWeb/SVG/SVGGeometryElement.h>
namespace Web::SVG {
@ -21,6 +22,11 @@ public:
virtual Gfx::Path& get_path() override;
NonnullRefPtr<SVGAnimatedLength> cx() const;
NonnullRefPtr<SVGAnimatedLength> cy() const;
NonnullRefPtr<SVGAnimatedLength> rx() const;
NonnullRefPtr<SVGAnimatedLength> ry() const;
private:
Optional<Gfx::Path> m_path;

View file

@ -1,9 +1,10 @@
#import <SVG/SVGAnimatedLength.idl>
#import <SVG/SVGGeometryElement.idl>
[Exposed=Window]
interface SVGEllipseElement : SVGGeometryElement {
// [SameObject] readonly attribute SVGAnimatedLength cx;
// [SameObject] readonly attribute SVGAnimatedLength cy;
// [SameObject] readonly attribute SVGAnimatedLength rx;
// [SameObject] readonly attribute SVGAnimatedLength ry;
[SameObject] readonly attribute SVGAnimatedLength cx;
[SameObject] readonly attribute SVGAnimatedLength cy;
[SameObject] readonly attribute SVGAnimatedLength rx;
[SameObject] readonly attribute SVGAnimatedLength ry;
};