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_STRING(SVGImageElement, XLinkNames::hrefAttr, Href, href) | |
37 | 36 |
38 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGImageElement) | 37 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGImageElement) |
39 REGISTER_LOCAL_ANIMATED_PROPERTY(href) | |
40 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) | 38 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) |
41 END_REGISTER_ANIMATED_PROPERTIES | 39 END_REGISTER_ANIMATED_PROPERTIES |
42 | 40 |
43 inline SVGImageElement::SVGImageElement(Document& document) | 41 inline SVGImageElement::SVGImageElement(Document& document) |
44 : SVGGraphicsElement(SVGNames::imageTag, document) | 42 : SVGGraphicsElement(SVGNames::imageTag, document) |
45 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth))) | 43 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth))) |
46 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight))) | 44 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight))) |
47 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth))) | 45 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth))) |
48 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight))) | 46 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight))) |
49 , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(this, SVGName
s::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())) | 47 , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(this, SVGName
s::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())) |
| 48 , m_href(SVGAnimatedString::create(this, XLinkNames::hrefAttr, SVGString::cr
eate())) |
50 , m_imageLoader(this) | 49 , m_imageLoader(this) |
51 { | 50 { |
52 ScriptWrappable::init(this); | 51 ScriptWrappable::init(this); |
53 | 52 |
54 addToPropertyMap(m_x); | 53 addToPropertyMap(m_x); |
55 addToPropertyMap(m_y); | 54 addToPropertyMap(m_y); |
56 addToPropertyMap(m_width); | 55 addToPropertyMap(m_width); |
57 addToPropertyMap(m_height); | 56 addToPropertyMap(m_height); |
58 | 57 |
59 addToPropertyMap(m_preserveAspectRatio); | 58 addToPropertyMap(m_preserveAspectRatio); |
| 59 addToPropertyMap(m_href); |
60 registerAnimatedPropertiesForSVGImageElement(); | 60 registerAnimatedPropertiesForSVGImageElement(); |
61 } | 61 } |
62 | 62 |
63 PassRefPtr<SVGImageElement> SVGImageElement::create(Document& document) | 63 PassRefPtr<SVGImageElement> SVGImageElement::create(Document& document) |
64 { | 64 { |
65 return adoptRef(new SVGImageElement(document)); | 65 return adoptRef(new SVGImageElement(document)); |
66 } | 66 } |
67 | 67 |
68 bool SVGImageElement::currentFrameHasSingleSecurityOrigin() const | 68 bool SVGImageElement::currentFrameHasSingleSecurityOrigin() const |
69 { | 69 { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 if (!isSupportedAttribute(name)) | 115 if (!isSupportedAttribute(name)) |
116 SVGGraphicsElement::parseAttribute(name, value); | 116 SVGGraphicsElement::parseAttribute(name, value); |
117 else if (name == SVGNames::xAttr) | 117 else if (name == SVGNames::xAttr) |
118 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError); | 118 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
119 else if (name == SVGNames::yAttr) | 119 else if (name == SVGNames::yAttr) |
120 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError); | 120 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
121 else if (name == SVGNames::widthAttr) | 121 else if (name == SVGNames::widthAttr) |
122 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError); | 122 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
123 else if (name == SVGNames::heightAttr) | 123 else if (name == SVGNames::heightAttr) |
124 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError)
; | 124 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError)
; |
125 else if (name == SVGNames::preserveAspectRatioAttr) { | 125 else if (name == SVGNames::preserveAspectRatioAttr) |
126 m_preserveAspectRatio->setBaseValueAsString(value, parseError); | 126 m_preserveAspectRatio->setBaseValueAsString(value, parseError); |
127 } else if (SVGURIReference::parseAttribute(name, value)) { | 127 else if (name.matches(XLinkNames::hrefAttr)) |
128 } else | 128 m_href->setBaseValueAsString(value, parseError); |
| 129 else |
129 ASSERT_NOT_REACHED(); | 130 ASSERT_NOT_REACHED(); |
130 | 131 |
131 reportAttributeParsingError(parseError, name, value); | 132 reportAttributeParsingError(parseError, name, value); |
132 } | 133 } |
133 | 134 |
134 void SVGImageElement::svgAttributeChanged(const QualifiedName& attrName) | 135 void SVGImageElement::svgAttributeChanged(const QualifiedName& attrName) |
135 { | 136 { |
136 if (!isSupportedAttribute(attrName)) { | 137 if (!isSupportedAttribute(attrName)) { |
137 SVGGraphicsElement::svgAttributeChanged(attrName); | 138 SVGGraphicsElement::svgAttributeChanged(attrName); |
138 return; | 139 return; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 if (!rootParent->inDocument()) | 208 if (!rootParent->inDocument()) |
208 return InsertionDone; | 209 return InsertionDone; |
209 // Update image loader, as soon as we're living in the tree. | 210 // Update image loader, as soon as we're living in the tree. |
210 // We can only resolve base URIs properly, after that! | 211 // We can only resolve base URIs properly, after that! |
211 m_imageLoader.updateFromElement(); | 212 m_imageLoader.updateFromElement(); |
212 return InsertionDone; | 213 return InsertionDone; |
213 } | 214 } |
214 | 215 |
215 const AtomicString SVGImageElement::imageSourceURL() const | 216 const AtomicString SVGImageElement::imageSourceURL() const |
216 { | 217 { |
217 return AtomicString(hrefCurrentValue()); | 218 return AtomicString(m_href->currentValue()->value()); |
218 } | 219 } |
219 | 220 |
220 void SVGImageElement::didMoveToNewDocument(Document& oldDocument) | 221 void SVGImageElement::didMoveToNewDocument(Document& oldDocument) |
221 { | 222 { |
222 m_imageLoader.elementDidMoveToNewDocument(); | 223 m_imageLoader.elementDidMoveToNewDocument(); |
223 SVGGraphicsElement::didMoveToNewDocument(oldDocument); | 224 SVGGraphicsElement::didMoveToNewDocument(oldDocument); |
224 } | 225 } |
225 | 226 |
226 } | 227 } |
OLD | NEW |