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, 2008, 2009 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> | 4 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 namespace WebCore { | 33 namespace WebCore { |
34 | 34 |
35 // Animated property definitions | 35 // Animated property definitions |
36 DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::xAttr, X, x) | 36 DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::xAttr, X, x) |
37 DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::yAttr, Y, y) | 37 DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::yAttr, Y, y) |
38 DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::widthAttr, Width, width) | 38 DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::widthAttr, Width, width) |
39 DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::heightAttr, Height, height) | 39 DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::heightAttr, Height, height) |
40 DEFINE_ANIMATED_PRESERVEASPECTRATIO(SVGImageElement, SVGNames::preserveAspectRat
ioAttr, PreserveAspectRatio, preserveAspectRatio) | 40 DEFINE_ANIMATED_PRESERVEASPECTRATIO(SVGImageElement, SVGNames::preserveAspectRat
ioAttr, PreserveAspectRatio, preserveAspectRatio) |
41 DEFINE_ANIMATED_STRING(SVGImageElement, XLinkNames::hrefAttr, Href, href) | 41 DEFINE_ANIMATED_STRING(SVGImageElement, XLinkNames::hrefAttr, Href, href) |
42 DEFINE_ANIMATED_BOOLEAN(SVGImageElement, SVGNames::externalResourcesRequiredAttr
, ExternalResourcesRequired, externalResourcesRequired) | |
43 | 42 |
44 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGImageElement) | 43 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGImageElement) |
45 REGISTER_LOCAL_ANIMATED_PROPERTY(x) | 44 REGISTER_LOCAL_ANIMATED_PROPERTY(x) |
46 REGISTER_LOCAL_ANIMATED_PROPERTY(y) | 45 REGISTER_LOCAL_ANIMATED_PROPERTY(y) |
47 REGISTER_LOCAL_ANIMATED_PROPERTY(width) | 46 REGISTER_LOCAL_ANIMATED_PROPERTY(width) |
48 REGISTER_LOCAL_ANIMATED_PROPERTY(height) | 47 REGISTER_LOCAL_ANIMATED_PROPERTY(height) |
49 REGISTER_LOCAL_ANIMATED_PROPERTY(preserveAspectRatio) | 48 REGISTER_LOCAL_ANIMATED_PROPERTY(preserveAspectRatio) |
50 REGISTER_LOCAL_ANIMATED_PROPERTY(href) | 49 REGISTER_LOCAL_ANIMATED_PROPERTY(href) |
51 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) | |
52 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) | 50 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) |
53 END_REGISTER_ANIMATED_PROPERTIES | 51 END_REGISTER_ANIMATED_PROPERTIES |
54 | 52 |
55 inline SVGImageElement::SVGImageElement(Document& document) | 53 inline SVGImageElement::SVGImageElement(Document& document) |
56 : SVGGraphicsElement(SVGNames::imageTag, document) | 54 : SVGGraphicsElement(SVGNames::imageTag, document) |
57 , m_x(LengthModeWidth) | 55 , m_x(LengthModeWidth) |
58 , m_y(LengthModeHeight) | 56 , m_y(LengthModeHeight) |
59 , m_width(LengthModeWidth) | 57 , m_width(LengthModeWidth) |
60 , m_height(LengthModeHeight) | 58 , m_height(LengthModeHeight) |
61 , m_imageLoader(this) | 59 , m_imageLoader(this) |
(...skipping 16 matching lines...) Expand all Loading... |
78 } | 76 } |
79 } | 77 } |
80 | 78 |
81 return true; | 79 return true; |
82 } | 80 } |
83 | 81 |
84 bool SVGImageElement::isSupportedAttribute(const QualifiedName& attrName) | 82 bool SVGImageElement::isSupportedAttribute(const QualifiedName& attrName) |
85 { | 83 { |
86 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | 84 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); |
87 if (supportedAttributes.isEmpty()) { | 85 if (supportedAttributes.isEmpty()) { |
88 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes
); | |
89 SVGURIReference::addSupportedAttributes(supportedAttributes); | 86 SVGURIReference::addSupportedAttributes(supportedAttributes); |
90 supportedAttributes.add(SVGNames::xAttr); | 87 supportedAttributes.add(SVGNames::xAttr); |
91 supportedAttributes.add(SVGNames::yAttr); | 88 supportedAttributes.add(SVGNames::yAttr); |
92 supportedAttributes.add(SVGNames::widthAttr); | 89 supportedAttributes.add(SVGNames::widthAttr); |
93 supportedAttributes.add(SVGNames::heightAttr); | 90 supportedAttributes.add(SVGNames::heightAttr); |
94 supportedAttributes.add(SVGNames::preserveAspectRatioAttr); | 91 supportedAttributes.add(SVGNames::preserveAspectRatioAttr); |
95 } | 92 } |
96 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 93 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
97 } | 94 } |
98 | 95 |
(...skipping 25 matching lines...) Expand all Loading... |
124 else if (name == SVGNames::yAttr) | 121 else if (name == SVGNames::yAttr) |
125 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; | 122 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; |
126 else if (name == SVGNames::preserveAspectRatioAttr) { | 123 else if (name == SVGNames::preserveAspectRatioAttr) { |
127 SVGPreserveAspectRatio preserveAspectRatio; | 124 SVGPreserveAspectRatio preserveAspectRatio; |
128 preserveAspectRatio.parse(value); | 125 preserveAspectRatio.parse(value); |
129 setPreserveAspectRatioBaseValue(preserveAspectRatio); | 126 setPreserveAspectRatioBaseValue(preserveAspectRatio); |
130 } else if (name == SVGNames::widthAttr) | 127 } else if (name == SVGNames::widthAttr) |
131 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r, ForbidNegativeLengths)); | 128 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r, ForbidNegativeLengths)); |
132 else if (name == SVGNames::heightAttr) | 129 else if (name == SVGNames::heightAttr) |
133 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror, ForbidNegativeLengths)); | 130 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror, ForbidNegativeLengths)); |
134 else if (SVGExternalResourcesRequired::parseAttribute(name, value) | 131 else if (SVGURIReference::parseAttribute(name, value)) { |
135 || SVGURIReference::parseAttribute(name, value)) { | |
136 } else | 132 } else |
137 ASSERT_NOT_REACHED(); | 133 ASSERT_NOT_REACHED(); |
138 | 134 |
139 reportAttributeParsingError(parseError, name, value); | 135 reportAttributeParsingError(parseError, name, value); |
140 } | 136 } |
141 | 137 |
142 void SVGImageElement::svgAttributeChanged(const QualifiedName& attrName) | 138 void SVGImageElement::svgAttributeChanged(const QualifiedName& attrName) |
143 { | 139 { |
144 if (!isSupportedAttribute(attrName)) { | 140 if (!isSupportedAttribute(attrName)) { |
145 SVGGraphicsElement::svgAttributeChanged(attrName); | 141 SVGGraphicsElement::svgAttributeChanged(attrName); |
(...skipping 18 matching lines...) Expand all Loading... |
164 RenderObject* renderer = this->renderer(); | 160 RenderObject* renderer = this->renderer(); |
165 if (!renderer) | 161 if (!renderer) |
166 return; | 162 return; |
167 | 163 |
168 if (isLengthAttribute) { | 164 if (isLengthAttribute) { |
169 if (toRenderSVGImage(renderer)->updateImageViewport()) | 165 if (toRenderSVGImage(renderer)->updateImageViewport()) |
170 RenderSVGResource::markForLayoutAndParentResourceInvalidation(render
er); | 166 RenderSVGResource::markForLayoutAndParentResourceInvalidation(render
er); |
171 return; | 167 return; |
172 } | 168 } |
173 | 169 |
174 if (attrName == SVGNames::preserveAspectRatioAttr | 170 if (attrName == SVGNames::preserveAspectRatioAttr) { |
175 || SVGExternalResourcesRequired::isKnownAttribute(attrName)) { | |
176 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); | 171 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); |
177 return; | 172 return; |
178 } | 173 } |
179 | 174 |
180 ASSERT_NOT_REACHED(); | 175 ASSERT_NOT_REACHED(); |
181 } | 176 } |
182 | 177 |
183 bool SVGImageElement::selfHasRelativeLengths() const | 178 bool SVGImageElement::selfHasRelativeLengths() const |
184 { | 179 { |
185 return xCurrentValue().isRelative() | 180 return xCurrentValue().isRelative() |
186 || yCurrentValue().isRelative() | 181 || yCurrentValue().isRelative() |
187 || widthCurrentValue().isRelative() | 182 || widthCurrentValue().isRelative() |
188 || heightCurrentValue().isRelative(); | 183 || heightCurrentValue().isRelative(); |
189 } | 184 } |
190 | 185 |
191 RenderObject* SVGImageElement::createRenderer(RenderStyle*) | 186 RenderObject* SVGImageElement::createRenderer(RenderStyle*) |
192 { | 187 { |
193 return new RenderSVGImage(this); | 188 return new RenderSVGImage(this); |
194 } | 189 } |
195 | 190 |
196 bool SVGImageElement::haveLoadedRequiredResources() | 191 bool SVGImageElement::haveLoadedRequiredResources() |
197 { | 192 { |
198 return !externalResourcesRequiredBaseValue() || !m_imageLoader.hasPendingAct
ivity(); | 193 return !m_imageLoader.hasPendingActivity(); |
199 } | 194 } |
200 | 195 |
201 void SVGImageElement::attach(const AttachContext& context) | 196 void SVGImageElement::attach(const AttachContext& context) |
202 { | 197 { |
203 SVGGraphicsElement::attach(context); | 198 SVGGraphicsElement::attach(context); |
204 | 199 |
205 if (RenderSVGImage* imageObj = toRenderSVGImage(renderer())) { | 200 if (RenderSVGImage* imageObj = toRenderSVGImage(renderer())) { |
206 if (imageObj->imageResource()->hasImage()) | 201 if (imageObj->imageResource()->hasImage()) |
207 return; | 202 return; |
208 | 203 |
(...skipping 17 matching lines...) Expand all Loading... |
226 return AtomicString(hrefCurrentValue()); | 221 return AtomicString(hrefCurrentValue()); |
227 } | 222 } |
228 | 223 |
229 void SVGImageElement::didMoveToNewDocument(Document& oldDocument) | 224 void SVGImageElement::didMoveToNewDocument(Document& oldDocument) |
230 { | 225 { |
231 m_imageLoader.elementDidMoveToNewDocument(); | 226 m_imageLoader.elementDidMoveToNewDocument(); |
232 SVGGraphicsElement::didMoveToNewDocument(oldDocument); | 227 SVGGraphicsElement::didMoveToNewDocument(oldDocument); |
233 } | 228 } |
234 | 229 |
235 } | 230 } |
OLD | NEW |