|
@@ -30,23 +30,26 @@ void SVGLineElement::attribute_changed(FlyString const& name, Optional<String> c
|
|
|
SVGGeometryElement::attribute_changed(name, old_value, value);
|
|
|
|
|
|
if (name == SVG::AttributeNames::x1) {
|
|
|
- m_x1 = AttributeParser::parse_coordinate(value.value_or(String {}));
|
|
|
+ m_x1 = AttributeParser::parse_number_percentage(value.value_or(String {}));
|
|
|
} else if (name == SVG::AttributeNames::y1) {
|
|
|
- m_y1 = AttributeParser::parse_coordinate(value.value_or(String {}));
|
|
|
+ m_y1 = AttributeParser::parse_number_percentage(value.value_or(String {}));
|
|
|
} else if (name == SVG::AttributeNames::x2) {
|
|
|
- m_x2 = AttributeParser::parse_coordinate(value.value_or(String {}));
|
|
|
+ m_x2 = AttributeParser::parse_number_percentage(value.value_or(String {}));
|
|
|
} else if (name == SVG::AttributeNames::y2) {
|
|
|
- m_y2 = AttributeParser::parse_coordinate(value.value_or(String {}));
|
|
|
+ m_y2 = AttributeParser::parse_number_percentage(value.value_or(String {}));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-Gfx::Path SVGLineElement::get_path(CSSPixelSize)
|
|
|
+Gfx::Path SVGLineElement::get_path(CSSPixelSize viewport_size)
|
|
|
{
|
|
|
+ auto const viewport_width = viewport_size.width().to_float();
|
|
|
+ auto const viewport_height = viewport_size.height().to_float();
|
|
|
+
|
|
|
Gfx::Path path;
|
|
|
- float x1 = m_x1.value_or(0);
|
|
|
- float y1 = m_y1.value_or(0);
|
|
|
- float x2 = m_x2.value_or(0);
|
|
|
- float y2 = m_y2.value_or(0);
|
|
|
+ float const x1 = m_x1.value_or({ 0, false }).resolve_relative_to(viewport_width);
|
|
|
+ float const y1 = m_y1.value_or({ 0, false }).resolve_relative_to(viewport_height);
|
|
|
+ float const x2 = m_x2.value_or({ 0, false }).resolve_relative_to(viewport_width);
|
|
|
+ float const y2 = m_y2.value_or({ 0, false }).resolve_relative_to(viewport_height);
|
|
|
|
|
|
// 1. perform an absolute moveto operation to absolute location (x1,y1)
|
|
|
path.move_to({ x1, y1 });
|
|
@@ -62,8 +65,8 @@ JS::NonnullGCPtr<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(realm(), 0, m_x1.value_or(0));
|
|
|
- auto anim_length = SVGLength::create(realm(), 0, m_x1.value_or(0));
|
|
|
+ auto base_length = SVGLength::create(realm(), 0, m_x1.value_or({ 0, false }).value());
|
|
|
+ auto anim_length = SVGLength::create(realm(), 0, m_x1.value_or({ 0, false }).value());
|
|
|
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
|
|
|
}
|
|
|
|
|
@@ -72,8 +75,8 @@ JS::NonnullGCPtr<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(realm(), 0, m_y1.value_or(0));
|
|
|
- auto anim_length = SVGLength::create(realm(), 0, m_y1.value_or(0));
|
|
|
+ auto base_length = SVGLength::create(realm(), 0, m_y1.value_or({ 0, false }).value());
|
|
|
+ auto anim_length = SVGLength::create(realm(), 0, m_y1.value_or({ 0, false }).value());
|
|
|
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
|
|
|
}
|
|
|
|
|
@@ -82,8 +85,8 @@ JS::NonnullGCPtr<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(realm(), 0, m_x2.value_or(0));
|
|
|
- auto anim_length = SVGLength::create(realm(), 0, m_x2.value_or(0));
|
|
|
+ auto base_length = SVGLength::create(realm(), 0, m_x2.value_or({ 0, false }).value());
|
|
|
+ auto anim_length = SVGLength::create(realm(), 0, m_x2.value_or({ 0, false }).value());
|
|
|
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
|
|
|
}
|
|
|
|
|
@@ -92,8 +95,8 @@ JS::NonnullGCPtr<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(realm(), 0, m_y2.value_or(0));
|
|
|
- auto anim_length = SVGLength::create(realm(), 0, m_y2.value_or(0));
|
|
|
+ auto base_length = SVGLength::create(realm(), 0, m_y2.value_or({ 0, false }).value());
|
|
|
+ auto anim_length = SVGLength::create(realm(), 0, m_y2.value_or({ 0, false }).value());
|
|
|
return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length));
|
|
|
}
|
|
|
|