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, |
(...skipping 24 matching lines...) Expand all Loading... |
35 } | 35 } |
36 | 36 |
37 return false; | 37 return false; |
38 } | 38 } |
39 | 39 |
40 bool SVGURIReference::isKnownAttribute(const QualifiedName& attrName) | 40 bool SVGURIReference::isKnownAttribute(const QualifiedName& attrName) |
41 { | 41 { |
42 return attrName.matches(XLinkNames::hrefAttr); | 42 return attrName.matches(XLinkNames::hrefAttr); |
43 } | 43 } |
44 | 44 |
45 String SVGURIReference::fragmentIdentifierFromIRIString(const String& url, const
Document& document) | 45 AtomicString SVGURIReference::fragmentIdentifierFromIRIString(const String& url,
const Document& document) |
46 { | 46 { |
47 size_t start = url.find('#'); | 47 size_t start = url.find('#'); |
48 if (start == kNotFound) | 48 if (start == kNotFound) |
49 return emptyString(); | 49 return emptyAtom; |
50 | 50 |
51 KURL base = start ? KURL(document.baseURI(), url.substring(0, start)) : docu
ment.baseURI(); | 51 KURL base = start ? KURL(document.baseURI(), url.substring(0, start)) : docu
ment.baseURI(); |
52 if (equalIgnoringFragmentIdentifier(base, document.url())) | 52 if (equalIgnoringFragmentIdentifier(base, document.url())) |
53 return url.substring(start + 1); | 53 return AtomicString(url.substring(start + 1)); |
54 | 54 |
55 return emptyString(); | 55 return emptyAtom; |
56 } | 56 } |
57 | 57 |
58 static inline KURL urlFromIRIStringWithFragmentIdentifier(const String& url, con
st Document& document, String& fragmentIdentifier) | 58 static inline KURL urlFromIRIStringWithFragmentIdentifier(const String& url, con
st Document& document, AtomicString& fragmentIdentifier) |
59 { | 59 { |
60 size_t startOfFragmentIdentifier = url.find('#'); | 60 size_t startOfFragmentIdentifier = url.find('#'); |
61 if (startOfFragmentIdentifier == kNotFound) | 61 if (startOfFragmentIdentifier == kNotFound) |
62 return KURL(); | 62 return KURL(); |
63 | 63 |
64 // Exclude the '#' character when determining the fragmentIdentifier. | 64 // Exclude the '#' character when determining the fragmentIdentifier. |
65 fragmentIdentifier = url.substring(startOfFragmentIdentifier + 1); | 65 fragmentIdentifier = AtomicString(url.substring(startOfFragmentIdentifier +
1)); |
66 if (startOfFragmentIdentifier) { | 66 if (startOfFragmentIdentifier) { |
67 KURL base(document.baseURI(), url.substring(0, startOfFragmentIdentifier
)); | 67 KURL base(document.baseURI(), url.substring(0, startOfFragmentIdentifier
)); |
68 return KURL(base, url.substring(startOfFragmentIdentifier)); | 68 return KURL(base, url.substring(startOfFragmentIdentifier)); |
69 } | 69 } |
70 | 70 |
71 return KURL(document.baseURI(), url.substring(startOfFragmentIdentifier)); | 71 return KURL(document.baseURI(), url.substring(startOfFragmentIdentifier)); |
72 } | 72 } |
73 | 73 |
74 Element* SVGURIReference::targetElementFromIRIString(const String& iri, const Do
cument& document, String* fragmentIdentifier, Document* externalDocument) | 74 Element* SVGURIReference::targetElementFromIRIString(const String& iri, const Do
cument& document, AtomicString* fragmentIdentifier, Document* externalDocument) |
75 { | 75 { |
76 // If there's no fragment identifier contained within the IRI string, we can
't lookup an element. | 76 // If there's no fragment identifier contained within the IRI string, we can
't lookup an element. |
77 String id; | 77 AtomicString id; |
78 KURL url = urlFromIRIStringWithFragmentIdentifier(iri, document, id); | 78 KURL url = urlFromIRIStringWithFragmentIdentifier(iri, document, id); |
79 if (url == KURL()) | 79 if (url == KURL()) |
80 return 0; | 80 return 0; |
81 | 81 |
82 if (fragmentIdentifier) | 82 if (fragmentIdentifier) |
83 *fragmentIdentifier = id; | 83 *fragmentIdentifier = id; |
84 | 84 |
85 if (id.isEmpty()) | 85 if (id.isEmpty()) |
86 return 0; | 86 return 0; |
87 | 87 |
88 if (externalDocument) { | 88 if (externalDocument) { |
89 // Enforce that the referenced url matches the url of the document that
we've loaded for it! | 89 // Enforce that the referenced url matches the url of the document that
we've loaded for it! |
90 ASSERT(equalIgnoringFragmentIdentifier(url, externalDocument->url())); | 90 ASSERT(equalIgnoringFragmentIdentifier(url, externalDocument->url())); |
91 return externalDocument->getElementById(id); | 91 return externalDocument->getElementById(id); |
92 } | 92 } |
93 | 93 |
94 // Exit early if the referenced url is external, and we have no externalDocu
ment given. | 94 // Exit early if the referenced url is external, and we have no externalDocu
ment given. |
95 if (isExternalURIReference(iri, document)) | 95 if (isExternalURIReference(iri, document)) |
96 return 0; | 96 return 0; |
97 | 97 |
98 return document.getElementById(id); | 98 return document.getElementById(id); |
99 } | 99 } |
100 | 100 |
101 void SVGURIReference::addSupportedAttributes(HashSet<QualifiedName>& supportedAt
tributes) | 101 void SVGURIReference::addSupportedAttributes(HashSet<QualifiedName>& supportedAt
tributes) |
102 { | 102 { |
103 supportedAttributes.add(XLinkNames::hrefAttr); | 103 supportedAttributes.add(XLinkNames::hrefAttr); |
104 } | 104 } |
105 | 105 |
106 } | 106 } |
OLD | NEW |