summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/SVGFEImageElement.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
commitcd44dc59cdfc39534aef4d417e9f3c412e3be139 (patch)
tree8d89889ba95ed6ec9322e733846cc9cce9d7dff1 /Source/WebCore/svg/SVGFEImageElement.cpp
parentd11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 (diff)
downloadqtwebkit-cd44dc59cdfc39534aef4d417e9f3c412e3be139.tar.gz
Imported WebKit commit fce473cb4d55aa9fe9d0b0322a2fffecb731b961 (http://svn.webkit.org/repository/webkit/trunk@106560)
Diffstat (limited to 'Source/WebCore/svg/SVGFEImageElement.cpp')
-rw-r--r--Source/WebCore/svg/SVGFEImageElement.cpp90
1 files changed, 42 insertions, 48 deletions
diff --git a/Source/WebCore/svg/SVGFEImageElement.cpp b/Source/WebCore/svg/SVGFEImageElement.cpp
index 0c833c0b5..7050c25c2 100644
--- a/Source/WebCore/svg/SVGFEImageElement.cpp
+++ b/Source/WebCore/svg/SVGFEImageElement.cpp
@@ -33,7 +33,6 @@
#include "RenderObject.h"
#include "RenderSVGResource.h"
#include "SVGElementInstance.h"
-#include "SVGImageBufferTools.h"
#include "SVGNames.h"
#include "SVGPreserveAspectRatio.h"
@@ -65,39 +64,47 @@ PassRefPtr<SVGFEImageElement> SVGFEImageElement::create(const QualifiedName& tag
SVGFEImageElement::~SVGFEImageElement()
{
- if (m_cachedImage)
- m_cachedImage->removeClient(this);
+ clearResourceReferences();
}
-void SVGFEImageElement::invalidateImageResource()
+void SVGFEImageElement::clearResourceReferences()
{
if (m_cachedImage) {
m_cachedImage->removeClient(this);
m_cachedImage = 0;
}
-
- m_targetImage.clear();
}
void SVGFEImageElement::requestImageResource()
{
- invalidateImageResource();
-
- String fragmentIdentifier;
- Element* hrefElement = SVGURIReference::targetElementFromIRIString(href(), document(), &fragmentIdentifier);
+ ResourceRequest request(ownerDocument()->completeURL(href()));
+ m_cachedImage = document()->cachedResourceLoader()->requestImage(request);
- if (hrefElement && hrefElement->isSVGElement() && hrefElement->renderer())
- return;
+ if (m_cachedImage)
+ m_cachedImage->addClient(this);
+}
- // We have what appears to be a local fragment identifier, but it didn't resolve yet.
- if (!fragmentIdentifier.isEmpty())
+void SVGFEImageElement::buildPendingResource()
+{
+ clearResourceReferences();
+ if (!inDocument())
return;
- ResourceRequest request(ownerDocument()->completeURL(href()));
- m_cachedImage = ownerDocument()->cachedResourceLoader()->requestImage(request);
+ String id;
+ Element* target = SVGURIReference::targetElementFromIRIString(href(), document(), &id);
+ if (!target) {
+ if (hasPendingResources())
+ return;
+
+ if (id.isEmpty())
+ requestImageResource();
+ else {
+ document()->accessSVGExtensions()->addPendingResource(id, this);
+ ASSERT(hasPendingResources());
+ }
+ }
- if (m_cachedImage)
- m_cachedImage->addClient(this);
+ invalidate();
}
bool SVGFEImageElement::isSupportedAttribute(const QualifiedName& attrName)
@@ -125,11 +132,8 @@ void SVGFEImageElement::parseMappedAttribute(Attribute* attr)
return;
}
- if (SVGURIReference::parseMappedAttribute(attr)) {
- requestImageResource();
+ if (SVGURIReference::parseMappedAttribute(attr))
return;
- }
-
if (SVGLangSpace::parseMappedAttribute(attr))
return;
if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
@@ -153,8 +157,7 @@ void SVGFEImageElement::svgAttributeChanged(const QualifiedName& attrName)
}
if (SVGURIReference::isKnownAttribute(attrName)) {
- invalidateImageResource();
- invalidate();
+ buildPendingResource();
return;
}
@@ -164,6 +167,18 @@ void SVGFEImageElement::svgAttributeChanged(const QualifiedName& attrName)
ASSERT_NOT_REACHED();
}
+void SVGFEImageElement::insertedIntoDocument()
+{
+ SVGFilterPrimitiveStandardAttributes::insertedIntoDocument();
+ buildPendingResource();
+}
+
+void SVGFEImageElement::removedFromDocument()
+{
+ SVGFilterPrimitiveStandardAttributes::removedFromDocument();
+ clearResourceReferences();
+}
+
void SVGFEImageElement::notifyFinished(CachedResource*)
{
if (!inDocument())
@@ -180,30 +195,9 @@ void SVGFEImageElement::notifyFinished(CachedResource*)
PassRefPtr<FilterEffect> SVGFEImageElement::build(SVGFilterBuilder*, Filter* filter)
{
- if (!m_cachedImage && !m_targetImage)
- requestImageResource();
-
- if (!m_cachedImage && !m_targetImage) {
- Element* hrefElement = SVGURIReference::targetElementFromIRIString(href(), document());
- if (!hrefElement || !hrefElement->isSVGElement())
- return 0;
-
- RenderObject* renderer = hrefElement->renderer();
- if (!renderer)
- return 0;
-
- IntRect targetRect = enclosingIntRect(renderer->objectBoundingBox());
-
- if (targetRect.isEmpty())
- return 0;
-
- m_targetImage = ImageBuffer::create(targetRect.size(), ColorSpaceLinearRGB);
-
- AffineTransform contentTransformation;
- SVGImageBufferTools::renderSubtreeToImageBuffer(m_targetImage.get(), renderer, contentTransformation);
- }
-
- return FEImage::create(filter, m_targetImage ? m_targetImage->copyImage(CopyBackingStore) : m_cachedImage->imageForRenderer(renderer()), preserveAspectRatio());
+ if (m_cachedImage)
+ return FEImage::createWithImage(filter, m_cachedImage->imageForRenderer(renderer()), preserveAspectRatio());
+ return FEImage::createWithIRIReference(filter, document(), href(), preserveAspectRatio());
}
void SVGFEImageElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const