| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 bool CSSImageSetValue::isCachePending(float deviceScaleFactor) const { | 91 bool CSSImageSetValue::isCachePending(float deviceScaleFactor) const { |
| 92 return !m_cachedImage || deviceScaleFactor != m_cachedScaleFactor; | 92 return !m_cachedImage || deviceScaleFactor != m_cachedScaleFactor; |
| 93 } | 93 } |
| 94 | 94 |
| 95 StyleImage* CSSImageSetValue::cachedImage(float deviceScaleFactor) const { | 95 StyleImage* CSSImageSetValue::cachedImage(float deviceScaleFactor) const { |
| 96 DCHECK(!isCachePending(deviceScaleFactor)); | 96 DCHECK(!isCachePending(deviceScaleFactor)); |
| 97 return m_cachedImage.get(); | 97 return m_cachedImage.get(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 StyleImage* CSSImageSetValue::cacheImage( | 100 StyleImage* CSSImageSetValue::cacheImage(const Document& document, |
| 101 const Document& document, | 101 float deviceScaleFactor, |
| 102 float deviceScaleFactor, | 102 CrossOriginAttributeValue crossOrigin, |
| 103 CrossOriginAttributeValue crossOrigin) { | 103 bool allowImagePlaceholder) { |
| 104 if (!m_imagesInSet.size()) | 104 if (!m_imagesInSet.size()) |
| 105 fillImageSet(); | 105 fillImageSet(); |
| 106 | 106 |
| 107 if (isCachePending(deviceScaleFactor)) { | 107 if (isCachePending(deviceScaleFactor)) { |
| 108 // FIXME: In the future, we want to take much more than deviceScaleFactor | 108 // FIXME: In the future, we want to take much more than deviceScaleFactor |
| 109 // into acount here. All forms of scale should be included: | 109 // into acount here. All forms of scale should be included: |
| 110 // Page::pageScaleFactor(), LocalFrame::pageZoomFactor(), and any CSS | 110 // Page::pageScaleFactor(), LocalFrame::pageZoomFactor(), and any CSS |
| 111 // transforms. https://bugs.webkit.org/show_bug.cgi?id=81698 | 111 // transforms. https://bugs.webkit.org/show_bug.cgi?id=81698 |
| 112 ImageWithScale image = bestImageForScaleFactor(deviceScaleFactor); | 112 ImageWithScale image = bestImageForScaleFactor(deviceScaleFactor); |
| 113 ResourceRequest resourceRequest(document.completeURL(image.imageURL)); | 113 ResourceRequest resourceRequest(document.completeURL(image.imageURL)); |
| 114 resourceRequest.setHTTPReferrer(image.referrer); | 114 resourceRequest.setHTTPReferrer(image.referrer); |
| 115 FetchRequest request(resourceRequest, FetchInitiatorTypeNames::css); | 115 FetchRequest request(resourceRequest, FetchInitiatorTypeNames::css); |
| 116 | 116 |
| 117 if (crossOrigin != CrossOriginAttributeNotSet) | 117 if (crossOrigin != CrossOriginAttributeNotSet) |
| 118 request.setCrossOriginAccessControl(document.getSecurityOrigin(), | 118 request.setCrossOriginAccessControl(document.getSecurityOrigin(), |
| 119 crossOrigin); | 119 crossOrigin); |
| 120 if (document.settings() && document.settings()->getFetchImagePlaceholders()) | 120 if (document.settings() && |
| 121 document.settings()->getFetchImagePlaceholders() && |
| 122 allowImagePlaceholder) |
| 121 request.setAllowImagePlaceholder(); | 123 request.setAllowImagePlaceholder(); |
| 122 | 124 |
| 123 if (ImageResourceContent* cachedImage = | 125 if (ImageResourceContent* cachedImage = |
| 124 ImageResourceContent::fetch(request, document.fetcher())) | 126 ImageResourceContent::fetch(request, document.fetcher())) |
| 125 m_cachedImage = StyleFetchedImageSet::create( | 127 m_cachedImage = StyleFetchedImageSet::create( |
| 126 cachedImage, image.scaleFactor, this, request.url()); | 128 cachedImage, image.scaleFactor, this, request.url()); |
| 127 else | 129 else |
| 128 m_cachedImage = StyleInvalidImage::create(image.imageURL); | 130 m_cachedImage = StyleInvalidImage::create(image.imageURL); |
| 129 m_cachedScaleFactor = deviceScaleFactor; | 131 m_cachedScaleFactor = deviceScaleFactor; |
| 130 } | 132 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 CSSImageSetValue* CSSImageSetValue::valueWithURLsMadeAbsolute() { | 180 CSSImageSetValue* CSSImageSetValue::valueWithURLsMadeAbsolute() { |
| 179 CSSImageSetValue* value = CSSImageSetValue::create(); | 181 CSSImageSetValue* value = CSSImageSetValue::create(); |
| 180 for (auto& item : *this) | 182 for (auto& item : *this) |
| 181 item->isImageValue() | 183 item->isImageValue() |
| 182 ? value->append(*toCSSImageValue(*item).valueWithURLMadeAbsolute()) | 184 ? value->append(*toCSSImageValue(*item).valueWithURLMadeAbsolute()) |
| 183 : value->append(*item); | 185 : value->append(*item); |
| 184 return value; | 186 return value; |
| 185 } | 187 } |
| 186 | 188 |
| 187 } // namespace blink | 189 } // namespace blink |
| OLD | NEW |