• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2004, 2005 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 "SVGSymbolElement.h"
25 
26 #include "SVGFitToViewBox.h"
27 #include "SVGNames.h"
28 
29 namespace WebCore {
30 
31 // Animated property definitions
DEFINE_ANIMATED_BOOLEAN(SVGSymbolElement,SVGNames::externalResourcesRequiredAttr,ExternalResourcesRequired,externalResourcesRequired)32 DEFINE_ANIMATED_BOOLEAN(SVGSymbolElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired)
33 DEFINE_ANIMATED_PRESERVEASPECTRATIO(SVGSymbolElement, SVGNames::preserveAspectRatioAttr, PreserveAspectRatio, preserveAspectRatio)
34 DEFINE_ANIMATED_RECT(SVGSymbolElement, SVGNames::viewBoxAttr, ViewBox, viewBox)
35 
36 inline SVGSymbolElement::SVGSymbolElement(const QualifiedName& tagName, Document* document)
37     : SVGStyledElement(tagName, document)
38 {
39 }
40 
create(const QualifiedName & tagName,Document * document)41 PassRefPtr<SVGSymbolElement> SVGSymbolElement::create(const QualifiedName& tagName, Document* document)
42 {
43     return adoptRef(new SVGSymbolElement(tagName, document));
44 }
45 
parseMappedAttribute(Attribute * attr)46 void SVGSymbolElement::parseMappedAttribute(Attribute* attr)
47 {
48     if (SVGLangSpace::parseMappedAttribute(attr))
49         return;
50     if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
51         return;
52     if (SVGFitToViewBox::parseMappedAttribute(document(), attr))
53         return;
54 
55     SVGStyledElement::parseMappedAttribute(attr);
56 }
57 
svgAttributeChanged(const QualifiedName & attrName)58 void SVGSymbolElement::svgAttributeChanged(const QualifiedName& attrName)
59 {
60     SVGStyledElement::svgAttributeChanged(attrName);
61 
62     if (attrName == SVGNames::viewBoxAttr)
63         updateRelativeLengthsInformation();
64 }
65 
synchronizeProperty(const QualifiedName & attrName)66 void SVGSymbolElement::synchronizeProperty(const QualifiedName& attrName)
67 {
68     SVGStyledElement::synchronizeProperty(attrName);
69 
70     if (attrName == anyQName()) {
71         synchronizePreserveAspectRatio();
72         synchronizeViewBox();
73         synchronizeExternalResourcesRequired();
74         synchronizeViewBox();
75         synchronizePreserveAspectRatio();
76         return;
77     }
78 
79     if (attrName == SVGNames::preserveAspectRatioAttr)
80         synchronizePreserveAspectRatio();
81     else if (attrName == SVGNames::viewBoxAttr)
82         synchronizeViewBox();
83     else if (SVGExternalResourcesRequired::isKnownAttribute(attrName))
84         synchronizeExternalResourcesRequired();
85     else if (SVGFitToViewBox::isKnownAttribute(attrName)) {
86         synchronizeViewBox();
87         synchronizePreserveAspectRatio();
88     }
89 }
90 
attributeToPropertyTypeMap()91 AttributeToPropertyTypeMap& SVGSymbolElement::attributeToPropertyTypeMap()
92 {
93     DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ());
94     return s_attributeToPropertyTypeMap;
95 }
96 
fillAttributeToPropertyTypeMap()97 void SVGSymbolElement::fillAttributeToPropertyTypeMap()
98 {
99     AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap();
100 
101     SVGStyledElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap);
102     attributeToPropertyTypeMap.set(SVGNames::viewBoxAttr, AnimatedRect);
103     attributeToPropertyTypeMap.set(SVGNames::preserveAspectRatioAttr, AnimatedPreserveAspectRatio);
104 }
105 
selfHasRelativeLengths() const106 bool SVGSymbolElement::selfHasRelativeLengths() const
107 {
108     return hasAttribute(SVGNames::viewBoxAttr);
109 }
110 
111 }
112 
113 #endif // ENABLE(SVG)
114