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 18 matching lines...) Expand all Loading... |
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) | 33 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::xAttr, X, x) |
34 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::yAttr, Y, y) | 34 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::yAttr, Y, y) |
35 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::widthAttr, Width, width) | 35 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::widthAttr, Width, width) |
36 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::heightAttr, Height, height) | 36 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::heightAttr, Height, height) |
37 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::rxAttr, Rx, rx) | 37 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::rxAttr, Rx, rx) |
38 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::ryAttr, Ry, ry) | 38 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::ryAttr, Ry, ry) |
39 DEFINE_ANIMATED_BOOLEAN(SVGRectElement, SVGNames::externalResourcesRequiredAttr,
ExternalResourcesRequired, externalResourcesRequired) | |
40 | 39 |
41 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGRectElement) | 40 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGRectElement) |
42 REGISTER_LOCAL_ANIMATED_PROPERTY(x) | 41 REGISTER_LOCAL_ANIMATED_PROPERTY(x) |
43 REGISTER_LOCAL_ANIMATED_PROPERTY(y) | 42 REGISTER_LOCAL_ANIMATED_PROPERTY(y) |
44 REGISTER_LOCAL_ANIMATED_PROPERTY(width) | 43 REGISTER_LOCAL_ANIMATED_PROPERTY(width) |
45 REGISTER_LOCAL_ANIMATED_PROPERTY(height) | 44 REGISTER_LOCAL_ANIMATED_PROPERTY(height) |
46 REGISTER_LOCAL_ANIMATED_PROPERTY(rx) | 45 REGISTER_LOCAL_ANIMATED_PROPERTY(rx) |
47 REGISTER_LOCAL_ANIMATED_PROPERTY(ry) | 46 REGISTER_LOCAL_ANIMATED_PROPERTY(ry) |
48 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) | |
49 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) | 47 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) |
50 END_REGISTER_ANIMATED_PROPERTIES | 48 END_REGISTER_ANIMATED_PROPERTIES |
51 | 49 |
52 inline SVGRectElement::SVGRectElement(Document& document) | 50 inline SVGRectElement::SVGRectElement(Document& document) |
53 : SVGGeometryElement(SVGNames::rectTag, document) | 51 : SVGGeometryElement(SVGNames::rectTag, document) |
54 , m_x(LengthModeWidth) | 52 , m_x(LengthModeWidth) |
55 , m_y(LengthModeHeight) | 53 , m_y(LengthModeHeight) |
56 , m_width(LengthModeWidth) | 54 , m_width(LengthModeWidth) |
57 , m_height(LengthModeHeight) | 55 , m_height(LengthModeHeight) |
58 , m_rx(LengthModeWidth) | 56 , m_rx(LengthModeWidth) |
59 , m_ry(LengthModeHeight) | 57 , m_ry(LengthModeHeight) |
60 { | 58 { |
61 ScriptWrappable::init(this); | 59 ScriptWrappable::init(this); |
62 registerAnimatedPropertiesForSVGRectElement(); | 60 registerAnimatedPropertiesForSVGRectElement(); |
63 } | 61 } |
64 | 62 |
65 PassRefPtr<SVGRectElement> SVGRectElement::create(Document& document) | 63 PassRefPtr<SVGRectElement> SVGRectElement::create(Document& document) |
66 { | 64 { |
67 return adoptRef(new SVGRectElement(document)); | 65 return adoptRef(new SVGRectElement(document)); |
68 } | 66 } |
69 | 67 |
70 bool SVGRectElement::isSupportedAttribute(const QualifiedName& attrName) | 68 bool SVGRectElement::isSupportedAttribute(const QualifiedName& attrName) |
71 { | 69 { |
72 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | 70 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); |
73 if (supportedAttributes.isEmpty()) { | 71 if (supportedAttributes.isEmpty()) { |
74 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes
); | |
75 supportedAttributes.add(SVGNames::xAttr); | 72 supportedAttributes.add(SVGNames::xAttr); |
76 supportedAttributes.add(SVGNames::yAttr); | 73 supportedAttributes.add(SVGNames::yAttr); |
77 supportedAttributes.add(SVGNames::widthAttr); | 74 supportedAttributes.add(SVGNames::widthAttr); |
78 supportedAttributes.add(SVGNames::heightAttr); | 75 supportedAttributes.add(SVGNames::heightAttr); |
79 supportedAttributes.add(SVGNames::rxAttr); | 76 supportedAttributes.add(SVGNames::rxAttr); |
80 supportedAttributes.add(SVGNames::ryAttr); | 77 supportedAttributes.add(SVGNames::ryAttr); |
81 } | 78 } |
82 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 79 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
83 } | 80 } |
84 | 81 |
85 void SVGRectElement::parseAttribute(const QualifiedName& name, const AtomicStrin
g& value) | 82 void SVGRectElement::parseAttribute(const QualifiedName& name, const AtomicStrin
g& value) |
86 { | 83 { |
87 SVGParsingError parseError = NoError; | 84 SVGParsingError parseError = NoError; |
88 | 85 |
89 if (!isSupportedAttribute(name)) | 86 if (!isSupportedAttribute(name)) |
90 SVGGeometryElement::parseAttribute(name, value); | 87 SVGGeometryElement::parseAttribute(name, value); |
91 else if (name == SVGNames::xAttr) | 88 else if (name == SVGNames::xAttr) |
92 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); | 89 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); |
93 else if (name == SVGNames::yAttr) | 90 else if (name == SVGNames::yAttr) |
94 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; | 91 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; |
95 else if (name == SVGNames::rxAttr) | 92 else if (name == SVGNames::rxAttr) |
96 setRxBaseValue(SVGLength::construct(LengthModeWidth, value, parseError,
ForbidNegativeLengths)); | 93 setRxBaseValue(SVGLength::construct(LengthModeWidth, value, parseError,
ForbidNegativeLengths)); |
97 else if (name == SVGNames::ryAttr) | 94 else if (name == SVGNames::ryAttr) |
98 setRyBaseValue(SVGLength::construct(LengthModeHeight, value, parseError,
ForbidNegativeLengths)); | 95 setRyBaseValue(SVGLength::construct(LengthModeHeight, value, parseError,
ForbidNegativeLengths)); |
99 else if (name == SVGNames::widthAttr) | 96 else if (name == SVGNames::widthAttr) |
100 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r, ForbidNegativeLengths)); | 97 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r, ForbidNegativeLengths)); |
101 else if (name == SVGNames::heightAttr) | 98 else if (name == SVGNames::heightAttr) |
102 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror, ForbidNegativeLengths)); | 99 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror, ForbidNegativeLengths)); |
103 else if (SVGExternalResourcesRequired::parseAttribute(name, value)) { | 100 else |
104 } 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)) { |
113 SVGGeometryElement::svgAttributeChanged(attrName); | 109 SVGGeometryElement::svgAttributeChanged(attrName); |
114 return; | 110 return; |
(...skipping 14 matching lines...) Expand all Loading... |
129 RenderSVGShape* renderer = toRenderSVGShape(this->renderer()); | 125 RenderSVGShape* renderer = toRenderSVGShape(this->renderer()); |
130 if (!renderer) | 126 if (!renderer) |
131 return; | 127 return; |
132 | 128 |
133 if (isLengthAttribute) { | 129 if (isLengthAttribute) { |
134 renderer->setNeedsShapeUpdate(); | 130 renderer->setNeedsShapeUpdate(); |
135 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); | 131 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); |
136 return; | 132 return; |
137 } | 133 } |
138 | 134 |
139 if (SVGExternalResourcesRequired::isKnownAttribute(attrName)) { | |
140 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); | |
141 return; | |
142 } | |
143 | |
144 ASSERT_NOT_REACHED(); | 135 ASSERT_NOT_REACHED(); |
145 } | 136 } |
146 | 137 |
147 bool SVGRectElement::selfHasRelativeLengths() const | 138 bool SVGRectElement::selfHasRelativeLengths() const |
148 { | 139 { |
149 return xCurrentValue().isRelative() | 140 return xCurrentValue().isRelative() |
150 || yCurrentValue().isRelative() | 141 || yCurrentValue().isRelative() |
151 || widthCurrentValue().isRelative() | 142 || widthCurrentValue().isRelative() |
152 || heightCurrentValue().isRelative() | 143 || heightCurrentValue().isRelative() |
153 || rxCurrentValue().isRelative() | 144 || rxCurrentValue().isRelative() |
154 || ryCurrentValue().isRelative(); | 145 || ryCurrentValue().isRelative(); |
155 } | 146 } |
156 | 147 |
157 RenderObject* SVGRectElement::createRenderer(RenderStyle*) | 148 RenderObject* SVGRectElement::createRenderer(RenderStyle*) |
158 { | 149 { |
159 return new RenderSVGRect(this); | 150 return new RenderSVGRect(this); |
160 } | 151 } |
161 | 152 |
162 } | 153 } |
OLD | NEW |