KHTML
SVGURIReference.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 #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->localName() == "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(")) {
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) {
00068 unsigned int start = url.find('#') + 1;
00069 return url.substring(start, url.length() - start);
00070 } else
00071 return url;
00072 }
00073
00074 }
00075
00076 #endif // ENABLE(SVG)