mirror of
https://github.com/RGBCube/serenity
synced 2025-06-04 16:18:12 +00:00
LibWeb: Expose SVGLineElement attributes to JS
This commit is contained in:
parent
b5ef900ccd
commit
b51ea3a67c
3 changed files with 51 additions and 4 deletions
|
@ -55,4 +55,44 @@ Gfx::Path& SVGLineElement::get_path()
|
||||||
return m_path.value();
|
return m_path.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://www.w3.org/TR/SVG11/shapes.html#LineElementX1Attribute
|
||||||
|
NonnullRefPtr<SVGAnimatedLength> SVGLineElement::x1() 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_x1.value_or(0));
|
||||||
|
auto anim_length = SVGLength::create(0, m_x1.value_or(0));
|
||||||
|
return SVGAnimatedLength::create(move(base_length), move(anim_length));
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://www.w3.org/TR/SVG11/shapes.html#LineElementY1Attribute
|
||||||
|
NonnullRefPtr<SVGAnimatedLength> SVGLineElement::y1() 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_y1.value_or(0));
|
||||||
|
auto anim_length = SVGLength::create(0, m_y1.value_or(0));
|
||||||
|
return SVGAnimatedLength::create(move(base_length), move(anim_length));
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://www.w3.org/TR/SVG11/shapes.html#LineElementX2Attribute
|
||||||
|
NonnullRefPtr<SVGAnimatedLength> SVGLineElement::x2() 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_x2.value_or(0));
|
||||||
|
auto anim_length = SVGLength::create(0, m_x2.value_or(0));
|
||||||
|
return SVGAnimatedLength::create(move(base_length), move(anim_length));
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://www.w3.org/TR/SVG11/shapes.html#LineElementY2Attribute
|
||||||
|
NonnullRefPtr<SVGAnimatedLength> SVGLineElement::y2() 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_y2.value_or(0));
|
||||||
|
auto anim_length = SVGLength::create(0, m_y2.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,11 @@ public:
|
||||||
|
|
||||||
virtual Gfx::Path& get_path() override;
|
virtual Gfx::Path& get_path() override;
|
||||||
|
|
||||||
|
NonnullRefPtr<SVGAnimatedLength> x1() const;
|
||||||
|
NonnullRefPtr<SVGAnimatedLength> y1() const;
|
||||||
|
NonnullRefPtr<SVGAnimatedLength> x2() const;
|
||||||
|
NonnullRefPtr<SVGAnimatedLength> y2() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Optional<Gfx::Path> m_path;
|
Optional<Gfx::Path> m_path;
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
|
#import <SVG/SVGAnimatedLength.idl>
|
||||||
#import <SVG/SVGGeometryElement.idl>
|
#import <SVG/SVGGeometryElement.idl>
|
||||||
|
|
||||||
[Exposed=Window]
|
[Exposed=Window]
|
||||||
interface SVGLineElement : SVGGeometryElement {
|
interface SVGLineElement : SVGGeometryElement {
|
||||||
// [SameObject] readonly attribute SVGAnimatedLength x1;
|
[SameObject] readonly attribute SVGAnimatedLength x1;
|
||||||
// [SameObject] readonly attribute SVGAnimatedLength y1;
|
[SameObject] readonly attribute SVGAnimatedLength y1;
|
||||||
// [SameObject] readonly attribute SVGAnimatedLength x2;
|
[SameObject] readonly attribute SVGAnimatedLength x2;
|
||||||
// [SameObject] readonly attribute SVGAnimatedLength y2;
|
[SameObject] readonly attribute SVGAnimatedLength y2;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue