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 "RenderSVGPath.h"
30 #include "RenderSVGResource.h"
32 #include "SVGParserUtilities.h"
33 #include "SVGPointList.h"
37 SVGPolyElement::SVGPolyElement(const QualifiedName& tagName, Document* document)
38 : SVGStyledTransformableElement(tagName, document)
42 SVGPointList* SVGPolyElement::points() const
45 m_points = SVGPointList::create(SVGNames::pointsAttr);
47 return m_points.get();
50 SVGPointList* SVGPolyElement::animatedPoints() const
56 void SVGPolyElement::parseMappedAttribute(Attribute* attr)
58 const AtomicString& value = attr->value();
59 if (attr->name() == SVGNames::pointsAttr) {
63 if (!pointsListFromSVGData(points(), value))
64 document()->accessSVGExtensions()->reportError("Problem parsing points=\"" + value + "\"");
66 if (SVGTests::parseMappedAttribute(attr))
68 if (SVGLangSpace::parseMappedAttribute(attr))
70 if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
72 SVGStyledTransformableElement::parseMappedAttribute(attr);
76 void SVGPolyElement::svgAttributeChanged(const QualifiedName& attrName)
78 SVGStyledTransformableElement::svgAttributeChanged(attrName);
80 // The points property is not a regular SVGAnimatedProperty, still we use the same SVG<->XML DOM synchronization framework.
81 if (attrName == SVGNames::pointsAttr)
82 invalidateSVGAttributes();
84 RenderSVGPath* renderer = static_cast<RenderSVGPath*>(this->renderer());
88 if (SVGStyledTransformableElement::isKnownAttribute(attrName)) {
89 renderer->setNeedsTransformUpdate();
90 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
94 if (attrName == SVGNames::pointsAttr) {
95 renderer->setNeedsPathUpdate();
96 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
100 if (SVGTests::isKnownAttribute(attrName)
101 || SVGLangSpace::isKnownAttribute(attrName)
102 || SVGExternalResourcesRequired::isKnownAttribute(attrName))
103 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
106 void SVGPolyElement::synchronizeProperty(const QualifiedName& attrName)
108 SVGStyledTransformableElement::synchronizeProperty(attrName);
110 if (attrName == anyQName()) {
111 synchronizeExternalResourcesRequired();
112 SVGAnimatedPropertySynchronizer<true>::synchronize(this, SVGNames::pointsAttr, points()->valueAsString());
116 if (SVGExternalResourcesRequired::isKnownAttribute(attrName))
117 synchronizeExternalResourcesRequired();
118 else if (attrName == SVGNames::pointsAttr)
119 SVGAnimatedPropertySynchronizer<true>::synchronize(this, attrName, points()->valueAsString());
124 #endif // ENABLE(SVG)