SVGLangSpace.cpp revision cad810f21b803229eb11403f9209855525a25d57
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
23#if ENABLE(SVG)
24#include "SVGLangSpace.h"
25
26#include "Attribute.h"
27#include "SVGElement.h"
28#include "XMLNames.h"
29#include <wtf/StdLibExtras.h>
30
31namespace WebCore {
32
33void SVGLangSpace::setXmllang(const AtomicString& xmlLang)
34{
35    m_lang = xmlLang;
36}
37
38const AtomicString& SVGLangSpace::xmlspace() const
39{
40    if (!m_space) {
41        DEFINE_STATIC_LOCAL(const AtomicString, defaultString, ("default"));
42        return defaultString;
43    }
44
45    return m_space;
46}
47
48void SVGLangSpace::setXmlspace(const AtomicString& xmlSpace)
49{
50    m_space = xmlSpace;
51}
52
53bool SVGLangSpace::parseMappedAttribute(Attribute* attr)
54{
55    if (attr->name().matches(XMLNames::langAttr)) {
56        setXmllang(attr->value());
57        return true;
58    }
59    if (attr->name().matches(XMLNames::spaceAttr)) {
60        setXmlspace(attr->value());
61        return true;
62    }
63
64    return false;
65}
66
67bool SVGLangSpace::isKnownAttribute(const QualifiedName& attrName)
68{
69    return attrName.matches(XMLNames::langAttr) || attrName.matches(XMLNames::spaceAttr);
70}
71
72}
73
74#endif // ENABLE(SVG)
75