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 | |
37 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGCircleElement) | 33 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGCircleElement) |
38 REGISTER_LOCAL_ANIMATED_PROPERTY(cx) | |
39 REGISTER_LOCAL_ANIMATED_PROPERTY(cy) | |
40 REGISTER_LOCAL_ANIMATED_PROPERTY(r) | |
41 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) | 34 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) |
42 END_REGISTER_ANIMATED_PROPERTIES | 35 END_REGISTER_ANIMATED_PROPERTIES |
43 | 36 |
44 inline SVGCircleElement::SVGCircleElement(Document& document) | 37 inline SVGCircleElement::SVGCircleElement(Document& document) |
45 : SVGGeometryElement(SVGNames::circleTag, document) | 38 : SVGGeometryElement(SVGNames::circleTag, document) |
46 , m_cx(LengthModeWidth) | 39 , m_cx(SVGAnimatedLength::create(this, SVGNames::cxAttr, SVGLength::create(L
engthModeWidth))) |
47 , m_cy(LengthModeHeight) | 40 , m_cy(SVGAnimatedLength::create(this, SVGNames::cyAttr, SVGLength::create(L
engthModeHeight))) |
48 , m_r(LengthModeOther) | 41 , m_r(SVGAnimatedLength::create(this, SVGNames::rAttr, SVGLength::create(Len
gthModeOther))) |
49 { | 42 { |
50 ScriptWrappable::init(this); | 43 ScriptWrappable::init(this); |
| 44 |
| 45 addToPropertyMap(m_cx); |
| 46 addToPropertyMap(m_cy); |
| 47 addToPropertyMap(m_r); |
51 registerAnimatedPropertiesForSVGCircleElement(); | 48 registerAnimatedPropertiesForSVGCircleElement(); |
52 } | 49 } |
53 | 50 |
54 PassRefPtr<SVGCircleElement> SVGCircleElement::create(Document& document) | 51 PassRefPtr<SVGCircleElement> SVGCircleElement::create(Document& document) |
55 { | 52 { |
56 return adoptRef(new SVGCircleElement(document)); | 53 return adoptRef(new SVGCircleElement(document)); |
57 } | 54 } |
58 | 55 |
59 bool SVGCircleElement::isSupportedAttribute(const QualifiedName& attrName) | 56 bool SVGCircleElement::isSupportedAttribute(const QualifiedName& attrName) |
60 { | 57 { |
61 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | 58 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); |
62 if (supportedAttributes.isEmpty()) { | 59 if (supportedAttributes.isEmpty()) { |
63 supportedAttributes.add(SVGNames::cxAttr); | 60 supportedAttributes.add(SVGNames::cxAttr); |
64 supportedAttributes.add(SVGNames::cyAttr); | 61 supportedAttributes.add(SVGNames::cyAttr); |
65 supportedAttributes.add(SVGNames::rAttr); | 62 supportedAttributes.add(SVGNames::rAttr); |
66 } | 63 } |
67 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 64 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
68 } | 65 } |
69 | 66 |
70 void SVGCircleElement::parseAttribute(const QualifiedName& name, const AtomicStr
ing& value) | 67 void SVGCircleElement::parseAttribute(const QualifiedName& name, const AtomicStr
ing& value) |
71 { | 68 { |
72 SVGParsingError parseError = NoError; | 69 SVGParsingError parseError = NoError; |
73 | 70 |
74 if (!isSupportedAttribute(name)) | 71 if (!isSupportedAttribute(name)) |
75 SVGGeometryElement::parseAttribute(name, value); | 72 SVGGeometryElement::parseAttribute(name, value); |
76 else if (name == SVGNames::cxAttr) | 73 else if (name == SVGNames::cxAttr) |
77 setCxBaseValue(SVGLength::construct(LengthModeWidth, value, parseError))
; | 74 m_cx->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
78 else if (name == SVGNames::cyAttr) | 75 else if (name == SVGNames::cyAttr) |
79 setCyBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)
); | 76 m_cy->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
80 else if (name == SVGNames::rAttr) | 77 else if (name == SVGNames::rAttr) |
81 setRBaseValue(SVGLength::construct(LengthModeOther, value, parseError, F
orbidNegativeLengths)); | 78 m_r->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
82 else | 79 else |
83 ASSERT_NOT_REACHED(); | 80 ASSERT_NOT_REACHED(); |
84 | 81 |
85 reportAttributeParsingError(parseError, name, value); | 82 reportAttributeParsingError(parseError, name, value); |
86 } | 83 } |
87 | 84 |
88 void SVGCircleElement::svgAttributeChanged(const QualifiedName& attrName) | 85 void SVGCircleElement::svgAttributeChanged(const QualifiedName& attrName) |
89 { | 86 { |
90 if (!isSupportedAttribute(attrName)) { | 87 if (!isSupportedAttribute(attrName)) { |
91 SVGGeometryElement::svgAttributeChanged(attrName); | 88 SVGGeometryElement::svgAttributeChanged(attrName); |
(...skipping 17 matching lines...) Expand all Loading... |
109 renderer->setNeedsShapeUpdate(); | 106 renderer->setNeedsShapeUpdate(); |
110 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); | 107 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); |
111 return; | 108 return; |
112 } | 109 } |
113 | 110 |
114 ASSERT_NOT_REACHED(); | 111 ASSERT_NOT_REACHED(); |
115 } | 112 } |
116 | 113 |
117 bool SVGCircleElement::selfHasRelativeLengths() const | 114 bool SVGCircleElement::selfHasRelativeLengths() const |
118 { | 115 { |
119 return cxCurrentValue().isRelative() | 116 return m_cx->currentValue()->isRelative() |
120 || cyCurrentValue().isRelative() | 117 || m_cy->currentValue()->isRelative() |
121 || rCurrentValue().isRelative(); | 118 || m_r->currentValue()->isRelative(); |
122 } | 119 } |
123 | 120 |
124 RenderObject* SVGCircleElement::createRenderer(RenderStyle*) | 121 RenderObject* SVGCircleElement::createRenderer(RenderStyle*) |
125 { | 122 { |
126 return new RenderSVGEllipse(this); | 123 return new RenderSVGEllipse(this); |
127 } | 124 } |
128 | 125 |
129 } | 126 } |
OLD | NEW |