| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #include "core/svg/SVGURIReference.h" | 21 #include "core/svg/SVGURIReference.h" |
| 22 | 22 |
| 23 #include "core/XLinkNames.h" | 23 #include "core/XLinkNames.h" |
| 24 #include "core/html/parser/HTMLParserIdioms.h" | |
| 25 #include "core/svg/SVGElement.h" | 24 #include "core/svg/SVGElement.h" |
| 26 #include "platform/weborigin/KURL.h" | 25 #include "platform/weborigin/KURL.h" |
| 27 | 26 |
| 28 namespace blink { | 27 namespace blink { |
| 29 | 28 |
| 30 SVGURIReference::SVGURIReference(SVGElement* element) | 29 SVGURIReference::SVGURIReference(SVGElement* element) |
| 31 : m_href(SVGAnimatedHref::create(element)) | 30 : m_href(SVGAnimatedString::create(element, XLinkNames::hrefAttr, SVGString:
:create())) |
| 32 { | 31 { |
| 33 ASSERT(element); | 32 ASSERT(element); |
| 34 m_href->addToPropertyMap(element); | 33 element->addToPropertyMap(m_href); |
| 35 } | 34 } |
| 36 | 35 |
| 37 DEFINE_TRACE(SVGURIReference) | 36 DEFINE_TRACE(SVGURIReference) |
| 38 { | 37 { |
| 39 visitor->trace(m_href); | 38 visitor->trace(m_href); |
| 40 } | 39 } |
| 41 | 40 |
| 42 bool SVGURIReference::isKnownAttribute(const QualifiedName& attrName) | 41 bool SVGURIReference::isKnownAttribute(const QualifiedName& attrName) |
| 43 { | 42 { |
| 44 return SVGAnimatedHref::isKnownAttribute(attrName); | 43 return attrName.matches(XLinkNames::hrefAttr); |
| 45 } | |
| 46 | |
| 47 const AtomicString& SVGURIReference::legacyHrefString(const SVGElement& element) | |
| 48 { | |
| 49 if (element.hasAttribute(SVGNames::hrefAttr)) | |
| 50 return element.getAttribute(SVGNames::hrefAttr); | |
| 51 return element.getAttribute(XLinkNames::hrefAttr); | |
| 52 } | |
| 53 | |
| 54 KURL SVGURIReference::legacyHrefURL(const Document& document) const | |
| 55 { | |
| 56 return document.completeURL(stripLeadingAndTrailingHTMLSpaces(hrefString()))
; | |
| 57 } | 44 } |
| 58 | 45 |
| 59 AtomicString SVGURIReference::fragmentIdentifierFromIRIString(const String& url,
const TreeScope& treeScope) | 46 AtomicString SVGURIReference::fragmentIdentifierFromIRIString(const String& url,
const TreeScope& treeScope) |
| 60 { | 47 { |
| 61 size_t start = url.find('#'); | 48 size_t start = url.find('#'); |
| 62 if (start == kNotFound) | 49 if (start == kNotFound) |
| 63 return emptyAtom; | 50 return emptyAtom; |
| 64 | 51 |
| 65 const Document& document = treeScope.document(); | 52 const Document& document = treeScope.document(); |
| 66 KURL base = start ? KURL(document.baseURI(), url.substring(0, start)) : docu
ment.baseURI(); | 53 KURL base = start ? KURL(document.baseURI(), url.substring(0, start)) : docu
ment.baseURI(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } | 98 } |
| 112 | 99 |
| 113 // Exit early if the referenced url is external, and we have no externalDocu
ment given. | 100 // Exit early if the referenced url is external, and we have no externalDocu
ment given. |
| 114 if (isExternalURIReference(iri, document)) | 101 if (isExternalURIReference(iri, document)) |
| 115 return nullptr; | 102 return nullptr; |
| 116 | 103 |
| 117 return treeScope.getElementById(id); | 104 return treeScope.getElementById(id); |
| 118 } | 105 } |
| 119 | 106 |
| 120 } // namespace blink | 107 } // namespace blink |
| OLD | NEW |