OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/css/CSSURIValue.h" | 5 #include "core/css/CSSURIValue.h" |
6 | 6 |
7 #include "core/css/CSSMarkup.h" | 7 #include "core/css/CSSMarkup.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/fetch/FetchInitiatorTypeNames.h" | 9 #include "core/svg/SVGElementProxy.h" |
10 #include "core/fetch/FetchRequest.h" | 10 #include "core/svg/SVGURIReference.h" |
11 #include "core/fetch/ResourceFetcher.h" | |
12 #include "wtf/text/WTFString.h" | |
13 | 11 |
14 namespace blink { | 12 namespace blink { |
15 | 13 |
16 CSSURIValue::CSSURIValue(const String& urlString) | 14 CSSURIValue::CSSURIValue(const String& urlString) |
17 : CSSValue(URIClass), m_url(urlString), m_loadRequested(false) {} | 15 : CSSValue(URIClass), m_url(urlString) {} |
18 | 16 |
19 CSSURIValue::~CSSURIValue() {} | 17 CSSURIValue::~CSSURIValue() {} |
20 | 18 |
21 DocumentResource* CSSURIValue::load(Document& document) const { | 19 SVGElementProxy& CSSURIValue::ensureElementProxy(Document& document) const { |
22 if (!m_loadRequested) { | 20 if (m_proxy) |
23 m_loadRequested = true; | 21 return *m_proxy; |
24 | 22 SVGURLReferenceResolver resolver(m_url, document); |
25 FetchRequest request(ResourceRequest(document.completeURL(m_url)), | 23 AtomicString fragmentId = resolver.fragmentIdentifier(); |
26 FetchInitiatorTypeNames::css); | 24 if (resolver.isLocal()) { |
27 m_document = | 25 m_proxy = SVGElementProxy::create(fragmentId); |
28 DocumentResource::fetchSVGDocument(request, document.fetcher()); | 26 } else { |
| 27 m_proxy = |
| 28 SVGElementProxy::create(resolver.absoluteUrl().getString(), fragmentId); |
29 } | 29 } |
30 return m_document; | 30 return *m_proxy; |
31 } | 31 } |
32 | 32 |
33 String CSSURIValue::customCSSText() const { | 33 String CSSURIValue::customCSSText() const { |
34 return serializeURI(m_url); | 34 return serializeURI(m_url); |
35 } | 35 } |
36 | 36 |
37 bool CSSURIValue::equals(const CSSURIValue& other) const { | 37 bool CSSURIValue::equals(const CSSURIValue& other) const { |
38 return m_url == other.m_url; | 38 return m_url == other.m_url; |
39 } | 39 } |
40 | 40 |
41 DEFINE_TRACE_AFTER_DISPATCH(CSSURIValue) { | 41 DEFINE_TRACE_AFTER_DISPATCH(CSSURIValue) { |
42 visitor->trace(m_document); | 42 visitor->trace(m_proxy); |
43 CSSValue::traceAfterDispatch(visitor); | 43 CSSValue::traceAfterDispatch(visitor); |
44 } | 44 } |
45 | 45 |
46 } // namespace blink | 46 } // namespace blink |
OLD | NEW |