2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
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.
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.
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.
22 #include "core/svg/SVGTests.h"
24 #include "core/SVGNames.h"
25 #include "core/svg/SVGElement.h"
26 #include "platform/Language.h"
30 SVGTests::SVGTests(SVGElement
* contextElement
)
31 : m_requiredFeatures(SVGStaticStringList::create(contextElement
, SVGNames::requiredFeaturesAttr
))
32 , m_requiredExtensions(SVGStaticStringList::create(contextElement
, SVGNames::requiredExtensionsAttr
))
33 , m_systemLanguage(SVGStaticStringList::create(contextElement
, SVGNames::systemLanguageAttr
))
35 ASSERT(contextElement
);
37 contextElement
->addToPropertyMap(m_requiredFeatures
);
38 contextElement
->addToPropertyMap(m_requiredExtensions
);
39 contextElement
->addToPropertyMap(m_systemLanguage
);
42 DEFINE_TRACE(SVGTests
)
44 visitor
->trace(m_requiredFeatures
);
45 visitor
->trace(m_requiredExtensions
);
46 visitor
->trace(m_systemLanguage
);
49 bool SVGTests::hasExtension(const String
&)
51 // FIXME: Implement me!
55 bool SVGTests::isValid(Document
& document
) const
57 // No need to check requiredFeatures since hasFeature always returns true.
59 if (m_systemLanguage
->isSpecified()) {
60 bool matchFound
= false;
62 const Vector
<String
>& systemLanguage
= m_systemLanguage
->value()->values();
63 for (const auto& value
: systemLanguage
) {
64 if (value
== defaultLanguage().string().substring(0, 2)) {
74 if (!m_requiredExtensions
->value()->values().isEmpty())
80 bool SVGTests::parseAttribute(const QualifiedName
& name
, const AtomicString
& value
)
82 // FIXME: Should handle exceptions here.
83 // This is safe as of now, as the current impl of SVGStringList::setValueAsString never fails.
84 SVGParsingError parseError
= NoError
;
86 if (name
== SVGNames::requiredFeaturesAttr
)
87 m_requiredFeatures
->setBaseValueAsString(value
, parseError
);
88 else if (name
== SVGNames::requiredExtensionsAttr
)
89 m_requiredExtensions
->setBaseValueAsString(value
, parseError
);
90 else if (name
== SVGNames::systemLanguageAttr
)
91 m_systemLanguage
->setBaseValueAsString(value
, parseError
);
95 ASSERT(parseError
== NoError
);
100 bool SVGTests::isKnownAttribute(const QualifiedName
& attrName
)
102 return attrName
== SVGNames::requiredFeaturesAttr
103 || attrName
== SVGNames::requiredExtensionsAttr
104 || attrName
== SVGNames::systemLanguageAttr
;
107 void SVGTests::addSupportedAttributes(HashSet
<QualifiedName
>& supportedAttributes
)
109 supportedAttributes
.add(SVGNames::requiredFeaturesAttr
);
110 supportedAttributes
.add(SVGNames::requiredExtensionsAttr
);
111 supportedAttributes
.add(SVGNames::systemLanguageAttr
);