1 /* 2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann (at) kde.org> 3 * Copyright (C) 2004, 2005, 2006 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 #if ENABLE(SVG) 24 #include "SVGSwitchElement.h" 25 26 #include "RenderSVGTransformableContainer.h" 27 #include "SVGNames.h" 28 29 namespace WebCore { 30 31 // Animated property definitions 32 DEFINE_ANIMATED_BOOLEAN(SVGSwitchElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired) 33 34 inline SVGSwitchElement::SVGSwitchElement(const QualifiedName& tagName, Document* document) 35 : SVGStyledTransformableElement(tagName, document) 36 { 37 } 38 39 PassRefPtr<SVGSwitchElement> SVGSwitchElement::create(const QualifiedName& tagName, Document* document) 40 { 41 return adoptRef(new SVGSwitchElement(tagName, document)); 42 } 43 44 bool SVGSwitchElement::childShouldCreateRenderer(Node* child) const 45 { 46 // FIXME: This function does not do what the comment below implies it does. 47 // It will create a renderer for any valid SVG element children, not just the first one. 48 for (Node* node = firstChild(); node; node = node->nextSibling()) { 49 if (!node->isSVGElement()) 50 continue; 51 52 SVGElement* element = static_cast<SVGElement*>(node); 53 if (!element || !element->isValid()) 54 continue; 55 56 return node == child; // Only allow this child if it's the first valid child 57 } 58 59 return false; 60 } 61 62 RenderObject* SVGSwitchElement::createRenderer(RenderArena* arena, RenderStyle*) 63 { 64 return new (arena) RenderSVGTransformableContainer(this); 65 } 66 67 void SVGSwitchElement::synchronizeProperty(const QualifiedName& attrName) 68 { 69 SVGStyledTransformableElement::synchronizeProperty(attrName); 70 71 if (attrName == anyQName()) { 72 synchronizeExternalResourcesRequired(); 73 SVGTests::synchronizeProperties(this, attrName); 74 return; 75 } 76 77 if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) 78 synchronizeExternalResourcesRequired(); 79 else if (SVGTests::isKnownAttribute(attrName)) 80 SVGTests::synchronizeProperties(this, attrName); 81 } 82 83 AttributeToPropertyTypeMap& SVGSwitchElement::attributeToPropertyTypeMap() 84 { 85 DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ()); 86 return s_attributeToPropertyTypeMap; 87 } 88 89 void SVGSwitchElement::fillAttributeToPropertyTypeMap() 90 { 91 SVGStyledTransformableElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap()); 92 } 93 94 } 95 96 #endif // ENABLE(SVG) 97