KHTML
SVGPolyElement.cpp
Go to the documentation of this file.
00001 /* 00002 Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 00003 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 00004 00005 This file is part of the KDE project 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #include "config.h" 00024 #include "wtf/Platform.h" 00025 00026 #if ENABLE(SVG) 00027 #include "SVGPolyElement.h" 00028 00029 #include "Document.h" 00030 #include "FloatPoint.h" 00031 #include "RenderPath.h" 00032 #include "SVGNames.h" 00033 #include "SVGParserUtilities.h" 00034 #include "SVGPointList.h" 00035 00036 namespace WebCore { 00037 00038 SVGPolyElement::SVGPolyElement(const QualifiedName& tagName, Document* doc) 00039 : SVGStyledTransformableElement(tagName, doc) 00040 , SVGTests() 00041 , SVGLangSpace() 00042 , SVGExternalResourcesRequired() 00043 , SVGAnimatedPoints() 00044 , m_ignoreAttributeChanges(false) 00045 { 00046 } 00047 00048 SVGPolyElement::~SVGPolyElement() 00049 { 00050 } 00051 00052 SVGPointList* SVGPolyElement::points() const 00053 { 00054 if (!m_points) 00055 m_points = SVGPointList::create(SVGNames::pointsAttr); 00056 00057 return m_points.get(); 00058 } 00059 00060 SVGPointList* SVGPolyElement::animatedPoints() const 00061 { 00062 // FIXME! 00063 return 0; 00064 } 00065 00066 void SVGPolyElement::parseMappedAttribute(MappedAttribute* attr) 00067 { 00068 const AtomicString& value = attr->value(); 00069 if (attr->name() == SVGNames::pointsAttr) { 00070 ExceptionCode ec = 0; 00071 points()->clear(ec); 00072 00073 if (!pointsListFromSVGData(points(), value)) { 00074 points()->clear(ec); 00075 /*FIXME khtml document()->accessSVGExtensions()->reportError("Problem parsing points=\"" + value.string() + "\"");*/ 00076 } 00077 } else { 00078 if (SVGTests::parseMappedAttribute(attr)) 00079 return; 00080 if (SVGLangSpace::parseMappedAttribute(attr)) 00081 return; 00082 if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) 00083 return; 00084 SVGStyledTransformableElement::parseMappedAttribute(attr); 00085 } 00086 } 00087 00088 void SVGPolyElement::svgAttributeChanged(const QualifiedName& attrName) 00089 { 00090 if (m_ignoreAttributeChanges) 00091 return; 00092 00093 SVGStyledTransformableElement::svgAttributeChanged(attrName); 00094 00095 if (!renderer()) 00096 return; 00097 00098 if (attrName == SVGNames::pointsAttr) { 00099 m_ignoreAttributeChanges = true; 00100 renderer()->setNeedsLayout(true); 00101 00102 //ExceptionCode ec = 0; 00103 00104 // Spec: Additionally, the 'points' attribute on the original element 00105 // accessed via the XML DOM (e.g., using the getAttribute() method call) 00106 // will reflect any changes made to points. 00107 kDebug() << "fixme!!!!!!!!!" << endl; 00108 /*FIXME KHTML String _points; 00109 int len = points()->numberOfItems(); 00110 for (int i = 0; i < len; ++i) { 00111 FloatPoint p = points()->getItem(i, ec); 00112 _points += String::format("%.6lg %.6lg ", p.x(), p.y()); 00113 } 00114 00115 if (RefPtr<Attr> attr = const_cast<SVGPolyElement*>(this)->getAttributeNode(SVGNames::pointsAttr.localName())) { 00116 ExceptionCode ec = 0; 00117 attr->setValue(_points, ec); 00118 }*/ 00119 00120 m_ignoreAttributeChanges = false; 00121 return; 00122 } 00123 00124 if (SVGTests::isKnownAttribute(attrName) || 00125 SVGLangSpace::isKnownAttribute(attrName) || 00126 SVGExternalResourcesRequired::isKnownAttribute(attrName) || 00127 SVGStyledTransformableElement::isKnownAttribute(attrName)) 00128 renderer()->setNeedsLayout(true); 00129 } 00130 00131 } 00132 00133 #endif // ENABLE(SVG)
KDE 4.6 API Reference