| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. |
| 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 10 matching lines...) Expand all Loading... |
| 21 #include "core/css/CSSImageValue.h" | 21 #include "core/css/CSSImageValue.h" |
| 22 | 22 |
| 23 #include "core/css/CSSMarkup.h" | 23 #include "core/css/CSSMarkup.h" |
| 24 #include "core/dom/Document.h" | 24 #include "core/dom/Document.h" |
| 25 #include "core/fetch/FetchInitiatorTypeNames.h" | 25 #include "core/fetch/FetchInitiatorTypeNames.h" |
| 26 #include "core/fetch/FetchRequest.h" | 26 #include "core/fetch/FetchRequest.h" |
| 27 #include "core/fetch/ImageResource.h" | 27 #include "core/fetch/ImageResource.h" |
| 28 #include "core/fetch/ResourceFetcher.h" | 28 #include "core/fetch/ResourceFetcher.h" |
| 29 #include "core/loader/MixedContentChecker.h" | 29 #include "core/loader/MixedContentChecker.h" |
| 30 #include "core/style/StyleFetchedImage.h" | 30 #include "core/style/StyleFetchedImage.h" |
| 31 #include "core/style/StyleInvalidImage.h" |
| 31 #include "platform/CrossOriginAttributeValue.h" | 32 #include "platform/CrossOriginAttributeValue.h" |
| 32 #include "platform/weborigin/KURL.h" | 33 #include "platform/weborigin/KURL.h" |
| 33 #include "platform/weborigin/SecurityPolicy.h" | 34 #include "platform/weborigin/SecurityPolicy.h" |
| 34 | 35 |
| 35 namespace blink { | 36 namespace blink { |
| 36 | 37 |
| 37 CSSImageValue::CSSImageValue(const AtomicString& rawValue, const KURL& url, Styl
eFetchedImage* image) | 38 CSSImageValue::CSSImageValue(const AtomicString& rawValue, const KURL& url, Styl
eImage* image) |
| 38 : CSSValue(ImageClass) | 39 : CSSValue(ImageClass) |
| 39 , m_relativeURL(rawValue) | 40 , m_relativeURL(rawValue) |
| 40 , m_absoluteURL(url.getString()) | 41 , m_absoluteURL(url.getString()) |
| 41 , m_isCachePending(!image) | 42 , m_isCachePending(!image) |
| 42 , m_cachedImage(image) | 43 , m_cachedImage(image) |
| 43 { | 44 { |
| 44 } | 45 } |
| 45 | 46 |
| 46 CSSImageValue::CSSImageValue(const AtomicString& absoluteURL) | 47 CSSImageValue::CSSImageValue(const AtomicString& absoluteURL) |
| 47 : CSSValue(ImageClass) | 48 : CSSValue(ImageClass) |
| 48 , m_relativeURL(absoluteURL) | 49 , m_relativeURL(absoluteURL) |
| 49 , m_absoluteURL(absoluteURL) | 50 , m_absoluteURL(absoluteURL) |
| 50 , m_isCachePending(true) | 51 , m_isCachePending(true) |
| 51 { | 52 { |
| 52 } | 53 } |
| 53 | 54 |
| 54 CSSImageValue::~CSSImageValue() | 55 CSSImageValue::~CSSImageValue() |
| 55 { | 56 { |
| 56 } | 57 } |
| 57 | 58 |
| 58 StyleFetchedImage* CSSImageValue::cacheImage(Document* document, CrossOriginAttr
ibuteValue crossOrigin) | 59 StyleImage* CSSImageValue::cacheImage(Document* document, CrossOriginAttributeVa
lue crossOrigin) |
| 59 { | 60 { |
| 60 ASSERT(document); | 61 ASSERT(document); |
| 61 | 62 |
| 62 if (m_isCachePending) { | 63 if (m_isCachePending) { |
| 63 m_isCachePending = false; | 64 m_isCachePending = false; |
| 64 | 65 |
| 65 FetchRequest request(ResourceRequest(m_absoluteURL), m_initiatorName.isE
mpty() ? FetchInitiatorTypeNames::css : m_initiatorName); | 66 FetchRequest request(ResourceRequest(m_absoluteURL), m_initiatorName.isE
mpty() ? FetchInitiatorTypeNames::css : m_initiatorName); |
| 66 request.mutableResourceRequest().setHTTPReferrer(SecurityPolicy::generat
eReferrer(m_referrer.referrerPolicy, request.url(), m_referrer.referrer)); | 67 request.mutableResourceRequest().setHTTPReferrer(SecurityPolicy::generat
eReferrer(m_referrer.referrerPolicy, request.url(), m_referrer.referrer)); |
| 67 | 68 |
| 68 if (crossOrigin != CrossOriginAttributeNotSet) | 69 if (crossOrigin != CrossOriginAttributeNotSet) |
| 69 request.setCrossOriginAccessControl(document->getSecurityOrigin(), c
rossOrigin); | 70 request.setCrossOriginAccessControl(document->getSecurityOrigin(), c
rossOrigin); |
| 70 | 71 |
| 71 if (RawPtr<ImageResource> cachedImage = ImageResource::fetch(request, do
cument->fetcher())) | 72 if (RawPtr<ImageResource> cachedImage = ImageResource::fetch(request, do
cument->fetcher())) |
| 72 m_cachedImage = StyleFetchedImage::create(cachedImage.get(), documen
t, request.url()); | 73 m_cachedImage = StyleFetchedImage::create(cachedImage.get(), documen
t, request.url()); |
| 74 else |
| 75 m_cachedImage = StyleInvalidImage::create(url()); |
| 73 } | 76 } |
| 74 | 77 |
| 75 return m_cachedImage.get(); | 78 return m_cachedImage.get(); |
| 76 } | 79 } |
| 77 | 80 |
| 78 void CSSImageValue::restoreCachedResourceIfNeeded(Document& document) const | 81 void CSSImageValue::restoreCachedResourceIfNeeded(Document& document) const |
| 79 { | 82 { |
| 80 if (m_isCachePending || !m_cachedImage || !document.fetcher()) | 83 if (m_isCachePending || !m_cachedImage || !document.fetcher()) |
| 81 return; | 84 return; |
| 82 if (document.fetcher()->cachedResource(KURL(ParsedURLString, m_absoluteURL))
) | 85 if (document.fetcher()->cachedResource(KURL(ParsedURLString, m_absoluteURL))
) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 KURL url = document.completeURL(m_relativeURL); | 130 KURL url = document.completeURL(m_relativeURL); |
| 128 AtomicString urlString(url.getString()); | 131 AtomicString urlString(url.getString()); |
| 129 if (urlString == m_absoluteURL) | 132 if (urlString == m_absoluteURL) |
| 130 return; | 133 return; |
| 131 m_absoluteURL = urlString; | 134 m_absoluteURL = urlString; |
| 132 m_isCachePending = true; | 135 m_isCachePending = true; |
| 133 m_cachedImage.clear(); | 136 m_cachedImage.clear(); |
| 134 } | 137 } |
| 135 | 138 |
| 136 } // namespace blink | 139 } // namespace blink |
| OLD | NEW |