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 15 matching lines...) Expand all Loading... |
26 #include "CSSPropertyNames.h" | 26 #include "CSSPropertyNames.h" |
27 #include "XLinkNames.h" | 27 #include "XLinkNames.h" |
28 #include "core/rendering/RenderImageResource.h" | 28 #include "core/rendering/RenderImageResource.h" |
29 #include "core/rendering/svg/RenderSVGImage.h" | 29 #include "core/rendering/svg/RenderSVGImage.h" |
30 #include "core/rendering/svg/RenderSVGResource.h" | 30 #include "core/rendering/svg/RenderSVGResource.h" |
31 #include "core/svg/SVGElementInstance.h" | 31 #include "core/svg/SVGElementInstance.h" |
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) | |
37 DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::yAttr, Y, y) | |
38 DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::widthAttr, Width, width) | |
39 DEFINE_ANIMATED_LENGTH(SVGImageElement, SVGNames::heightAttr, Height, height) | |
40 DEFINE_ANIMATED_PRESERVEASPECTRATIO(SVGImageElement, SVGNames::preserveAspectRat
ioAttr, PreserveAspectRatio, preserveAspectRatio) | 36 DEFINE_ANIMATED_PRESERVEASPECTRATIO(SVGImageElement, SVGNames::preserveAspectRat
ioAttr, PreserveAspectRatio, preserveAspectRatio) |
41 DEFINE_ANIMATED_STRING(SVGImageElement, XLinkNames::hrefAttr, Href, href) | 37 DEFINE_ANIMATED_STRING(SVGImageElement, XLinkNames::hrefAttr, Href, href) |
42 DEFINE_ANIMATED_BOOLEAN(SVGImageElement, SVGNames::externalResourcesRequiredAttr
, ExternalResourcesRequired, externalResourcesRequired) | 38 DEFINE_ANIMATED_BOOLEAN(SVGImageElement, SVGNames::externalResourcesRequiredAttr
, ExternalResourcesRequired, externalResourcesRequired) |
43 | 39 |
44 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGImageElement) | 40 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGImageElement) |
45 REGISTER_LOCAL_ANIMATED_PROPERTY(x) | |
46 REGISTER_LOCAL_ANIMATED_PROPERTY(y) | |
47 REGISTER_LOCAL_ANIMATED_PROPERTY(width) | |
48 REGISTER_LOCAL_ANIMATED_PROPERTY(height) | |
49 REGISTER_LOCAL_ANIMATED_PROPERTY(preserveAspectRatio) | 41 REGISTER_LOCAL_ANIMATED_PROPERTY(preserveAspectRatio) |
50 REGISTER_LOCAL_ANIMATED_PROPERTY(href) | 42 REGISTER_LOCAL_ANIMATED_PROPERTY(href) |
51 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) | 43 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) |
52 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) | 44 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) |
53 END_REGISTER_ANIMATED_PROPERTIES | 45 END_REGISTER_ANIMATED_PROPERTIES |
54 | 46 |
55 inline SVGImageElement::SVGImageElement(Document& document) | 47 inline SVGImageElement::SVGImageElement(Document& document) |
56 : SVGGraphicsElement(SVGNames::imageTag, document) | 48 : SVGGraphicsElement(SVGNames::imageTag, document) |
57 , m_x(LengthModeWidth) | 49 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth))) |
58 , m_y(LengthModeHeight) | 50 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight))) |
59 , m_width(LengthModeWidth) | 51 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth))) |
60 , m_height(LengthModeHeight) | 52 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight))) |
61 , m_imageLoader(this) | 53 , m_imageLoader(this) |
62 { | 54 { |
63 ScriptWrappable::init(this); | 55 ScriptWrappable::init(this); |
| 56 |
| 57 addToPropertyMap(m_x); |
| 58 addToPropertyMap(m_y); |
| 59 addToPropertyMap(m_width); |
| 60 addToPropertyMap(m_height); |
| 61 |
64 registerAnimatedPropertiesForSVGImageElement(); | 62 registerAnimatedPropertiesForSVGImageElement(); |
65 } | 63 } |
66 | 64 |
67 PassRefPtr<SVGImageElement> SVGImageElement::create(Document& document) | 65 PassRefPtr<SVGImageElement> SVGImageElement::create(Document& document) |
68 { | 66 { |
69 return adoptRef(new SVGImageElement(document)); | 67 return adoptRef(new SVGImageElement(document)); |
70 } | 68 } |
71 | 69 |
72 bool SVGImageElement::currentFrameHasSingleSecurityOrigin() const | 70 bool SVGImageElement::currentFrameHasSingleSecurityOrigin() const |
73 { | 71 { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight, value)
; | 111 addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight, value)
; |
114 } | 112 } |
115 | 113 |
116 void SVGImageElement::parseAttribute(const QualifiedName& name, const AtomicStri
ng& value) | 114 void SVGImageElement::parseAttribute(const QualifiedName& name, const AtomicStri
ng& value) |
117 { | 115 { |
118 SVGParsingError parseError = NoError; | 116 SVGParsingError parseError = NoError; |
119 | 117 |
120 if (!isSupportedAttribute(name)) | 118 if (!isSupportedAttribute(name)) |
121 SVGGraphicsElement::parseAttribute(name, value); | 119 SVGGraphicsElement::parseAttribute(name, value); |
122 else if (name == SVGNames::xAttr) | 120 else if (name == SVGNames::xAttr) |
123 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); | 121 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
124 else if (name == SVGNames::yAttr) | 122 else if (name == SVGNames::yAttr) |
125 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; | 123 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
| 124 else if (name == SVGNames::widthAttr) |
| 125 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
| 126 else if (name == SVGNames::heightAttr) |
| 127 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError)
; |
126 else if (name == SVGNames::preserveAspectRatioAttr) { | 128 else if (name == SVGNames::preserveAspectRatioAttr) { |
127 SVGPreserveAspectRatio preserveAspectRatio; | 129 SVGPreserveAspectRatio preserveAspectRatio; |
128 preserveAspectRatio.parse(value); | 130 preserveAspectRatio.parse(value); |
129 setPreserveAspectRatioBaseValue(preserveAspectRatio); | 131 setPreserveAspectRatioBaseValue(preserveAspectRatio); |
130 } else if (name == SVGNames::widthAttr) | 132 } else if (SVGExternalResourcesRequired::parseAttribute(name, value) |
131 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r, ForbidNegativeLengths)); | |
132 else if (name == SVGNames::heightAttr) | |
133 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror, ForbidNegativeLengths)); | |
134 else if (SVGExternalResourcesRequired::parseAttribute(name, value) | |
135 || SVGURIReference::parseAttribute(name, value)) { | 133 || SVGURIReference::parseAttribute(name, value)) { |
136 } else | 134 } else |
137 ASSERT_NOT_REACHED(); | 135 ASSERT_NOT_REACHED(); |
138 | 136 |
139 reportAttributeParsingError(parseError, name, value); | 137 reportAttributeParsingError(parseError, name, value); |
140 } | 138 } |
141 | 139 |
142 void SVGImageElement::svgAttributeChanged(const QualifiedName& attrName) | 140 void SVGImageElement::svgAttributeChanged(const QualifiedName& attrName) |
143 { | 141 { |
144 if (!isSupportedAttribute(attrName)) { | 142 if (!isSupportedAttribute(attrName)) { |
(...skipping 30 matching lines...) Expand all Loading... |
175 || SVGExternalResourcesRequired::isKnownAttribute(attrName)) { | 173 || SVGExternalResourcesRequired::isKnownAttribute(attrName)) { |
176 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); | 174 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); |
177 return; | 175 return; |
178 } | 176 } |
179 | 177 |
180 ASSERT_NOT_REACHED(); | 178 ASSERT_NOT_REACHED(); |
181 } | 179 } |
182 | 180 |
183 bool SVGImageElement::selfHasRelativeLengths() const | 181 bool SVGImageElement::selfHasRelativeLengths() const |
184 { | 182 { |
185 return xCurrentValue().isRelative() | 183 return m_x->currentValue()->isRelative() |
186 || yCurrentValue().isRelative() | 184 || m_y->currentValue()->isRelative() |
187 || widthCurrentValue().isRelative() | 185 || m_width->currentValue()->isRelative() |
188 || heightCurrentValue().isRelative(); | 186 || m_height->currentValue()->isRelative(); |
189 } | 187 } |
190 | 188 |
191 RenderObject* SVGImageElement::createRenderer(RenderStyle*) | 189 RenderObject* SVGImageElement::createRenderer(RenderStyle*) |
192 { | 190 { |
193 return new RenderSVGImage(this); | 191 return new RenderSVGImage(this); |
194 } | 192 } |
195 | 193 |
196 bool SVGImageElement::haveLoadedRequiredResources() | 194 bool SVGImageElement::haveLoadedRequiredResources() |
197 { | 195 { |
198 return !externalResourcesRequiredBaseValue() || !m_imageLoader.hasPendingAct
ivity(); | 196 return !externalResourcesRequiredBaseValue() || !m_imageLoader.hasPendingAct
ivity(); |
(...skipping 27 matching lines...) Expand all Loading... |
226 return AtomicString(hrefCurrentValue()); | 224 return AtomicString(hrefCurrentValue()); |
227 } | 225 } |
228 | 226 |
229 void SVGImageElement::didMoveToNewDocument(Document& oldDocument) | 227 void SVGImageElement::didMoveToNewDocument(Document& oldDocument) |
230 { | 228 { |
231 m_imageLoader.elementDidMoveToNewDocument(); | 229 m_imageLoader.elementDidMoveToNewDocument(); |
232 SVGGraphicsElement::didMoveToNewDocument(oldDocument); | 230 SVGGraphicsElement::didMoveToNewDocument(oldDocument); |
233 } | 231 } |
234 | 232 |
235 } | 233 } |
OLD | NEW |