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/SVGEllipseElement.h" | 23 #include "core/svg/SVGEllipseElement.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(SVGEllipseElement, SVGNames::cxAttr, Cx, cx) | |
34 DEFINE_ANIMATED_LENGTH(SVGEllipseElement, SVGNames::cyAttr, Cy, cy) | |
35 DEFINE_ANIMATED_LENGTH(SVGEllipseElement, SVGNames::rxAttr, Rx, rx) | |
36 DEFINE_ANIMATED_LENGTH(SVGEllipseElement, SVGNames::ryAttr, Ry, ry) | |
37 DEFINE_ANIMATED_BOOLEAN(SVGEllipseElement, SVGNames::externalResourcesRequiredAt
tr, ExternalResourcesRequired, externalResourcesRequired) | 33 DEFINE_ANIMATED_BOOLEAN(SVGEllipseElement, SVGNames::externalResourcesRequiredAt
tr, ExternalResourcesRequired, externalResourcesRequired) |
38 | 34 |
39 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGEllipseElement) | 35 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGEllipseElement) |
40 REGISTER_LOCAL_ANIMATED_PROPERTY(cx) | |
41 REGISTER_LOCAL_ANIMATED_PROPERTY(cy) | |
42 REGISTER_LOCAL_ANIMATED_PROPERTY(rx) | |
43 REGISTER_LOCAL_ANIMATED_PROPERTY(ry) | |
44 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) | 36 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) |
45 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) | 37 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) |
46 END_REGISTER_ANIMATED_PROPERTIES | 38 END_REGISTER_ANIMATED_PROPERTIES |
47 | 39 |
48 inline SVGEllipseElement::SVGEllipseElement(Document& document) | 40 inline SVGEllipseElement::SVGEllipseElement(Document& document) |
49 : SVGGeometryElement(SVGNames::ellipseTag, document) | 41 : SVGGeometryElement(SVGNames::ellipseTag, document) |
50 , m_cx(LengthModeWidth) | 42 , m_cx(SVGAnimatedLength::create(this, SVGNames::cxAttr, SVGLength::create(L
engthModeWidth))) |
51 , m_cy(LengthModeHeight) | 43 , m_cy(SVGAnimatedLength::create(this, SVGNames::cyAttr, SVGLength::create(L
engthModeHeight))) |
52 , m_rx(LengthModeWidth) | 44 , m_rx(SVGAnimatedLength::create(this, SVGNames::rxAttr, SVGLength::create(L
engthModeWidth))) |
53 , m_ry(LengthModeHeight) | 45 , m_ry(SVGAnimatedLength::create(this, SVGNames::ryAttr, SVGLength::create(L
engthModeHeight))) |
54 { | 46 { |
55 ScriptWrappable::init(this); | 47 ScriptWrappable::init(this); |
| 48 |
| 49 addToPropertyMap(m_cx); |
| 50 addToPropertyMap(m_cy); |
| 51 addToPropertyMap(m_rx); |
| 52 addToPropertyMap(m_ry); |
56 registerAnimatedPropertiesForSVGEllipseElement(); | 53 registerAnimatedPropertiesForSVGEllipseElement(); |
57 } | 54 } |
58 | 55 |
59 PassRefPtr<SVGEllipseElement> SVGEllipseElement::create(Document& document) | 56 PassRefPtr<SVGEllipseElement> SVGEllipseElement::create(Document& document) |
60 { | 57 { |
61 return adoptRef(new SVGEllipseElement(document)); | 58 return adoptRef(new SVGEllipseElement(document)); |
62 } | 59 } |
63 | 60 |
64 bool SVGEllipseElement::isSupportedAttribute(const QualifiedName& attrName) | 61 bool SVGEllipseElement::isSupportedAttribute(const QualifiedName& attrName) |
65 { | 62 { |
66 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | 63 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); |
67 if (supportedAttributes.isEmpty()) { | 64 if (supportedAttributes.isEmpty()) { |
68 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes
); | 65 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes
); |
69 supportedAttributes.add(SVGNames::cxAttr); | 66 supportedAttributes.add(SVGNames::cxAttr); |
70 supportedAttributes.add(SVGNames::cyAttr); | 67 supportedAttributes.add(SVGNames::cyAttr); |
71 supportedAttributes.add(SVGNames::rxAttr); | 68 supportedAttributes.add(SVGNames::rxAttr); |
72 supportedAttributes.add(SVGNames::ryAttr); | 69 supportedAttributes.add(SVGNames::ryAttr); |
73 } | 70 } |
74 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 71 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
75 } | 72 } |
76 | 73 |
77 void SVGEllipseElement::parseAttribute(const QualifiedName& name, const AtomicSt
ring& value) | 74 void SVGEllipseElement::parseAttribute(const QualifiedName& name, const AtomicSt
ring& value) |
78 { | 75 { |
79 SVGParsingError parseError = NoError; | 76 SVGParsingError parseError = NoError; |
80 | 77 |
81 if (!isSupportedAttribute(name)) | 78 if (!isSupportedAttribute(name)) |
82 SVGGeometryElement::parseAttribute(name, value); | 79 SVGGeometryElement::parseAttribute(name, value); |
83 else if (name == SVGNames::cxAttr) | 80 else if (name == SVGNames::cxAttr) |
84 setCxBaseValue(SVGLength::construct(LengthModeWidth, value, parseError))
; | 81 m_cx->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
85 else if (name == SVGNames::cyAttr) | 82 else if (name == SVGNames::cyAttr) |
86 setCyBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)
); | 83 m_cy->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
87 else if (name == SVGNames::rxAttr) | 84 else if (name == SVGNames::rxAttr) |
88 setRxBaseValue(SVGLength::construct(LengthModeWidth, value, parseError,
ForbidNegativeLengths)); | 85 m_rx->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
89 else if (name == SVGNames::ryAttr) | 86 else if (name == SVGNames::ryAttr) |
90 setRyBaseValue(SVGLength::construct(LengthModeHeight, value, parseError,
ForbidNegativeLengths)); | 87 m_ry->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
91 else if (SVGExternalResourcesRequired::parseAttribute(name, value)) { | 88 else if (SVGExternalResourcesRequired::parseAttribute(name, value)) { |
92 } else | 89 } else |
93 ASSERT_NOT_REACHED(); | 90 ASSERT_NOT_REACHED(); |
94 | 91 |
95 reportAttributeParsingError(parseError, name, value); | 92 reportAttributeParsingError(parseError, name, value); |
96 } | 93 } |
97 | 94 |
98 void SVGEllipseElement::svgAttributeChanged(const QualifiedName& attrName) | 95 void SVGEllipseElement::svgAttributeChanged(const QualifiedName& attrName) |
99 { | 96 { |
100 if (!isSupportedAttribute(attrName)) { | 97 if (!isSupportedAttribute(attrName)) { |
(...skipping 24 matching lines...) Expand all Loading... |
125 if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) { | 122 if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) { |
126 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); | 123 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); |
127 return; | 124 return; |
128 } | 125 } |
129 | 126 |
130 ASSERT_NOT_REACHED(); | 127 ASSERT_NOT_REACHED(); |
131 } | 128 } |
132 | 129 |
133 bool SVGEllipseElement::selfHasRelativeLengths() const | 130 bool SVGEllipseElement::selfHasRelativeLengths() const |
134 { | 131 { |
135 return cxCurrentValue().isRelative() | 132 return m_cx->currentValue()->isRelative() |
136 || cyCurrentValue().isRelative() | 133 || m_cy->currentValue()->isRelative() |
137 || rxCurrentValue().isRelative() | 134 || m_rx->currentValue()->isRelative() |
138 || ryCurrentValue().isRelative(); | 135 || m_ry->currentValue()->isRelative(); |
139 } | 136 } |
140 | 137 |
141 RenderObject* SVGEllipseElement::createRenderer(RenderStyle*) | 138 RenderObject* SVGEllipseElement::createRenderer(RenderStyle*) |
142 { | 139 { |
143 return new RenderSVGEllipse(this); | 140 return new RenderSVGEllipse(this); |
144 } | 141 } |
145 | 142 |
146 } | 143 } |
OLD | NEW |