File indexing completed on 2024-04-28 15:24:41

0001 /*
0002     Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
0003                   2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
0004 
0005     This file is part of the KDE project
0006 
0007     This library is free software; you can redistribute it and/or
0008     modify it under the terms of the GNU Library General Public
0009     License as published by the Free Software Foundation; either
0010     version 2 of the License, or (at your option) any later version.
0011 
0012     This library is distributed in the hope that it will be useful,
0013     but WITHOUT ANY WARRANTY; without even the implied warranty of
0014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015     Library General Public License for more details.
0016 
0017     You should have received a copy of the GNU Library General Public License
0018     along with this library; see the file COPYING.LIB.  If not, write to
0019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0020     Boston, MA 02110-1301, USA.
0021 */
0022 
0023 #include "wtf/Platform.h"
0024 
0025 #if ENABLE(SVG)
0026 #include "SVGTests.h"
0027 
0028 //#include "DOMImplementation.h"
0029 //#include "Language.h"
0030 #include "SVGElement.h"
0031 #include "SVGNames.h"
0032 #include "SVGStringList.h"
0033 
0034 namespace WebCore
0035 {
0036 
0037 SVGTests::SVGTests()
0038 {
0039 }
0040 
0041 SVGTests::~SVGTests()
0042 {
0043 }
0044 
0045 SVGStringList *SVGTests::requiredFeatures() const
0046 {
0047     if (!m_features) {
0048         m_features = SVGStringList::create(SVGNames::requiredFeaturesAttr);
0049     }
0050 
0051     return m_features.get();
0052 }
0053 
0054 SVGStringList *SVGTests::requiredExtensions() const
0055 {
0056     if (!m_extensions) {
0057         m_extensions = SVGStringList::create(SVGNames::requiredExtensionsAttr);
0058     }
0059 
0060     return m_extensions.get();
0061 }
0062 
0063 SVGStringList *SVGTests::systemLanguage() const
0064 {
0065     if (!m_systemLanguage) {
0066         m_systemLanguage = SVGStringList::create(SVGNames::systemLanguageAttr);
0067     }
0068 
0069     return m_systemLanguage.get();
0070 }
0071 
0072 bool SVGTests::hasExtension(const String &) const
0073 {
0074     return false;
0075 }
0076 
0077 bool SVGTests::isValid() const
0078 {
0079     ExceptionCode ec = 0;
0080 
0081     if (m_features) {
0082         for (unsigned long i = 0; i < m_features->numberOfItems(); i++) {
0083             String value = m_features->getItem(i, ec);
0084             if (value.isEmpty() || !DOMImplementation::hasFeature(value, String())) {
0085                 return false;
0086             }
0087         }
0088     }
0089 
0090     /*if (m_systemLanguage) {
0091         for (unsigned long i = 0; i < m_systemLanguage->numberOfItems(); i++)
0092             if (m_systemLanguage->getItem(i, ec) != defaultLanguage().substring(0, 2))
0093                 return false;
0094     }*/
0095 
0096     if (m_extensions && m_extensions->numberOfItems() > 0) {
0097         return false;
0098     }
0099 
0100     return true;
0101 }
0102 
0103 bool SVGTests::parseMappedAttribute(MappedAttribute *attr)
0104 {
0105     if (attr->name() == SVGNames::requiredFeaturesAttr) {
0106         requiredFeatures()->reset(attr->value());
0107         return true;
0108     } else if (attr->name() == SVGNames::requiredExtensionsAttr) {
0109         requiredExtensions()->reset(attr->value());
0110         return true;
0111     } else if (attr->name() == SVGNames::systemLanguageAttr) {
0112         systemLanguage()->reset(attr->value());
0113         return true;
0114     }
0115 
0116     return false;
0117 }
0118 
0119 bool SVGTests::isKnownAttribute(const QualifiedName &attrName)
0120 {
0121     return (attrName == SVGNames::requiredFeaturesAttr ||
0122             attrName == SVGNames::requiredExtensionsAttr ||
0123             attrName == SVGNames::systemLanguageAttr);
0124 }
0125 
0126 }
0127 
0128 #endif // ENABLE(SVG)