24#include "wtf/Platform.h"
30#include "RenderPath.h"
35SVGCircleElement::SVGCircleElement(
const QualifiedName& tagName, Document* doc)
36 : SVGStyledTransformableElement(tagName, doc)
39 , SVGExternalResourcesRequired()
40 , m_cx(SVGLength(this, LengthModeWidth))
41 , m_cy(SVGLength(this, LengthModeHeight))
42 , m_r(SVGLength(this, LengthModeOther))
46SVGCircleElement::~SVGCircleElement()
50ANIMATED_PROPERTY_DEFINITIONS(SVGCircleElement, SVGLength, Length, length, Cx, cx, SVGNames::cxAttr, m_cx)
51ANIMATED_PROPERTY_DEFINITIONS(SVGCircleElement, SVGLength, Length, length, Cy, cy, SVGNames::cyAttr, m_cy)
52ANIMATED_PROPERTY_DEFINITIONS(SVGCircleElement, SVGLength, Length, length, R, r, SVGNames::rAttr, m_r)
54void SVGCircleElement::parseMappedAttribute(MappedAttribute* attr)
56 if (attr->name() == SVGNames::cxAttr)
57 setCxBaseValue(SVGLength(
this, LengthModeWidth, attr->value()));
58 else if (attr->name() == SVGNames::cyAttr)
59 setCyBaseValue(SVGLength(
this, LengthModeHeight, attr->value()));
60 else if (attr->name() == SVGNames::rAttr) {
61 setRBaseValue(SVGLength(
this, LengthModeOther, attr->value()));
62 if (r().value() < 0.0)
63 document()->accessSVGExtensions()->reportError(
"A negative value for circle <r> is not allowed");
65 if (SVGTests::parseMappedAttribute(attr))
67 if (SVGLangSpace::parseMappedAttribute(attr))
69 if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
71 SVGStyledTransformableElement::parseMappedAttribute(attr);
75void SVGCircleElement::svgAttributeChanged(
const QualifiedName& attrName)
77 SVGStyledTransformableElement::svgAttributeChanged(attrName);
82 if (attrName == SVGNames::cxAttr || attrName == SVGNames::cyAttr ||
83 attrName == SVGNames::rAttr ||
84 SVGTests::isKnownAttribute(attrName) ||
85 SVGLangSpace::isKnownAttribute(attrName) ||
86 SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
87 SVGStyledTransformableElement::isKnownAttribute(attrName))
88 renderer()->setNeedsLayout(
true);
91Path SVGCircleElement::toPathData()
const
93 return Path::createCircle(FloatPoint(cx().value(), cy().value()), r().value());
96bool SVGCircleElement::hasRelativeValues()
const
98 return (cx().isRelative() || cy().isRelative() || r().isRelative());
102quint32 SVGCircleElement::id()
const
104 return SVGNames::circleTag.id();