KHTML
SVGFEImageElement.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "config.h"
00024
00025 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
00026 #include "SVGFEImageElement.h"
00027
00028 #include "Attr.h"
00029 #include "CachedImage.h"
00030 #include "DocLoader.h"
00031 #include "Document.h"
00032 #include "SVGLength.h"
00033 #include "SVGNames.h"
00034 #include "SVGPreserveAspectRatio.h"
00035 #include "SVGResourceFilter.h"
00036
00037 namespace WebCore {
00038
00039 SVGFEImageElement::SVGFEImageElement(const QualifiedName& tagName, Document* doc)
00040 : SVGFilterPrimitiveStandardAttributes(tagName, doc)
00041 , SVGURIReference()
00042 , SVGLangSpace()
00043 , SVGExternalResourcesRequired()
00044 , m_preserveAspectRatio(SVGPreserveAspectRatio::create())
00045 , m_cachedImage(0)
00046 , m_filterEffect(0)
00047 {
00048 }
00049
00050 SVGFEImageElement::~SVGFEImageElement()
00051 {
00052 delete m_filterEffect;
00053 if (m_cachedImage)
00054 m_cachedImage->removeClient(this);
00055 }
00056
00057 ANIMATED_PROPERTY_DEFINITIONS(SVGFEImageElement, SVGPreserveAspectRatio*, PreserveAspectRatio, preserveAspectRatio, PreserveAspectRatio, preserveAspectRatio, SVGNames::preserveAspectRatioAttr, m_preserveAspectRatio.get())
00058
00059 void SVGFEImageElement::parseMappedAttribute(MappedAttribute* attr)
00060 {
00061 const String& value = attr->value();
00062 if (attr->name() == SVGNames::preserveAspectRatioAttr) {
00063 const UChar* c = value.characters();
00064 const UChar* end = c + value.length();
00065 preserveAspectRatioBaseValue()->parsePreserveAspectRatio(c, end);
00066 } else {
00067 if (SVGURIReference::parseMappedAttribute(attr)) {
00068 if (!href().startsWith("#")) {
00069
00070 if (m_cachedImage)
00071 m_cachedImage->removeClient(this);
00072 m_cachedImage = ownerDocument()->docLoader()->requestImage(href());
00073 if (m_cachedImage)
00074 m_cachedImage->addClient(this);
00075 }
00076 return;
00077 }
00078 if (SVGLangSpace::parseMappedAttribute(attr))
00079 return;
00080 if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
00081 return;
00082
00083 SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
00084 }
00085 }
00086
00087 void SVGFEImageElement::notifyFinished(CachedResource* finishedObj)
00088 {
00089 if (finishedObj == m_cachedImage && m_filterEffect)
00090 m_filterEffect->setCachedImage(m_cachedImage);
00091 }
00092
00093 SVGFEImage* SVGFEImageElement::filterEffect(SVGResourceFilter* filter) const
00094 {
00095 if (!m_filterEffect)
00096 m_filterEffect = new SVGFEImage(filter);
00097
00098
00099 if (m_cachedImage)
00100 m_filterEffect->setCachedImage(m_cachedImage);
00101
00102 setStandardAttributes(m_filterEffect);
00103 return m_filterEffect;
00104 }
00105
00106 void SVGFEImageElement::getSubresourceAttributeStrings(Vector<String>& urls) const
00107 {
00108 urls.append(href());
00109 }
00110
00111 }
00112
00113 #endif // ENABLE(SVG)
00114
00115