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/SVGRectElement.h" | 23 #include "core/svg/SVGRectElement.h" |
24 | 24 |
25 #include "core/rendering/svg/RenderSVGRect.h" | 25 #include "core/rendering/svg/RenderSVGRect.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(SVGRectElement, SVGNames::xAttr, X, x) | |
34 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::yAttr, Y, y) | |
35 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::widthAttr, Width, width) | |
36 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::heightAttr, Height, height) | |
37 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::rxAttr, Rx, rx) | |
38 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::ryAttr, Ry, ry) | |
39 DEFINE_ANIMATED_BOOLEAN(SVGRectElement, SVGNames::externalResourcesRequiredAttr,
ExternalResourcesRequired, externalResourcesRequired) | 33 DEFINE_ANIMATED_BOOLEAN(SVGRectElement, SVGNames::externalResourcesRequiredAttr,
ExternalResourcesRequired, externalResourcesRequired) |
40 | 34 |
41 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGRectElement) | 35 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGRectElement) |
42 REGISTER_LOCAL_ANIMATED_PROPERTY(x) | |
43 REGISTER_LOCAL_ANIMATED_PROPERTY(y) | |
44 REGISTER_LOCAL_ANIMATED_PROPERTY(width) | |
45 REGISTER_LOCAL_ANIMATED_PROPERTY(height) | |
46 REGISTER_LOCAL_ANIMATED_PROPERTY(rx) | |
47 REGISTER_LOCAL_ANIMATED_PROPERTY(ry) | |
48 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) | 36 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) |
49 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) | 37 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) |
50 END_REGISTER_ANIMATED_PROPERTIES | 38 END_REGISTER_ANIMATED_PROPERTIES |
51 | 39 |
52 inline SVGRectElement::SVGRectElement(Document& document) | 40 inline SVGRectElement::SVGRectElement(Document& document) |
53 : SVGGeometryElement(SVGNames::rectTag, document) | 41 : SVGGeometryElement(SVGNames::rectTag, document) |
54 , m_x(LengthModeWidth) | 42 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth))) |
55 , m_y(LengthModeHeight) | 43 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight))) |
56 , m_width(LengthModeWidth) | 44 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth))) |
57 , m_height(LengthModeHeight) | 45 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight))) |
58 , m_rx(LengthModeWidth) | 46 , m_rx(SVGAnimatedLength::create(this, SVGNames::rxAttr, SVGLength::create(L
engthModeWidth))) |
59 , m_ry(LengthModeHeight) | 47 , m_ry(SVGAnimatedLength::create(this, SVGNames::ryAttr, SVGLength::create(L
engthModeHeight))) |
60 { | 48 { |
61 ScriptWrappable::init(this); | 49 ScriptWrappable::init(this); |
| 50 |
| 51 addToPropertyMap(m_x); |
| 52 addToPropertyMap(m_y); |
| 53 addToPropertyMap(m_width); |
| 54 addToPropertyMap(m_height); |
| 55 addToPropertyMap(m_rx); |
| 56 addToPropertyMap(m_ry); |
| 57 |
62 registerAnimatedPropertiesForSVGRectElement(); | 58 registerAnimatedPropertiesForSVGRectElement(); |
63 } | 59 } |
64 | 60 |
65 PassRefPtr<SVGRectElement> SVGRectElement::create(Document& document) | 61 PassRefPtr<SVGRectElement> SVGRectElement::create(Document& document) |
66 { | 62 { |
67 return adoptRef(new SVGRectElement(document)); | 63 return adoptRef(new SVGRectElement(document)); |
68 } | 64 } |
69 | 65 |
70 bool SVGRectElement::isSupportedAttribute(const QualifiedName& attrName) | 66 bool SVGRectElement::isSupportedAttribute(const QualifiedName& attrName) |
71 { | 67 { |
(...skipping 10 matching lines...) Expand all Loading... |
82 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 78 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
83 } | 79 } |
84 | 80 |
85 void SVGRectElement::parseAttribute(const QualifiedName& name, const AtomicStrin
g& value) | 81 void SVGRectElement::parseAttribute(const QualifiedName& name, const AtomicStrin
g& value) |
86 { | 82 { |
87 SVGParsingError parseError = NoError; | 83 SVGParsingError parseError = NoError; |
88 | 84 |
89 if (!isSupportedAttribute(name)) | 85 if (!isSupportedAttribute(name)) |
90 SVGGeometryElement::parseAttribute(name, value); | 86 SVGGeometryElement::parseAttribute(name, value); |
91 else if (name == SVGNames::xAttr) | 87 else if (name == SVGNames::xAttr) |
92 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); | 88 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
93 else if (name == SVGNames::yAttr) | 89 else if (name == SVGNames::yAttr) |
94 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; | 90 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
95 else if (name == SVGNames::rxAttr) | 91 else if (name == SVGNames::rxAttr) |
96 setRxBaseValue(SVGLength::construct(LengthModeWidth, value, parseError,
ForbidNegativeLengths)); | 92 m_rx->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
97 else if (name == SVGNames::ryAttr) | 93 else if (name == SVGNames::ryAttr) |
98 setRyBaseValue(SVGLength::construct(LengthModeHeight, value, parseError,
ForbidNegativeLengths)); | 94 m_ry->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
99 else if (name == SVGNames::widthAttr) | 95 else if (name == SVGNames::widthAttr) |
100 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r, ForbidNegativeLengths)); | 96 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
101 else if (name == SVGNames::heightAttr) | 97 else if (name == SVGNames::heightAttr) |
102 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror, ForbidNegativeLengths)); | 98 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError)
; |
103 else if (SVGExternalResourcesRequired::parseAttribute(name, value)) { | 99 else if (SVGExternalResourcesRequired::parseAttribute(name, value)) { |
104 } else | 100 } else |
105 ASSERT_NOT_REACHED(); | 101 ASSERT_NOT_REACHED(); |
106 | 102 |
107 reportAttributeParsingError(parseError, name, value); | 103 reportAttributeParsingError(parseError, name, value); |
108 } | 104 } |
109 | 105 |
110 void SVGRectElement::svgAttributeChanged(const QualifiedName& attrName) | 106 void SVGRectElement::svgAttributeChanged(const QualifiedName& attrName) |
111 { | 107 { |
112 if (!isSupportedAttribute(attrName)) { | 108 if (!isSupportedAttribute(attrName)) { |
(...skipping 26 matching lines...) Expand all Loading... |
139 if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) { | 135 if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) { |
140 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); | 136 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); |
141 return; | 137 return; |
142 } | 138 } |
143 | 139 |
144 ASSERT_NOT_REACHED(); | 140 ASSERT_NOT_REACHED(); |
145 } | 141 } |
146 | 142 |
147 bool SVGRectElement::selfHasRelativeLengths() const | 143 bool SVGRectElement::selfHasRelativeLengths() const |
148 { | 144 { |
149 return xCurrentValue().isRelative() | 145 return m_x->currentValue()->isRelative() |
150 || yCurrentValue().isRelative() | 146 || m_y->currentValue()->isRelative() |
151 || widthCurrentValue().isRelative() | 147 || m_width->currentValue()->isRelative() |
152 || heightCurrentValue().isRelative() | 148 || m_height->currentValue()->isRelative() |
153 || rxCurrentValue().isRelative() | 149 || m_rx->currentValue()->isRelative() |
154 || ryCurrentValue().isRelative(); | 150 || m_ry->currentValue()->isRelative(); |
155 } | 151 } |
156 | 152 |
157 RenderObject* SVGRectElement::createRenderer(RenderStyle*) | 153 RenderObject* SVGRectElement::createRenderer(RenderStyle*) |
158 { | 154 { |
159 return new RenderSVGRect(this); | 155 return new RenderSVGRect(this); |
160 } | 156 } |
161 | 157 |
162 } | 158 } |
OLD | NEW |