| 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/ImageResourceContent.h" |
| 28 #include "core/fetch/ResourceFetcher.h" | 28 #include "core/fetch/ResourceFetcher.h" |
| 29 #include "core/frame/Settings.h" | 29 #include "core/frame/Settings.h" |
| 30 #include "core/style/StyleFetchedImage.h" | 30 #include "core/style/StyleFetchedImage.h" |
| 31 #include "core/style/StyleInvalidImage.h" | 31 #include "core/style/StyleInvalidImage.h" |
| 32 #include "platform/CrossOriginAttributeValue.h" | 32 #include "platform/CrossOriginAttributeValue.h" |
| 33 #include "platform/weborigin/KURL.h" | 33 #include "platform/weborigin/KURL.h" |
| 34 #include "platform/weborigin/SecurityPolicy.h" | 34 #include "platform/weborigin/SecurityPolicy.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 60 request.mutableResourceRequest().setHTTPReferrer( | 60 request.mutableResourceRequest().setHTTPReferrer( |
| 61 SecurityPolicy::generateReferrer(m_referrer.referrerPolicy, | 61 SecurityPolicy::generateReferrer(m_referrer.referrerPolicy, |
| 62 request.url(), m_referrer.referrer)); | 62 request.url(), m_referrer.referrer)); |
| 63 | 63 |
| 64 if (crossOrigin != CrossOriginAttributeNotSet) | 64 if (crossOrigin != CrossOriginAttributeNotSet) |
| 65 request.setCrossOriginAccessControl(document.getSecurityOrigin(), | 65 request.setCrossOriginAccessControl(document.getSecurityOrigin(), |
| 66 crossOrigin); | 66 crossOrigin); |
| 67 if (document.settings() && document.settings()->fetchImagePlaceholders()) | 67 if (document.settings() && document.settings()->fetchImagePlaceholders()) |
| 68 request.setAllowImagePlaceholder(); | 68 request.setAllowImagePlaceholder(); |
| 69 | 69 |
| 70 if (ImageResource* cachedImage = | 70 if (ImageResourceContent* cachedImage = |
| 71 ImageResource::fetch(request, document.fetcher())) | 71 ImageResourceContent::fetch(request, document.fetcher())) |
| 72 m_cachedImage = | 72 m_cachedImage = |
| 73 StyleFetchedImage::create(cachedImage, document, request.url()); | 73 StyleFetchedImage::create(cachedImage, document, request.url()); |
| 74 else | 74 else |
| 75 m_cachedImage = StyleInvalidImage::create(url()); | 75 m_cachedImage = StyleInvalidImage::create(url()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 return m_cachedImage.get(); | 78 return m_cachedImage.get(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void CSSImageValue::restoreCachedResourceIfNeeded( | 81 void CSSImageValue::restoreCachedResourceIfNeeded( |
| 82 const Document& document) const { | 82 const Document& document) const { |
| 83 if (!m_cachedImage || !document.fetcher() || m_absoluteURL.isNull()) | 83 if (!m_cachedImage || !document.fetcher() || m_absoluteURL.isNull()) |
| 84 return; | 84 return; |
| 85 | 85 |
| 86 ImageResource* resource = m_cachedImage->cachedImage(); | 86 ImageResourceContent* resource = m_cachedImage->cachedImage(); |
| 87 if (!resource) | 87 if (!resource) |
| 88 return; | 88 return; |
| 89 | 89 |
| 90 document.fetcher()->emulateLoadStartedForInspector( | 90 resource->emulateLoadStartedForInspector( |
| 91 resource, KURL(ParsedURLString, m_absoluteURL), | 91 document.fetcher(), KURL(ParsedURLString, m_absoluteURL), |
| 92 WebURLRequest::RequestContextImage, | |
| 93 m_initiatorName.isEmpty() ? FetchInitiatorTypeNames::css | 92 m_initiatorName.isEmpty() ? FetchInitiatorTypeNames::css |
| 94 : m_initiatorName); | 93 : m_initiatorName); |
| 95 } | 94 } |
| 96 | 95 |
| 97 bool CSSImageValue::hasFailedOrCanceledSubresources() const { | 96 bool CSSImageValue::hasFailedOrCanceledSubresources() const { |
| 98 if (!m_cachedImage) | 97 if (!m_cachedImage) |
| 99 return false; | 98 return false; |
| 100 if (Resource* cachedResource = m_cachedImage->cachedImage()) | 99 if (ImageResourceContent* cachedResource = m_cachedImage->cachedImage()) |
| 101 return cachedResource->loadFailedOrCanceled(); | 100 return cachedResource->loadFailedOrCanceled(); |
| 102 return true; | 101 return true; |
| 103 } | 102 } |
| 104 | 103 |
| 105 bool CSSImageValue::equals(const CSSImageValue& other) const { | 104 bool CSSImageValue::equals(const CSSImageValue& other) const { |
| 106 return m_absoluteURL == other.m_absoluteURL; | 105 return m_absoluteURL == other.m_absoluteURL; |
| 107 } | 106 } |
| 108 | 107 |
| 109 String CSSImageValue::customCSSText() const { | 108 String CSSImageValue::customCSSText() const { |
| 110 return serializeURI(m_relativeURL); | 109 return serializeURI(m_relativeURL); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 122 void CSSImageValue::reResolveURL(const Document& document) const { | 121 void CSSImageValue::reResolveURL(const Document& document) const { |
| 123 KURL url = document.completeURL(m_relativeURL); | 122 KURL url = document.completeURL(m_relativeURL); |
| 124 AtomicString urlString(url.getString()); | 123 AtomicString urlString(url.getString()); |
| 125 if (urlString == m_absoluteURL) | 124 if (urlString == m_absoluteURL) |
| 126 return; | 125 return; |
| 127 m_absoluteURL = urlString; | 126 m_absoluteURL = urlString; |
| 128 m_cachedImage.clear(); | 127 m_cachedImage.clear(); |
| 129 } | 128 } |
| 130 | 129 |
| 131 } // namespace blink | 130 } // namespace blink |
| OLD | NEW |