|
1 /* |
|
2 Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
|
3 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 "SVGTests.h" |
|
25 |
|
26 #include "Attribute.h" |
|
27 #include "DOMImplementation.h" |
|
28 #include "Language.h" |
|
29 #include "SVGElement.h" |
|
30 #include "SVGNames.h" |
|
31 #include "SVGStringList.h" |
|
32 |
|
33 namespace WebCore { |
|
34 |
|
35 SVGTests::SVGTests() |
|
36 { |
|
37 } |
|
38 |
|
39 SVGTests::~SVGTests() |
|
40 { |
|
41 } |
|
42 |
|
43 SVGStringList* SVGTests::requiredFeatures() const |
|
44 { |
|
45 if (!m_features) |
|
46 m_features = SVGStringList::create(SVGNames::requiredFeaturesAttr); |
|
47 |
|
48 return m_features.get(); |
|
49 } |
|
50 |
|
51 SVGStringList* SVGTests::requiredExtensions() const |
|
52 { |
|
53 if (!m_extensions) |
|
54 m_extensions = SVGStringList::create(SVGNames::requiredExtensionsAttr); |
|
55 |
|
56 return m_extensions.get(); |
|
57 } |
|
58 |
|
59 SVGStringList* SVGTests::systemLanguage() const |
|
60 { |
|
61 if (!m_systemLanguage) |
|
62 m_systemLanguage = SVGStringList::create(SVGNames::systemLanguageAttr); |
|
63 |
|
64 return m_systemLanguage.get(); |
|
65 } |
|
66 |
|
67 bool SVGTests::hasExtension(const String&) const |
|
68 { |
|
69 return false; |
|
70 } |
|
71 |
|
72 bool SVGTests::isValid() const |
|
73 { |
|
74 ExceptionCode ec = 0; |
|
75 |
|
76 if (m_features) { |
|
77 for (unsigned long i = 0; i < m_features->numberOfItems(); i++) { |
|
78 String value = m_features->getItem(i, ec); |
|
79 if (value.isEmpty() || !DOMImplementation::hasFeature(value, String())) |
|
80 return false; |
|
81 } |
|
82 } |
|
83 |
|
84 if (m_systemLanguage) { |
|
85 for (unsigned long i = 0; i < m_systemLanguage->numberOfItems(); i++) |
|
86 if (m_systemLanguage->getItem(i, ec) != defaultLanguage().substring(0, 2)) |
|
87 return false; |
|
88 } |
|
89 |
|
90 if (m_extensions && m_extensions->numberOfItems() > 0) |
|
91 return false; |
|
92 |
|
93 return true; |
|
94 } |
|
95 |
|
96 bool SVGTests::parseMappedAttribute(Attribute* attr) |
|
97 { |
|
98 if (attr->name() == SVGNames::requiredFeaturesAttr) { |
|
99 requiredFeatures()->reset(attr->value()); |
|
100 return true; |
|
101 } else if (attr->name() == SVGNames::requiredExtensionsAttr) { |
|
102 requiredExtensions()->reset(attr->value()); |
|
103 return true; |
|
104 } else if (attr->name() == SVGNames::systemLanguageAttr) { |
|
105 systemLanguage()->reset(attr->value()); |
|
106 return true; |
|
107 } |
|
108 |
|
109 return false; |
|
110 } |
|
111 |
|
112 bool SVGTests::isKnownAttribute(const QualifiedName& attrName) |
|
113 { |
|
114 return (attrName == SVGNames::requiredFeaturesAttr || |
|
115 attrName == SVGNames::requiredExtensionsAttr || |
|
116 attrName == SVGNames::systemLanguageAttr); |
|
117 } |
|
118 |
|
119 } |
|
120 |
|
121 #endif // ENABLE(SVG) |