KHtml

SVGTests.cpp
1 /*
2  Copyright (C) 2004, 2005, 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 "SVGTests.h"
27 
28 //#include "DOMImplementation.h"
29 //#include "Language.h"
30 #include "SVGElement.h"
31 #include "SVGNames.h"
32 #include "SVGStringList.h"
33 
34 namespace WebCore
35 {
36 
37 SVGTests::SVGTests()
38 {
39 }
40 
41 SVGTests::~SVGTests()
42 {
43 }
44 
45 SVGStringList *SVGTests::requiredFeatures() const
46 {
47  if (!m_features) {
48  m_features = SVGStringList::create(SVGNames::requiredFeaturesAttr);
49  }
50 
51  return m_features.get();
52 }
53 
54 SVGStringList *SVGTests::requiredExtensions() const
55 {
56  if (!m_extensions) {
57  m_extensions = SVGStringList::create(SVGNames::requiredExtensionsAttr);
58  }
59 
60  return m_extensions.get();
61 }
62 
63 SVGStringList *SVGTests::systemLanguage() const
64 {
65  if (!m_systemLanguage) {
66  m_systemLanguage = SVGStringList::create(SVGNames::systemLanguageAttr);
67  }
68 
69  return m_systemLanguage.get();
70 }
71 
72 bool SVGTests::hasExtension(const String &) const
73 {
74  return false;
75 }
76 
77 bool SVGTests::isValid() const
78 {
79  ExceptionCode ec = 0;
80 
81  if (m_features) {
82  for (unsigned long i = 0; i < m_features->numberOfItems(); i++) {
83  String value = m_features->getItem(i, ec);
84  if (value.isEmpty() || !DOMImplementation::hasFeature(value, String())) {
85  return false;
86  }
87  }
88  }
89 
90  /*if (m_systemLanguage) {
91  for (unsigned long i = 0; i < m_systemLanguage->numberOfItems(); i++)
92  if (m_systemLanguage->getItem(i, ec) != defaultLanguage().substring(0, 2))
93  return false;
94  }*/
95 
96  if (m_extensions && m_extensions->numberOfItems() > 0) {
97  return false;
98  }
99 
100  return true;
101 }
102 
103 bool SVGTests::parseMappedAttribute(MappedAttribute *attr)
104 {
105  if (attr->name() == SVGNames::requiredFeaturesAttr) {
106  requiredFeatures()->reset(attr->value());
107  return true;
108  } else if (attr->name() == SVGNames::requiredExtensionsAttr) {
109  requiredExtensions()->reset(attr->value());
110  return true;
111  } else if (attr->name() == SVGNames::systemLanguageAttr) {
112  systemLanguage()->reset(attr->value());
113  return true;
114  }
115 
116  return false;
117 }
118 
119 bool SVGTests::isKnownAttribute(const QualifiedName &attrName)
120 {
121  return (attrName == SVGNames::requiredFeaturesAttr ||
122  attrName == SVGNames::requiredExtensionsAttr ||
123  attrName == SVGNames::systemLanguageAttr);
124 }
125 
126 }
127 
128 #endif // ENABLE(SVG)
bool hasFeature(const DOMString &feature, const DOMString &version)
Test if the DOM implementation implements a specific feature.
Definition: dom_doc.cpp:82
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.