mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:37:34 +00:00
LibWeb: Expose SVGCircleElement attributes to JS
This commit is contained in:
parent
b51ea3a67c
commit
1a3d6c68ef
3 changed files with 39 additions and 3 deletions
|
@ -70,4 +70,34 @@ Gfx::Path& SVGCircleElement::get_path()
|
||||||
return m_path.value();
|
return m_path.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://www.w3.org/TR/SVG11/shapes.html#CircleElementCXAttribute
|
||||||
|
NonnullRefPtr<SVGAnimatedLength> SVGCircleElement::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#CircleElementCYAttribute
|
||||||
|
NonnullRefPtr<SVGAnimatedLength> SVGCircleElement::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#CircleElementRAttribute
|
||||||
|
NonnullRefPtr<SVGAnimatedLength> SVGCircleElement::r() 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.value_or(0));
|
||||||
|
auto anim_length = SVGLength::create(0, m_radius.value_or(0));
|
||||||
|
return SVGAnimatedLength::create(move(base_length), move(anim_length));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/SVG/SVGAnimatedLength.h>
|
||||||
#include <LibWeb/SVG/SVGGeometryElement.h>
|
#include <LibWeb/SVG/SVGGeometryElement.h>
|
||||||
|
|
||||||
namespace Web::SVG {
|
namespace Web::SVG {
|
||||||
|
@ -21,6 +22,10 @@ public:
|
||||||
|
|
||||||
virtual Gfx::Path& get_path() override;
|
virtual Gfx::Path& get_path() override;
|
||||||
|
|
||||||
|
NonnullRefPtr<SVGAnimatedLength> cx() const;
|
||||||
|
NonnullRefPtr<SVGAnimatedLength> cy() const;
|
||||||
|
NonnullRefPtr<SVGAnimatedLength> r() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Optional<Gfx::Path> m_path;
|
Optional<Gfx::Path> m_path;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
#import <SVG/SVGAnimatedLength.idl>
|
||||||
#import <SVG/SVGGeometryElement.idl>
|
#import <SVG/SVGGeometryElement.idl>
|
||||||
|
|
||||||
[Exposed=Window]
|
[Exposed=Window]
|
||||||
interface SVGCircleElement : SVGGeometryElement {
|
interface SVGCircleElement : SVGGeometryElement {
|
||||||
// [SameObject] readonly attribute SVGAnimatedLength cx;
|
[SameObject] readonly attribute SVGAnimatedLength cx;
|
||||||
// [SameObject] readonly attribute SVGAnimatedLength cy;
|
[SameObject] readonly attribute SVGAnimatedLength cy;
|
||||||
// [SameObject] readonly attribute SVGAnimatedLength r;
|
[SameObject] readonly attribute SVGAnimatedLength r;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue