OSDN Git Service

Merge "Trigger a full rebuild of webcore to get the Chrome http stack as default"
[android-x86/external-webkit.git] / WebCore / svg / SVGPolyElement.cpp
1 /*
2  * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3  * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4  *
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.
9  *
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.
14  *
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.
19  */
20
21 #include "config.h"
22
23 #if ENABLE(SVG)
24 #include "SVGPolyElement.h"
25
26 #include "Attribute.h"
27 #include "Document.h"
28 #include "FloatPoint.h"
29 #include "RenderPath.h"
30 #include "RenderSVGResource.h"
31 #include "SVGNames.h"
32 #include "SVGParserUtilities.h"
33 #include "SVGPointList.h"
34
35 namespace WebCore {
36
37 SVGPolyElement::SVGPolyElement(const QualifiedName& tagName, Document* doc)
38     : SVGStyledTransformableElement(tagName, doc)
39     , SVGTests()
40     , SVGLangSpace()
41     , SVGExternalResourcesRequired()
42     , SVGAnimatedPoints()
43 {
44 }
45
46 SVGPolyElement::~SVGPolyElement()
47 {
48 }
49
50 SVGPointList* SVGPolyElement::points() const
51 {
52     if (!m_points)
53         m_points = SVGPointList::create(SVGNames::pointsAttr);
54
55     return m_points.get();
56 }
57
58 SVGPointList* SVGPolyElement::animatedPoints() const
59 {
60     // FIXME!
61     return 0;
62 }
63
64 void SVGPolyElement::parseMappedAttribute(Attribute* attr)
65 {
66     const AtomicString& value = attr->value();
67     if (attr->name() == SVGNames::pointsAttr) {
68         ExceptionCode ec = 0;
69         points()->clear(ec);
70
71         if (!pointsListFromSVGData(points(), value))
72             document()->accessSVGExtensions()->reportError("Problem parsing points=\"" + value + "\"");
73     } else {
74         if (SVGTests::parseMappedAttribute(attr))
75             return;
76         if (SVGLangSpace::parseMappedAttribute(attr))
77             return;
78         if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
79             return;
80         SVGStyledTransformableElement::parseMappedAttribute(attr);
81     }
82 }
83
84 void SVGPolyElement::svgAttributeChanged(const QualifiedName& attrName)
85 {
86     SVGStyledTransformableElement::svgAttributeChanged(attrName);
87
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();
91
92     RenderPath* renderer = static_cast<RenderPath*>(this->renderer());
93     if (!renderer)
94         return;
95
96     if (SVGStyledTransformableElement::isKnownAttribute(attrName)) {
97         renderer->setNeedsTransformUpdate();
98         RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
99         return;
100     }
101
102     if (attrName == SVGNames::pointsAttr) {
103         renderer->setNeedsPathUpdate();
104         RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
105         return;
106     }
107
108     if (SVGTests::isKnownAttribute(attrName)
109         || SVGLangSpace::isKnownAttribute(attrName)
110         || SVGExternalResourcesRequired::isKnownAttribute(attrName))
111         RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
112 }
113
114 void SVGPolyElement::synchronizeProperty(const QualifiedName& attrName)
115 {
116     SVGStyledTransformableElement::synchronizeProperty(attrName);
117
118     if (attrName == anyQName()) {
119         synchronizeExternalResourcesRequired();
120         SVGAnimatedPropertySynchronizer<true>::synchronize(this, SVGNames::pointsAttr, points()->valueAsString());
121         return;
122     }
123
124     if (SVGExternalResourcesRequired::isKnownAttribute(attrName))
125         synchronizeExternalResourcesRequired();
126     else if (attrName == SVGNames::pointsAttr)
127         SVGAnimatedPropertySynchronizer<true>::synchronize(this, attrName, points()->valueAsString());
128 }
129
130 }
131
132 #endif // ENABLE(SVG)