24#include "wtf/Platform.h"
30#include "RenderPath.h"
36SVGLineElement::SVGLineElement(
const QualifiedName& tagName, Document* doc)
37 : SVGStyledTransformableElement(tagName, doc)
40 , SVGExternalResourcesRequired()
41 , m_x1(this, LengthModeWidth)
42 , m_y1(this, LengthModeHeight)
43 , m_x2(this, LengthModeWidth)
44 , m_y2(this, LengthModeHeight)
48SVGLineElement::~SVGLineElement()
52ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, X1, x1, SVGNames::x1Attr, m_x1)
53ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, Y1, y1, SVGNames::y1Attr, m_y1)
54ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, X2, x2, SVGNames::x2Attr, m_x2)
55ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, Y2, y2, SVGNames::y2Attr, m_y2)
57void SVGLineElement::parseMappedAttribute(MappedAttribute* attr)
59 if (attr->name() == SVGNames::x1Attr)
60 setX1BaseValue(SVGLength(
this, LengthModeWidth, attr->value()));
61 else if (attr->name() == SVGNames::y1Attr)
62 setY1BaseValue(SVGLength(
this, LengthModeHeight, attr->value()));
63 else if (attr->name() == SVGNames::x2Attr)
64 setX2BaseValue(SVGLength(
this, LengthModeWidth, attr->value()));
65 else if (attr->name() == SVGNames::y2Attr)
66 setY2BaseValue(SVGLength(
this, LengthModeHeight, attr->value()));
69 if (SVGTests::parseMappedAttribute(attr))
71 if (SVGLangSpace::parseMappedAttribute(attr))
73 if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
75 SVGStyledTransformableElement::parseMappedAttribute(attr);
79void SVGLineElement::svgAttributeChanged(
const QualifiedName& attrName)
81 SVGStyledTransformableElement::svgAttributeChanged(attrName);
86 if (attrName == SVGNames::x1Attr || attrName == SVGNames::y1Attr ||
87 attrName == SVGNames::x2Attr || attrName == SVGNames::y2Attr ||
88 SVGTests::isKnownAttribute(attrName) ||
89 SVGLangSpace::isKnownAttribute(attrName) ||
90 SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
91 SVGStyledTransformableElement::isKnownAttribute(attrName))
92 renderer()->setNeedsLayout(
true);
95Path SVGLineElement::toPathData()
const
97 return Path::createLine(FloatPoint(x1().value(), y1().value()),
98 FloatPoint(x2().value(), y2().value()));
101bool SVGLineElement::hasRelativeValues()
const
103 return (x1().isRelative() || y1().isRelative() ||
104 x2().isRelative() || y2().isRelative());