1 /* 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann (at) kde.org> 3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis (at) 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 #include "core/svg/SVGViewElement.h" 24 25 26 namespace WebCore { 27 28 // Animated property definitions 29 DEFINE_ANIMATED_BOOLEAN(SVGViewElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired) 30 DEFINE_ANIMATED_RECT(SVGViewElement, SVGNames::viewBoxAttr, ViewBox, viewBox) 31 DEFINE_ANIMATED_PRESERVEASPECTRATIO(SVGViewElement, SVGNames::preserveAspectRatioAttr, PreserveAspectRatio, preserveAspectRatio) 32 33 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGViewElement) 34 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) 35 REGISTER_LOCAL_ANIMATED_PROPERTY(viewBox) 36 REGISTER_LOCAL_ANIMATED_PROPERTY(preserveAspectRatio) 37 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) 38 END_REGISTER_ANIMATED_PROPERTIES 39 40 inline SVGViewElement::SVGViewElement(Document& document) 41 : SVGElement(SVGNames::viewTag, document) 42 , m_zoomAndPan(SVGZoomAndPanMagnify) 43 , m_viewTarget(SVGNames::viewTargetAttr) 44 { 45 ScriptWrappable::init(this); 46 registerAnimatedPropertiesForSVGViewElement(); 47 } 48 49 PassRefPtr<SVGViewElement> SVGViewElement::create(Document& document) 50 { 51 return adoptRef(new SVGViewElement(document)); 52 } 53 54 bool SVGViewElement::isSupportedAttribute(const QualifiedName& attrName) 55 { 56 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); 57 if (supportedAttributes.isEmpty()) { 58 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes); 59 SVGFitToViewBox::addSupportedAttributes(supportedAttributes); 60 SVGZoomAndPan::addSupportedAttributes(supportedAttributes); 61 supportedAttributes.add(SVGNames::viewTargetAttr); 62 } 63 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); 64 } 65 66 void SVGViewElement::parseAttribute(const QualifiedName& name, const AtomicString& value) 67 { 68 if (!isSupportedAttribute(name)) { 69 SVGElement::parseAttribute(name, value); 70 return; 71 } 72 73 if (name == SVGNames::viewTargetAttr) { 74 viewTarget().reset(value); 75 return; 76 } 77 78 if (SVGExternalResourcesRequired::parseAttribute(name, value)) 79 return; 80 if (SVGFitToViewBox::parseAttribute(this, name, value)) 81 return; 82 if (SVGZoomAndPan::parseAttribute(this, name, value)) 83 return; 84 85 ASSERT_NOT_REACHED(); 86 } 87 88 } 89