2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006 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.
23 #include "core/svg/SVGSymbolElement.h"
26 #include "core/rendering/svg/RenderSVGHiddenContainer.h"
27 #include "core/svg/SVGElementInstance.h"
31 inline SVGSymbolElement::SVGSymbolElement(Document& document)
32 : SVGElement(SVGNames::symbolTag, document)
33 , SVGFitToViewBox(this)
35 ScriptWrappable::init(this);
38 PassRefPtr<SVGSymbolElement> SVGSymbolElement::create(Document& document)
40 return adoptRef(new SVGSymbolElement(document));
43 bool SVGSymbolElement::isSupportedAttribute(const QualifiedName& attrName)
45 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
46 if (supportedAttributes.isEmpty())
47 SVGFitToViewBox::addSupportedAttributes(supportedAttributes);
49 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
52 void SVGSymbolElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
54 if (!isSupportedAttribute(name)) {
55 SVGElement::parseAttribute(name, value);
59 SVGParsingError parseError = NoError;
60 if (SVGFitToViewBox::parseAttribute(name, value, document(), parseError)) {
65 reportAttributeParsingError(parseError, name, value);
68 void SVGSymbolElement::svgAttributeChanged(const QualifiedName& attrName)
70 if (!isSupportedAttribute(attrName)) {
71 SVGElement::svgAttributeChanged(attrName);
75 SVGElement::InvalidationGuard invalidationGuard(this);
77 // Every other property change is ignored.
78 if (attrName == SVGNames::viewBoxAttr)
79 updateRelativeLengthsInformation();
82 bool SVGSymbolElement::selfHasRelativeLengths() const
84 return hasAttribute(SVGNames::viewBoxAttr);
87 RenderObject* SVGSymbolElement::createRenderer(RenderStyle*)
89 return new RenderSVGHiddenContainer(this);