1/* 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2004, 2005, 2006 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#include "SVGLangSpace.h" 23 24#include "Attribute.h" 25#include "SVGElement.h" 26#include "XMLNames.h" 27#include <wtf/StdLibExtras.h> 28 29namespace WebCore { 30 31void SVGLangSpace::setXmllang(const AtomicString& xmlLang) 32{ 33 m_lang = xmlLang; 34} 35 36const AtomicString& SVGLangSpace::xmlspace() const 37{ 38 if (!m_space) { 39 DEPRECATED_DEFINE_STATIC_LOCAL(const AtomicString, defaultString, ("default", AtomicString::ConstructFromLiteral)); 40 return defaultString; 41 } 42 43 return m_space; 44} 45 46void SVGLangSpace::setXmlspace(const AtomicString& xmlSpace) 47{ 48 m_space = xmlSpace; 49} 50 51bool SVGLangSpace::parseAttribute(const QualifiedName& name, const AtomicString& value) 52{ 53 if (name.matches(XMLNames::langAttr)) { 54 setXmllang(value); 55 return true; 56 } 57 if (name.matches(XMLNames::spaceAttr)) { 58 setXmlspace(value); 59 return true; 60 } 61 62 return false; 63} 64 65bool SVGLangSpace::isKnownAttribute(const QualifiedName& attrName) 66{ 67 return attrName.matches(XMLNames::langAttr) || attrName.matches(XMLNames::spaceAttr); 68} 69 70void SVGLangSpace::addSupportedAttributes(HashSet<QualifiedName>& supportedAttributes) 71{ 72 DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, xmlPrefix, ("xml", AtomicString::ConstructFromLiteral)); 73 74 QualifiedName langWithPrefix = XMLNames::langAttr; 75 langWithPrefix.setPrefix(xmlPrefix); 76 supportedAttributes.add(langWithPrefix); 77 supportedAttributes.add(XMLNames::langAttr); 78 79 QualifiedName spaceWithPrefix = XMLNames::spaceAttr; 80 spaceWithPrefix.setPrefix(xmlPrefix); 81 supportedAttributes.add(spaceWithPrefix); 82 supportedAttributes.add(XMLNames::spaceAttr); 83} 84 85} 86