don't discard iframe children.
[kdelibs.git] / khtml / svg / SVGCircleElement.cpp
blob0e3851d81c4e368692b9b651717dc1f8da062a5e
1 /*
2 Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
5 This file is part of the KDE project
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
23 #include "config.h"
24 #include "wtf/Platform.h"
26 #if ENABLE(SVG)
27 #include "SVGCircleElement.h"
29 #include "FloatPoint.h"
30 #include "RenderPath.h"
31 #include "SVGNames.h"
33 namespace WebCore {
35 SVGCircleElement::SVGCircleElement(const QualifiedName& tagName, Document* doc)
36 : SVGStyledTransformableElement(tagName, doc)
37 , SVGTests()
38 , SVGLangSpace()
39 , SVGExternalResourcesRequired()
40 , m_cx(SVGLength(this, LengthModeWidth))
41 , m_cy(SVGLength(this, LengthModeHeight))
42 , m_r(SVGLength(this, LengthModeOther))
46 SVGCircleElement::~SVGCircleElement()
50 ANIMATED_PROPERTY_DEFINITIONS(SVGCircleElement, SVGLength, Length, length, Cx, cx, SVGNames::cxAttr, m_cx)
51 ANIMATED_PROPERTY_DEFINITIONS(SVGCircleElement, SVGLength, Length, length, Cy, cy, SVGNames::cyAttr, m_cy)
52 ANIMATED_PROPERTY_DEFINITIONS(SVGCircleElement, SVGLength, Length, length, R, r, SVGNames::rAttr, m_r)
54 void 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");
64 } else {
65 if (SVGTests::parseMappedAttribute(attr))
66 return;
67 if (SVGLangSpace::parseMappedAttribute(attr))
68 return;
69 if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
70 return;
71 SVGStyledTransformableElement::parseMappedAttribute(attr);
75 void SVGCircleElement::svgAttributeChanged(const QualifiedName& attrName)
77 SVGStyledTransformableElement::svgAttributeChanged(attrName);
79 if (!renderer())
80 return;
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);
91 Path SVGCircleElement::toPathData() const
93 return Path::createCircle(FloatPoint(cx().value(), cy().value()), r().value());
96 bool SVGCircleElement::hasRelativeValues() const
98 return (cx().isRelative() || cy().isRelative() || r().isRelative());
101 // KHTML ElementImpl pure virtual method
102 quint32 SVGCircleElement::id() const
104 return SVGNames::circleTag.id();
107 DOMString SVGCircleElement::tagName() const
109 return SVGNames::circleTag.tagName();
115 #endif // ENABLE(SVG)