Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Unified Diff: third_party/WebKit/Source/core/svg/SVGURIReference.h

Issue 2174833002: Make fragment-only URLs always be document-local references (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove isExternal...; add additional test Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/svg/SVGURIReference.h
diff --git a/third_party/WebKit/Source/core/svg/SVGURIReference.h b/third_party/WebKit/Source/core/svg/SVGURIReference.h
index 97248ec0c9c9b00a9e88cd16a08ff514fdc8050e..0bf7ddccfa099136187d83de802de383f60a604c 100644
--- a/third_party/WebKit/Source/core/svg/SVGURIReference.h
+++ b/third_party/WebKit/Source/core/svg/SVGURIReference.h
@@ -48,18 +48,6 @@ public:
static AtomicString fragmentIdentifierFromIRIString(const String&, const TreeScope&);
static Element* targetElementFromIRIString(const String&, const TreeScope&, AtomicString* = nullptr);
- static inline bool isExternalURIReference(const String& uri, const Document& document)
- {
- // Fragment-only URIs are always internal if the baseURL is same as the document URL.
- // This is common case, so check that first to avoid resolving URL (which is relatively expensive). See crbug.com/557979
- if (document.baseURL() == document.url() && uri.startsWith('#'))
- return false;
-
- // If the URI matches our documents URL, we're dealing with a local reference.
- KURL url = document.completeURL(uri);
- return !equalIgnoringFragmentIdentifier(url, document.url());
- }
-
const String& hrefString() const { return m_href->currentValue()->value(); }
// JS API
@@ -74,6 +62,24 @@ private:
Member<SVGAnimatedHref> m_href;
};
+// Helper class used to resolve fragment references. Handles the 'local url
+// flag' per https://drafts.csswg.org/css-values/#local-urls .
+class SVGURLReferenceResolver {
+ STACK_ALLOCATED();
+public:
+ SVGURLReferenceResolver(const String& urlString, const Document&);
+
+ bool isLocal() const;
+ KURL absoluteUrl() const;
+ AtomicString fragmentIdentifier() const;
+
+private:
+ const String& m_relativeUrl;
+ Member<const Document> m_document;
+ mutable KURL m_absoluteUrl;
+ bool m_isLocal;
+};
+
} // namespace blink
#endif // SVGURIReference_h

Powered by Google App Engine
This is Rietveld 408576698