2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 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.
24 #include "SVGViewElement.h"
26 #include "Attribute.h"
27 #include "SVGFitToViewBox.h"
29 #include "SVGStringList.h"
30 #include "SVGZoomAndPan.h"
34 // Animated property definitions
35 DEFINE_ANIMATED_BOOLEAN(SVGViewElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired)
36 DEFINE_ANIMATED_RECT(SVGViewElement, SVGNames::viewBoxAttr, ViewBox, viewBox)
37 DEFINE_ANIMATED_PRESERVEASPECTRATIO(SVGViewElement, SVGNames::preserveAspectRatioAttr, PreserveAspectRatio, preserveAspectRatio)
39 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGViewElement)
40 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired)
41 REGISTER_LOCAL_ANIMATED_PROPERTY(viewBox)
42 REGISTER_LOCAL_ANIMATED_PROPERTY(preserveAspectRatio)
43 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGStyledElement)
44 END_REGISTER_ANIMATED_PROPERTIES
46 inline SVGViewElement::SVGViewElement(const QualifiedName& tagName, Document* document)
47 : SVGStyledElement(tagName, document)
48 , m_viewTarget(SVGNames::viewTargetAttr)
50 ASSERT(hasTagName(SVGNames::viewTag));
51 registerAnimatedPropertiesForSVGViewElement();
54 PassRefPtr<SVGViewElement> SVGViewElement::create(const QualifiedName& tagName, Document* document)
56 return adoptRef(new SVGViewElement(tagName, document));
59 bool SVGViewElement::isSupportedAttribute(const QualifiedName& attrName)
61 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
62 if (supportedAttributes.isEmpty()) {
63 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes);
64 SVGFitToViewBox::addSupportedAttributes(supportedAttributes);
65 SVGZoomAndPan::addSupportedAttributes(supportedAttributes);
66 supportedAttributes.add(SVGNames::viewTargetAttr);
68 return supportedAttributes.contains(attrName);
71 void SVGViewElement::parseMappedAttribute(Attribute* attr)
73 if (!isSupportedAttribute(attr->name())) {
74 SVGStyledElement::parseMappedAttribute(attr);
78 if (attr->name() == SVGNames::viewTargetAttr) {
79 viewTarget().reset(attr->value());
83 if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
85 if (SVGFitToViewBox::parseMappedAttribute(document(), attr))
87 if (SVGZoomAndPan::parseMappedAttribute(attr))