KHtml

SVGPolyElement.cpp
1 /*
2  Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <[email protected]>
3  2004, 2005, 2006, 2007 Rob Buis <[email protected]>
4 
5  This file is part of the KDE project
6 
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.
11 
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.
16 
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.
21 */
22 
23 #include "wtf/Platform.h"
24 
25 #if ENABLE(SVG)
26 #include "SVGPolyElement.h"
27 
28 #include "Document.h"
29 #include "FloatPoint.h"
30 #include "RenderPath.h"
31 #include "SVGNames.h"
32 #include "SVGParserUtilities.h"
33 #include "SVGPointList.h"
34 
35 namespace WebCore
36 {
37 
38 SVGPolyElement::SVGPolyElement(const QualifiedName &tagName, Document *doc)
39  : SVGStyledTransformableElement(tagName, doc)
40  , SVGTests()
41  , SVGLangSpace()
42  , SVGExternalResourcesRequired()
43  , SVGAnimatedPoints()
44  , m_ignoreAttributeChanges(false)
45 {
46 }
47 
48 SVGPolyElement::~SVGPolyElement()
49 {
50 }
51 
52 SVGPointList *SVGPolyElement::points() const
53 {
54  if (!m_points) {
55  m_points = SVGPointList::create(SVGNames::pointsAttr);
56  }
57 
58  return m_points.get();
59 }
60 
61 SVGPointList *SVGPolyElement::animatedPoints() const
62 {
63  // FIXME!
64  return nullptr;
65 }
66 
67 void SVGPolyElement::parseMappedAttribute(MappedAttribute *attr)
68 {
69  const AtomicString &value = attr->value();
70  if (attr->name() == SVGNames::pointsAttr) {
71  ExceptionCode ec = 0;
72  points()->clear(ec);
73 
74  if (!pointsListFromSVGData(points(), value)) {
75  points()->clear(ec);
76  /*FIXME khtml document()->accessSVGExtensions()->reportError("Problem parsing points=\"" + value.string() + "\"");*/
77  }
78  } else {
79  if (SVGTests::parseMappedAttribute(attr)) {
80  return;
81  }
82  if (SVGLangSpace::parseMappedAttribute(attr)) {
83  return;
84  }
85  if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) {
86  return;
87  }
88  SVGStyledTransformableElement::parseMappedAttribute(attr);
89  }
90 }
91 
92 void SVGPolyElement::svgAttributeChanged(const QualifiedName &attrName)
93 {
94  if (m_ignoreAttributeChanges) {
95  return;
96  }
97 
98  SVGStyledTransformableElement::svgAttributeChanged(attrName);
99 
100  if (!renderer()) {
101  return;
102  }
103 
104  if (attrName == SVGNames::pointsAttr) {
105  m_ignoreAttributeChanges = true;
106  renderer()->setNeedsLayout(true);
107 
108  //ExceptionCode ec = 0;
109 
110  // Spec: Additionally, the 'points' attribute on the original element
111  // accessed via the XML DOM (e.g., using the getAttribute() method call)
112  // will reflect any changes made to points.
113  // qCDebug(KHTML_LOG) << "fixme!!!!!!!!!";
114  /*FIXME KHTML String _points;
115  int len = points()->numberOfItems();
116  for (int i = 0; i < len; ++i) {
117  FloatPoint p = points()->getItem(i, ec);
118  _points += String::format("%.6lg %.6lg ", p.x(), p.y());
119  }
120 
121  if (RefPtr<Attr> attr = const_cast<SVGPolyElement*>(this)->getAttributeNode(SVGNames::pointsAttr.localName())) {
122  ExceptionCode ec = 0;
123  attr->setValue(_points, ec);
124  }*/
125 
126  m_ignoreAttributeChanges = false;
127  return;
128  }
129 
130  if (SVGTests::isKnownAttribute(attrName) ||
131  SVGLangSpace::isKnownAttribute(attrName) ||
132  SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
133  SVGStyledTransformableElement::isKnownAttribute(attrName)) {
134  renderer()->setNeedsLayout(true);
135  }
136 }
137 
138 }
139 
140 #endif // ENABLE(SVG)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 16 2021 22:48:02 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.