KHTML
SVGURIReference.cpp
Go to the documentation of this file.
00001 /* 00002 Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 00003 2004, 2005, 2006 Rob Buis <buis@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #include "config.h" 00022 #include "wtf/Platform.h" 00023 00024 #if ENABLE(SVG) 00025 #include "SVGURIReference.h" 00026 00027 #include "SVGNames.h" 00028 #include "SVGStyledElement.h" 00029 #include "XLinkNames.h" 00030 00031 namespace WebCore { 00032 00033 SVGURIReference::SVGURIReference() 00034 { 00035 } 00036 00037 SVGURIReference::~SVGURIReference() 00038 { 00039 } 00040 00041 ANIMATED_PROPERTY_DEFINITIONS_WITH_CONTEXT(SVGURIReference, String, String, string, Href, href, XLinkNames::hrefAttr, m_href) 00042 00043 bool SVGURIReference::parseMappedAttribute(MappedAttribute* attr) 00044 { 00045 kDebug() << "parse" << attr->localName() << attr->value() << endl; 00046 if (attr->id() == ATTR_XLINK_HREF) { 00047 kDebug() << "set href base value" << attr->value() << endl; 00048 setHrefBaseValue(attr->value()); 00049 return true; 00050 } 00051 00052 return false; 00053 } 00054 00055 bool SVGURIReference::isKnownAttribute(const QualifiedName& attrName) 00056 { 00057 return attrName.matches(XLinkNames::hrefAttr); 00058 } 00059 00060 String SVGURIReference::getTarget(const String& url) 00061 { 00062 if (url.startsWith("url(")) { // URI References, ie. fill:url(#target) 00063 unsigned int start = url.find('#') + 1; 00064 unsigned int end = url.reverseFind(')'); 00065 00066 return url.substring(start, end - start); 00067 } else if (url.find('#') > -1) { // format is #target 00068 unsigned int start = url.find('#') + 1; 00069 return url.substring(start, url.length() - start); 00070 } else // Normal Reference, ie. style="color-profile:changeColor" 00071 return url; 00072 } 00073 00074 } 00075 00076 #endif // ENABLE(SVG)
KDE 4.6 API Reference