| 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 namespace WebCore { | 32 namespace WebCore { |
| 33 | 33 |
| 34 SVGImageElement::SVGImageElement(Document& document) | 34 SVGImageElement::SVGImageElement(Document& document) |
| 35 : SVGGraphicsElement(SVGNames::imageTag, document) | 35 : SVGGraphicsElement(SVGNames::imageTag, document) |
| 36 , SVGURIReference(this) | 36 , SVGURIReference(this) |
| 37 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth), AllowNegativeLengths)) | 37 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth), AllowNegativeLengths)) |
| 38 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight), AllowNegativeLengths)) | 38 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight), AllowNegativeLengths)) |
| 39 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth), ForbidNegativeLengths)) | 39 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth), ForbidNegativeLengths)) |
| 40 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight), ForbidNegativeLengths)) | 40 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight), ForbidNegativeLengths)) |
| 41 , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(this, SVGName
s::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())) | 41 , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(this, SVGName
s::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())) |
| 42 , m_imageLoader(this) | 42 , m_imageLoader(SVGImageLoader::create(this)) |
| 43 , m_needsLoaderURIUpdate(true) | 43 , m_needsLoaderURIUpdate(true) |
| 44 { | 44 { |
| 45 ScriptWrappable::init(this); | 45 ScriptWrappable::init(this); |
| 46 | 46 |
| 47 addToPropertyMap(m_x); | 47 addToPropertyMap(m_x); |
| 48 addToPropertyMap(m_y); | 48 addToPropertyMap(m_y); |
| 49 addToPropertyMap(m_width); | 49 addToPropertyMap(m_width); |
| 50 addToPropertyMap(m_height); | 50 addToPropertyMap(m_height); |
| 51 addToPropertyMap(m_preserveAspectRatio); | 51 addToPropertyMap(m_preserveAspectRatio); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void SVGImageElement::trace(Visitor* visitor) |
| 55 { |
| 56 visitor->trace(m_imageLoader); |
| 57 SVGGraphicsElement::trace(visitor); |
| 58 } |
| 59 |
| 54 bool SVGImageElement::currentFrameHasSingleSecurityOrigin() const | 60 bool SVGImageElement::currentFrameHasSingleSecurityOrigin() const |
| 55 { | 61 { |
| 56 if (RenderSVGImage* renderSVGImage = toRenderSVGImage(renderer())) { | 62 if (RenderSVGImage* renderSVGImage = toRenderSVGImage(renderer())) { |
| 57 if (renderSVGImage->imageResource()->hasImage()) { | 63 if (renderSVGImage->imageResource()->hasImage()) { |
| 58 if (Image* image = renderSVGImage->imageResource()->cachedImage()->i
mage()) | 64 if (Image* image = renderSVGImage->imageResource()->cachedImage()->i
mage()) |
| 59 return image->currentFrameHasSingleSecurityOrigin(); | 65 return image->currentFrameHasSingleSecurityOrigin(); |
| 60 } | 66 } |
| 61 } | 67 } |
| 62 | 68 |
| 63 return true; | 69 return true; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 bool isLengthAttribute = attrName == SVGNames::xAttr | 136 bool isLengthAttribute = attrName == SVGNames::xAttr |
| 131 || attrName == SVGNames::yAttr | 137 || attrName == SVGNames::yAttr |
| 132 || attrName == SVGNames::widthAttr | 138 || attrName == SVGNames::widthAttr |
| 133 || attrName == SVGNames::heightAttr; | 139 || attrName == SVGNames::heightAttr; |
| 134 | 140 |
| 135 if (isLengthAttribute) | 141 if (isLengthAttribute) |
| 136 updateRelativeLengthsInformation(); | 142 updateRelativeLengthsInformation(); |
| 137 | 143 |
| 138 if (SVGURIReference::isKnownAttribute(attrName)) { | 144 if (SVGURIReference::isKnownAttribute(attrName)) { |
| 139 if (inDocument()) | 145 if (inDocument()) |
| 140 m_imageLoader.updateFromElementIgnoringPreviousError(); | 146 imageLoader().updateFromElementIgnoringPreviousError(); |
| 141 else | 147 else |
| 142 m_needsLoaderURIUpdate = true; | 148 m_needsLoaderURIUpdate = true; |
| 143 return; | 149 return; |
| 144 } | 150 } |
| 145 | 151 |
| 146 RenderObject* renderer = this->renderer(); | 152 RenderObject* renderer = this->renderer(); |
| 147 if (!renderer) | 153 if (!renderer) |
| 148 return; | 154 return; |
| 149 | 155 |
| 150 if (isLengthAttribute) { | 156 if (isLengthAttribute) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 169 || m_height->currentValue()->isRelative(); | 175 || m_height->currentValue()->isRelative(); |
| 170 } | 176 } |
| 171 | 177 |
| 172 RenderObject* SVGImageElement::createRenderer(RenderStyle*) | 178 RenderObject* SVGImageElement::createRenderer(RenderStyle*) |
| 173 { | 179 { |
| 174 return new RenderSVGImage(this); | 180 return new RenderSVGImage(this); |
| 175 } | 181 } |
| 176 | 182 |
| 177 bool SVGImageElement::haveLoadedRequiredResources() | 183 bool SVGImageElement::haveLoadedRequiredResources() |
| 178 { | 184 { |
| 179 return !m_needsLoaderURIUpdate && !m_imageLoader.hasPendingActivity(); | 185 return !m_needsLoaderURIUpdate && !imageLoader().hasPendingActivity(); |
| 180 } | 186 } |
| 181 | 187 |
| 182 void SVGImageElement::attach(const AttachContext& context) | 188 void SVGImageElement::attach(const AttachContext& context) |
| 183 { | 189 { |
| 184 SVGGraphicsElement::attach(context); | 190 SVGGraphicsElement::attach(context); |
| 185 | 191 |
| 186 if (RenderSVGImage* imageObj = toRenderSVGImage(renderer())) { | 192 if (RenderSVGImage* imageObj = toRenderSVGImage(renderer())) { |
| 187 if (imageObj->imageResource()->hasImage()) | 193 if (imageObj->imageResource()->hasImage()) |
| 188 return; | 194 return; |
| 189 | 195 |
| 190 imageObj->imageResource()->setImageResource(m_imageLoader.image()); | 196 imageObj->imageResource()->setImageResource(imageLoader().image()); |
| 191 } | 197 } |
| 192 } | 198 } |
| 193 | 199 |
| 194 Node::InsertionNotificationRequest SVGImageElement::insertedInto(ContainerNode*
rootParent) | 200 Node::InsertionNotificationRequest SVGImageElement::insertedInto(ContainerNode*
rootParent) |
| 195 { | 201 { |
| 196 SVGGraphicsElement::insertedInto(rootParent); | 202 SVGGraphicsElement::insertedInto(rootParent); |
| 197 if (!rootParent->inDocument()) | 203 if (!rootParent->inDocument()) |
| 198 return InsertionDone; | 204 return InsertionDone; |
| 199 | 205 |
| 200 // We can only resolve base URIs properly after tree insertion - hence, URI
mutations while | 206 // We can only resolve base URIs properly after tree insertion - hence, URI
mutations while |
| 201 // detached are deferred until this point. | 207 // detached are deferred until this point. |
| 202 if (m_needsLoaderURIUpdate) { | 208 if (m_needsLoaderURIUpdate) { |
| 203 m_imageLoader.updateFromElementIgnoringPreviousError(); | 209 imageLoader().updateFromElementIgnoringPreviousError(); |
| 204 m_needsLoaderURIUpdate = false; | 210 m_needsLoaderURIUpdate = false; |
| 205 } else { | 211 } else { |
| 206 // A previous loader update may have failed to actually fetch the image
if the document | 212 // A previous loader update may have failed to actually fetch the image
if the document |
| 207 // was inactive. In that case, force a re-update (but don't clear previo
us errors). | 213 // was inactive. In that case, force a re-update (but don't clear previo
us errors). |
| 208 if (!m_imageLoader.image()) | 214 if (!imageLoader().image()) |
| 209 m_imageLoader.updateFromElement(); | 215 imageLoader().updateFromElement(); |
| 210 } | 216 } |
| 211 | 217 |
| 212 return InsertionDone; | 218 return InsertionDone; |
| 213 } | 219 } |
| 214 | 220 |
| 215 const AtomicString SVGImageElement::imageSourceURL() const | 221 const AtomicString SVGImageElement::imageSourceURL() const |
| 216 { | 222 { |
| 217 return AtomicString(hrefString()); | 223 return AtomicString(hrefString()); |
| 218 } | 224 } |
| 219 | 225 |
| 220 void SVGImageElement::didMoveToNewDocument(Document& oldDocument) | 226 void SVGImageElement::didMoveToNewDocument(Document& oldDocument) |
| 221 { | 227 { |
| 222 m_imageLoader.elementDidMoveToNewDocument(); | 228 imageLoader().elementDidMoveToNewDocument(); |
| 223 SVGGraphicsElement::didMoveToNewDocument(oldDocument); | 229 SVGGraphicsElement::didMoveToNewDocument(oldDocument); |
| 224 } | 230 } |
| 225 | 231 |
| 226 } | 232 } |
| OLD | NEW |