File indexing completed on 2024-04-28 15:24:43
0001 /* 0002 Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 0003 2004, 2005, 2006 Rob Buis <buis@kde.org> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Library General Public 0007 License as published by the Free Software Foundation; either 0008 version 2 of the License, or (at your option) any later version. 0009 0010 This library is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 Library General Public License for more details. 0014 0015 You should have received a copy of the GNU Library General Public License 0016 along with this library; see the file COPYING.LIB. If not, write to 0017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #include "wtf/Platform.h" 0022 0023 #if ENABLE(SVG) 0024 #include "SVGURIReference.h" 0025 0026 #include "SVGNames.h" 0027 #include "SVGStyledElement.h" 0028 #include "XLinkNames.h" 0029 0030 namespace WebCore 0031 { 0032 0033 SVGURIReference::SVGURIReference() 0034 { 0035 } 0036 0037 SVGURIReference::~SVGURIReference() 0038 { 0039 } 0040 0041 ANIMATED_PROPERTY_DEFINITIONS_WITH_CONTEXT(SVGURIReference, String, String, string, Href, href, XLinkNames::hrefAttr, m_href) 0042 0043 bool SVGURIReference::parseMappedAttribute(MappedAttribute *attr) 0044 { 0045 // qCDebug(KHTML_LOG) << "parse" << attr->localName() << attr->value(); 0046 if (attr->id() == ATTR_XLINK_HREF) { 0047 // qCDebug(KHTML_LOG) << "set href base value" << attr->value(); 0048 setHrefBaseValue(attr->value()); 0049 return true; 0050 } 0051 0052 return false; 0053 } 0054 0055 bool SVGURIReference::isKnownAttribute(const QualifiedName &attrName) 0056 { 0057 return attrName.matches(XLinkNames::hrefAttr); 0058 } 0059 0060 String SVGURIReference::getTarget(const String &url) 0061 { 0062 if (url.startsWith("url(")) { // URI References, ie. fill:url(#target) 0063 unsigned int start = url.find('#') + 1; 0064 unsigned int end = url.reverseFind(')'); 0065 0066 return url.substring(start, end - start); 0067 } else if (url.find('#') > -1) { // format is #target 0068 unsigned int start = url.find('#') + 1; 0069 return url.substring(start, url.length() - start); 0070 } else { // Normal Reference, ie. style="color-profile:changeColor" 0071 return url; 0072 } 0073 } 0074 0075 } 0076 0077 #endif // ENABLE(SVG)