2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
24 #include "SVGPolyElement.h"
26 #include "Attribute.h"
28 #include "FloatPoint.h"
29 #include "RenderPath.h"
30 #include "RenderSVGResource.h"
32 #include "SVGParserUtilities.h"
33 #include "SVGPointList.h"
37 SVGPolyElement::SVGPolyElement(const QualifiedName& tagName, Document* doc)
38 : SVGStyledTransformableElement(tagName, doc)
41 , SVGExternalResourcesRequired()
46 SVGPolyElement::~SVGPolyElement()
50 SVGPointList* SVGPolyElement::points() const
53 m_points = SVGPointList::create(SVGNames::pointsAttr);
55 return m_points.get();
58 SVGPointList* SVGPolyElement::animatedPoints() const
64 void SVGPolyElement::parseMappedAttribute(Attribute* attr)
66 const AtomicString& value = attr->value();
67 if (attr->name() == SVGNames::pointsAttr) {
71 if (!pointsListFromSVGData(points(), value))
72 document()->accessSVGExtensions()->reportError("Problem parsing points=\"" + value + "\"");
74 if (SVGTests::parseMappedAttribute(attr))
76 if (SVGLangSpace::parseMappedAttribute(attr))
78 if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
80 SVGStyledTransformableElement::parseMappedAttribute(attr);
84 void SVGPolyElement::svgAttributeChanged(const QualifiedName& attrName)
86 SVGStyledTransformableElement::svgAttributeChanged(attrName);
88 // The points property is not a regular SVGAnimatedProperty, still we use the same SVG<->XML DOM synchronization framework.
89 if (attrName == SVGNames::pointsAttr)
90 invalidateSVGAttributes();
92 RenderPath* renderer = static_cast<RenderPath*>(this->renderer());
96 if (SVGStyledTransformableElement::isKnownAttribute(attrName)) {
97 renderer->setNeedsTransformUpdate();
98 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
102 if (attrName == SVGNames::pointsAttr) {
103 renderer->setNeedsPathUpdate();
104 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
108 if (SVGTests::isKnownAttribute(attrName)
109 || SVGLangSpace::isKnownAttribute(attrName)
110 || SVGExternalResourcesRequired::isKnownAttribute(attrName))
111 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
114 void SVGPolyElement::synchronizeProperty(const QualifiedName& attrName)
116 SVGStyledTransformableElement::synchronizeProperty(attrName);
118 if (attrName == anyQName()) {
119 synchronizeExternalResourcesRequired();
120 SVGAnimatedPropertySynchronizer<true>::synchronize(this, SVGNames::pointsAttr, points()->valueAsString());
124 if (SVGExternalResourcesRequired::isKnownAttribute(attrName))
125 synchronizeExternalResourcesRequired();
126 else if (attrName == SVGNames::pointsAttr)
127 SVGAnimatedPropertySynchronizer<true>::synchronize(this, attrName, points()->valueAsString());
132 #endif // ENABLE(SVG)