KHTML
SVGFEImageElement.cpp
Go to the documentation of this file.
00001 /* 00002 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 00003 2004, 2005 Rob Buis <buis@kde.org> 00004 00005 This file is part of the KDE project 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 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 // FIXME: this code needs to special-case url fragments and later look them up using getElementById instead of loading them here 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 // The resource may already be loaded! 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 // vim:ts=4:noet
KDE 4.6 API Reference