mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +00:00
LibWeb: Begin implementing SVGRectElement's SVGAnimatedLength attributes
This commit is contained in:
parent
7a6b4e33ba
commit
57296393ed
4 changed files with 77 additions and 6 deletions
|
@ -2841,6 +2841,7 @@ using namespace Web::NavigationTiming;
|
|||
using namespace Web::RequestIdleCallback;
|
||||
using namespace Web::ResizeObserver;
|
||||
using namespace Web::Selection;
|
||||
using namespace Web::SVG;
|
||||
using namespace Web::URL;
|
||||
using namespace Web::WebSockets;
|
||||
using namespace Web::XHR;
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "SVGRectElement.h"
|
||||
#include <LibWeb/SVG/AttributeNames.h>
|
||||
#include <LibWeb/SVG/AttributeParser.h>
|
||||
#include <LibWeb/SVG/SVGAnimatedLength.h>
|
||||
#include <LibWeb/SVG/SVGLength.h>
|
||||
|
||||
namespace Web::SVG {
|
||||
|
||||
|
@ -150,4 +152,64 @@ Gfx::FloatPoint SVGRectElement::calculate_used_corner_radius_values()
|
|||
return Gfx::FloatPoint { rx, ry };
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/SVG11/shapes.html#RectElementXAttribute
|
||||
NonnullRefPtr<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(0, m_x.value_or(0));
|
||||
auto anim_length = SVGLength::create(0, m_x.value_or(0));
|
||||
return SVGAnimatedLength::create(move(base_length), move(anim_length));
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/SVG11/shapes.html#RectElementYAttribute
|
||||
NonnullRefPtr<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(0, m_y.value_or(0));
|
||||
auto anim_length = SVGLength::create(0, m_y.value_or(0));
|
||||
return SVGAnimatedLength::create(move(base_length), move(anim_length));
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/SVG11/shapes.html#RectElementWidthAttribute
|
||||
NonnullRefPtr<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(0, m_width.value_or(0));
|
||||
auto anim_length = SVGLength::create(0, m_width.value_or(0));
|
||||
return SVGAnimatedLength::create(move(base_length), move(anim_length));
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/SVG11/shapes.html#RectElementHeightAttribute
|
||||
NonnullRefPtr<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(0, m_height.value_or(0));
|
||||
auto anim_length = SVGLength::create(0, m_height.value_or(0));
|
||||
return SVGAnimatedLength::create(move(base_length), move(anim_length));
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/SVG11/shapes.html#RectElementRXAttribute
|
||||
NonnullRefPtr<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(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#RectElementRYAttribute
|
||||
NonnullRefPtr<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(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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,13 @@ public:
|
|||
|
||||
virtual Gfx::Path& get_path() override;
|
||||
|
||||
NonnullRefPtr<SVGAnimatedLength> x() const;
|
||||
NonnullRefPtr<SVGAnimatedLength> y() const;
|
||||
NonnullRefPtr<SVGAnimatedLength> width() const;
|
||||
NonnullRefPtr<SVGAnimatedLength> height() const;
|
||||
NonnullRefPtr<SVGAnimatedLength> rx() const;
|
||||
NonnullRefPtr<SVGAnimatedLength> ry() const;
|
||||
|
||||
private:
|
||||
Gfx::FloatPoint calculate_used_corner_radius_values();
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#import <SVG/SVGAnimatedLength.idl>
|
||||
#import <SVG/SVGGeometryElement.idl>
|
||||
|
||||
[Exposed=Window]
|
||||
interface SVGRectElement : SVGGeometryElement {
|
||||
// [SameObject] readonly attribute SVGAnimatedLength x;
|
||||
// [SameObject] readonly attribute SVGAnimatedLength y;
|
||||
// [SameObject] readonly attribute SVGAnimatedLength width;
|
||||
// [SameObject] readonly attribute SVGAnimatedLength height;
|
||||
// [SameObject] readonly attribute SVGAnimatedLength rx;
|
||||
// [SameObject] readonly attribute SVGAnimatedLength ry;
|
||||
[SameObject] readonly attribute SVGAnimatedLength x;
|
||||
[SameObject] readonly attribute SVGAnimatedLength y;
|
||||
[SameObject] readonly attribute SVGAnimatedLength width;
|
||||
[SameObject] readonly attribute SVGAnimatedLength height;
|
||||
[SameObject] readonly attribute SVGAnimatedLength rx;
|
||||
[SameObject] readonly attribute SVGAnimatedLength ry;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue