OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "core/svg/SVGCircleElement.h" | 23 #include "core/svg/SVGCircleElement.h" |
24 | 24 |
25 #include "core/rendering/svg/RenderSVGEllipse.h" | 25 #include "core/rendering/svg/RenderSVGEllipse.h" |
26 #include "core/rendering/svg/RenderSVGResource.h" | 26 #include "core/rendering/svg/RenderSVGResource.h" |
27 #include "core/svg/SVGElementInstance.h" | 27 #include "core/svg/SVGElementInstance.h" |
28 #include "core/svg/SVGLength.h" | 28 #include "core/svg/SVGLength.h" |
29 | 29 |
30 namespace WebCore { | 30 namespace WebCore { |
31 | 31 |
32 // Animated property definitions | 32 // Animated property definitions |
33 DEFINE_ANIMATED_LENGTH(SVGCircleElement, SVGNames::cxAttr, Cx, cx) | |
34 DEFINE_ANIMATED_LENGTH(SVGCircleElement, SVGNames::cyAttr, Cy, cy) | |
35 DEFINE_ANIMATED_LENGTH(SVGCircleElement, SVGNames::rAttr, R, r) | |
36 DEFINE_ANIMATED_BOOLEAN(SVGCircleElement, SVGNames::externalResourcesRequiredAtt
r, ExternalResourcesRequired, externalResourcesRequired) | 33 DEFINE_ANIMATED_BOOLEAN(SVGCircleElement, SVGNames::externalResourcesRequiredAtt
r, ExternalResourcesRequired, externalResourcesRequired) |
37 | 34 |
38 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGCircleElement) | 35 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGCircleElement) |
39 REGISTER_LOCAL_ANIMATED_PROPERTY(cx) | |
40 REGISTER_LOCAL_ANIMATED_PROPERTY(cy) | |
41 REGISTER_LOCAL_ANIMATED_PROPERTY(r) | |
42 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) | 36 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) |
43 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) | 37 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) |
44 END_REGISTER_ANIMATED_PROPERTIES | 38 END_REGISTER_ANIMATED_PROPERTIES |
45 | 39 |
46 inline SVGCircleElement::SVGCircleElement(Document& document) | 40 inline SVGCircleElement::SVGCircleElement(Document& document) |
47 : SVGGeometryElement(SVGNames::circleTag, document) | 41 : SVGGeometryElement(SVGNames::circleTag, document) |
48 , m_cx(LengthModeWidth) | 42 , m_cx(SVGAnimatedLength::create(this, SVGNames::cxAttr, SVGLength::create(L
engthModeWidth))) |
49 , m_cy(LengthModeHeight) | 43 , m_cy(SVGAnimatedLength::create(this, SVGNames::cyAttr, SVGLength::create(L
engthModeHeight))) |
50 , m_r(LengthModeOther) | 44 , m_r(SVGAnimatedLength::create(this, SVGNames::rAttr, SVGLength::create(Len
gthModeOther))) |
51 { | 45 { |
52 ScriptWrappable::init(this); | 46 ScriptWrappable::init(this); |
| 47 |
| 48 addToPropertyMap(m_cx); |
| 49 addToPropertyMap(m_cy); |
| 50 addToPropertyMap(m_r); |
53 registerAnimatedPropertiesForSVGCircleElement(); | 51 registerAnimatedPropertiesForSVGCircleElement(); |
54 } | 52 } |
55 | 53 |
56 PassRefPtr<SVGCircleElement> SVGCircleElement::create(Document& document) | 54 PassRefPtr<SVGCircleElement> SVGCircleElement::create(Document& document) |
57 { | 55 { |
58 return adoptRef(new SVGCircleElement(document)); | 56 return adoptRef(new SVGCircleElement(document)); |
59 } | 57 } |
60 | 58 |
61 bool SVGCircleElement::isSupportedAttribute(const QualifiedName& attrName) | 59 bool SVGCircleElement::isSupportedAttribute(const QualifiedName& attrName) |
62 { | 60 { |
63 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | 61 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); |
64 if (supportedAttributes.isEmpty()) { | 62 if (supportedAttributes.isEmpty()) { |
65 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes
); | 63 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes
); |
66 supportedAttributes.add(SVGNames::cxAttr); | 64 supportedAttributes.add(SVGNames::cxAttr); |
67 supportedAttributes.add(SVGNames::cyAttr); | 65 supportedAttributes.add(SVGNames::cyAttr); |
68 supportedAttributes.add(SVGNames::rAttr); | 66 supportedAttributes.add(SVGNames::rAttr); |
69 } | 67 } |
70 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 68 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
71 } | 69 } |
72 | 70 |
73 void SVGCircleElement::parseAttribute(const QualifiedName& name, const AtomicStr
ing& value) | 71 void SVGCircleElement::parseAttribute(const QualifiedName& name, const AtomicStr
ing& value) |
74 { | 72 { |
75 SVGParsingError parseError = NoError; | 73 SVGParsingError parseError = NoError; |
76 | 74 |
77 if (!isSupportedAttribute(name)) | 75 if (!isSupportedAttribute(name)) |
78 SVGGeometryElement::parseAttribute(name, value); | 76 SVGGeometryElement::parseAttribute(name, value); |
79 else if (name == SVGNames::cxAttr) | 77 else if (name == SVGNames::cxAttr) |
80 setCxBaseValue(SVGLength::construct(LengthModeWidth, value, parseError))
; | 78 m_cx->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
81 else if (name == SVGNames::cyAttr) | 79 else if (name == SVGNames::cyAttr) |
82 setCyBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)
); | 80 m_cy->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
83 else if (name == SVGNames::rAttr) | 81 else if (name == SVGNames::rAttr) |
84 setRBaseValue(SVGLength::construct(LengthModeOther, value, parseError, F
orbidNegativeLengths)); | 82 m_r->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
85 else if (SVGExternalResourcesRequired::parseAttribute(name, value)) { | 83 else if (SVGExternalResourcesRequired::parseAttribute(name, value)) { |
86 } else | 84 } else |
87 ASSERT_NOT_REACHED(); | 85 ASSERT_NOT_REACHED(); |
88 | 86 |
89 reportAttributeParsingError(parseError, name, value); | 87 reportAttributeParsingError(parseError, name, value); |
90 } | 88 } |
91 | 89 |
92 void SVGCircleElement::svgAttributeChanged(const QualifiedName& attrName) | 90 void SVGCircleElement::svgAttributeChanged(const QualifiedName& attrName) |
93 { | 91 { |
94 if (!isSupportedAttribute(attrName)) { | 92 if (!isSupportedAttribute(attrName)) { |
(...skipping 23 matching lines...) Expand all Loading... |
118 if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) { | 116 if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) { |
119 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); | 117 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); |
120 return; | 118 return; |
121 } | 119 } |
122 | 120 |
123 ASSERT_NOT_REACHED(); | 121 ASSERT_NOT_REACHED(); |
124 } | 122 } |
125 | 123 |
126 bool SVGCircleElement::selfHasRelativeLengths() const | 124 bool SVGCircleElement::selfHasRelativeLengths() const |
127 { | 125 { |
128 return cxCurrentValue().isRelative() | 126 return m_cx->currentValue()->isRelative() |
129 || cyCurrentValue().isRelative() | 127 || m_cy->currentValue()->isRelative() |
130 || rCurrentValue().isRelative(); | 128 || m_r->currentValue()->isRelative(); |
131 } | 129 } |
132 | 130 |
133 RenderObject* SVGCircleElement::createRenderer(RenderStyle*) | 131 RenderObject* SVGCircleElement::createRenderer(RenderStyle*) |
134 { | 132 { |
135 return new RenderSVGEllipse(this); | 133 return new RenderSVGEllipse(this); |
136 } | 134 } |
137 | 135 |
138 } | 136 } |
OLD | NEW |