| 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, |
| 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/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/frame/Settings.h" |
| 29 #include "core/loader/MixedContentChecker.h" | 30 #include "core/loader/MixedContentChecker.h" |
| 30 #include "core/style/StyleFetchedImage.h" | 31 #include "core/style/StyleFetchedImage.h" |
| 31 #include "core/style/StyleInvalidImage.h" | 32 #include "core/style/StyleInvalidImage.h" |
| 32 #include "platform/CrossOriginAttributeValue.h" | 33 #include "platform/CrossOriginAttributeValue.h" |
| 33 #include "platform/weborigin/KURL.h" | 34 #include "platform/weborigin/KURL.h" |
| 34 #include "platform/weborigin/SecurityPolicy.h" | 35 #include "platform/weborigin/SecurityPolicy.h" |
| 35 | 36 |
| 36 namespace blink { | 37 namespace blink { |
| 37 | 38 |
| 38 CSSImageValue::CSSImageValue(const AtomicString& rawValue, const KURL& url, Styl
eImage* image) | 39 CSSImageValue::CSSImageValue(const AtomicString& rawValue, const KURL& url, Styl
eImage* image) |
| 39 : CSSValue(ImageClass) | 40 : CSSValue(ImageClass) |
| 40 , m_relativeURL(rawValue) | 41 , m_relativeURL(rawValue) |
| 41 , m_absoluteURL(url.getString()) | 42 , m_absoluteURL(url.getString()) |
| 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 { | 51 { |
| 51 } | 52 } |
| 52 | 53 |
| 53 CSSImageValue::~CSSImageValue() | 54 CSSImageValue::~CSSImageValue() |
| 54 { | 55 { |
| 55 } | 56 } |
| 56 | 57 |
| 57 StyleImage* CSSImageValue::cacheImage(const Document& document, CrossOriginAttri
buteValue crossOrigin) | 58 StyleImage* CSSImageValue::cacheImage(const Document& document, CrossOriginAttri
buteValue crossOrigin, ImageResource::PlaceholderRequestType placeholderRequestT
ype) |
| 58 { | 59 { |
| 59 if (!m_cachedImage) { | 60 if (!m_cachedImage) { |
| 60 FetchRequest request(ResourceRequest(m_absoluteURL), m_initiatorName.isE
mpty() ? FetchInitiatorTypeNames::css : m_initiatorName); | 61 FetchRequest request(ResourceRequest(m_absoluteURL), m_initiatorName.isE
mpty() ? FetchInitiatorTypeNames::css : m_initiatorName); |
| 61 request.mutableResourceRequest().setHTTPReferrer(SecurityPolicy::generat
eReferrer(m_referrer.referrerPolicy, request.url(), m_referrer.referrer)); | 62 request.mutableResourceRequest().setHTTPReferrer(SecurityPolicy::generat
eReferrer(m_referrer.referrerPolicy, request.url(), m_referrer.referrer)); |
| 62 | 63 |
| 63 if (crossOrigin != CrossOriginAttributeNotSet) | 64 if (crossOrigin != CrossOriginAttributeNotSet) |
| 64 request.setCrossOriginAccessControl(document.getSecurityOrigin(), cr
ossOrigin); | 65 request.setCrossOriginAccessControl(document.getSecurityOrigin(), cr
ossOrigin); |
| 65 | 66 |
| 66 if (ImageResource* cachedImage = ImageResource::fetch(request, document.
fetcher())) | 67 if (ImageResource* cachedImage = ImageResource::fetch(request, document.
fetcher(), placeholderRequestType)) |
| 67 m_cachedImage = StyleFetchedImage::create(cachedImage, document, req
uest.url()); | 68 m_cachedImage = StyleFetchedImage::create(cachedImage, document, req
uest.url()); |
| 68 else | 69 else |
| 69 m_cachedImage = StyleInvalidImage::create(url()); | 70 m_cachedImage = StyleInvalidImage::create(url()); |
| 70 } | 71 } |
| 71 | 72 |
| 72 return m_cachedImage.get(); | 73 return m_cachedImage.get(); |
| 73 } | 74 } |
| 74 | 75 |
| 75 void CSSImageValue::restoreCachedResourceIfNeeded(const Document& document) cons
t | 76 void CSSImageValue::restoreCachedResourceIfNeeded(const Document& document) cons
t |
| 76 { | 77 { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 { | 125 { |
| 125 KURL url = document.completeURL(m_relativeURL); | 126 KURL url = document.completeURL(m_relativeURL); |
| 126 AtomicString urlString(url.getString()); | 127 AtomicString urlString(url.getString()); |
| 127 if (urlString == m_absoluteURL) | 128 if (urlString == m_absoluteURL) |
| 128 return; | 129 return; |
| 129 m_absoluteURL = urlString; | 130 m_absoluteURL = urlString; |
| 130 m_cachedImage.clear(); | 131 m_cachedImage.clear(); |
| 131 } | 132 } |
| 132 | 133 |
| 133 } // namespace blink | 134 } // namespace blink |
| OLD | NEW |