| 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 15 matching lines...) Expand all Loading... |
| 26 #include "core/css/CSSImageSetValue.h" | 26 #include "core/css/CSSImageSetValue.h" |
| 27 | 27 |
| 28 #include "core/css/CSSImageValue.h" | 28 #include "core/css/CSSImageValue.h" |
| 29 #include "core/css/CSSPrimitiveValue.h" | 29 #include "core/css/CSSPrimitiveValue.h" |
| 30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
| 31 #include "core/fetch/FetchInitiatorTypeNames.h" | 31 #include "core/fetch/FetchInitiatorTypeNames.h" |
| 32 #include "core/fetch/FetchRequest.h" | 32 #include "core/fetch/FetchRequest.h" |
| 33 #include "core/fetch/ImageResource.h" | 33 #include "core/fetch/ImageResource.h" |
| 34 #include "core/fetch/ResourceFetcher.h" | 34 #include "core/fetch/ResourceFetcher.h" |
| 35 #include "core/fetch/ResourceLoaderOptions.h" | 35 #include "core/fetch/ResourceLoaderOptions.h" |
| 36 #include "core/frame/Settings.h" |
| 36 #include "core/style/StyleFetchedImageSet.h" | 37 #include "core/style/StyleFetchedImageSet.h" |
| 37 #include "core/style/StyleInvalidImage.h" | 38 #include "core/style/StyleInvalidImage.h" |
| 38 #include "platform/weborigin/KURL.h" | 39 #include "platform/weborigin/KURL.h" |
| 39 #include "platform/weborigin/SecurityPolicy.h" | 40 #include "platform/weborigin/SecurityPolicy.h" |
| 40 #include "wtf/text/StringBuilder.h" | 41 #include "wtf/text/StringBuilder.h" |
| 41 #include <algorithm> | 42 #include <algorithm> |
| 42 | 43 |
| 43 namespace blink { | 44 namespace blink { |
| 44 | 45 |
| 45 CSSImageSetValue::CSSImageSetValue() | 46 CSSImageSetValue::CSSImageSetValue() |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 { | 94 { |
| 94 return !m_cachedImage || deviceScaleFactor != m_cachedScaleFactor; | 95 return !m_cachedImage || deviceScaleFactor != m_cachedScaleFactor; |
| 95 } | 96 } |
| 96 | 97 |
| 97 StyleImage* CSSImageSetValue::cachedImage(float deviceScaleFactor) const | 98 StyleImage* CSSImageSetValue::cachedImage(float deviceScaleFactor) const |
| 98 { | 99 { |
| 99 ASSERT(!isCachePending(deviceScaleFactor)); | 100 ASSERT(!isCachePending(deviceScaleFactor)); |
| 100 return m_cachedImage.get(); | 101 return m_cachedImage.get(); |
| 101 } | 102 } |
| 102 | 103 |
| 103 StyleImage* CSSImageSetValue::cacheImage(const Document& document, float deviceS
caleFactor, CrossOriginAttributeValue crossOrigin) | 104 StyleImage* CSSImageSetValue::cacheImage(const Document& document, float deviceS
caleFactor, CrossOriginAttributeValue crossOrigin, ImageResource::PlaceholderReq
uestType placeholderRequestType) |
| 104 { | 105 { |
| 105 if (!m_imagesInSet.size()) | 106 if (!m_imagesInSet.size()) |
| 106 fillImageSet(); | 107 fillImageSet(); |
| 107 | 108 |
| 108 if (isCachePending(deviceScaleFactor)) { | 109 if (isCachePending(deviceScaleFactor)) { |
| 109 // FIXME: In the future, we want to take much more than deviceScaleFacto
r into acount here. | 110 // FIXME: In the future, we want to take much more than deviceScaleFacto
r into acount here. |
| 110 // All forms of scale should be included: Page::pageScaleFactor(), Local
Frame::pageZoomFactor(), | 111 // All forms of scale should be included: Page::pageScaleFactor(), Local
Frame::pageZoomFactor(), |
| 111 // and any CSS transforms. https://bugs.webkit.org/show_bug.cgi?id=81698 | 112 // and any CSS transforms. https://bugs.webkit.org/show_bug.cgi?id=81698 |
| 112 ImageWithScale image = bestImageForScaleFactor(deviceScaleFactor); | 113 ImageWithScale image = bestImageForScaleFactor(deviceScaleFactor); |
| 113 FetchRequest request(ResourceRequest(document.completeURL(image.imageURL
)), FetchInitiatorTypeNames::css); | 114 FetchRequest request(ResourceRequest(document.completeURL(image.imageURL
)), FetchInitiatorTypeNames::css); |
| 114 request.mutableResourceRequest().setHTTPReferrer(image.referrer); | 115 request.mutableResourceRequest().setHTTPReferrer(image.referrer); |
| 115 | 116 |
| 116 if (crossOrigin != CrossOriginAttributeNotSet) | 117 if (crossOrigin != CrossOriginAttributeNotSet) |
| 117 request.setCrossOriginAccessControl(document.getSecurityOrigin(), cr
ossOrigin); | 118 request.setCrossOriginAccessControl(document.getSecurityOrigin(), cr
ossOrigin); |
| 118 | 119 |
| 119 if (ImageResource* cachedImage = ImageResource::fetch(request, document.
fetcher())) | 120 if (ImageResource* cachedImage = ImageResource::fetch(request, document.
fetcher(), placeholderRequestType)) |
| 120 m_cachedImage = StyleFetchedImageSet::create(cachedImage, image.scal
eFactor, this, request.url()); | 121 m_cachedImage = StyleFetchedImageSet::create(cachedImage, image.scal
eFactor, this, request.url()); |
| 121 else | 122 else |
| 122 m_cachedImage = StyleInvalidImage::create(image.imageURL); | 123 m_cachedImage = StyleInvalidImage::create(image.imageURL); |
| 123 m_cachedScaleFactor = deviceScaleFactor; | 124 m_cachedScaleFactor = deviceScaleFactor; |
| 124 } | 125 } |
| 125 | 126 |
| 126 return m_cachedImage.get(); | 127 return m_cachedImage.get(); |
| 127 } | 128 } |
| 128 | 129 |
| 129 String CSSImageSetValue::customCSSText() const | 130 String CSSImageSetValue::customCSSText() const |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 CSSImageSetValue* CSSImageSetValue::valueWithURLsMadeAbsolute() | 175 CSSImageSetValue* CSSImageSetValue::valueWithURLsMadeAbsolute() |
| 175 { | 176 { |
| 176 CSSImageSetValue* value = CSSImageSetValue::create(); | 177 CSSImageSetValue* value = CSSImageSetValue::create(); |
| 177 for (auto& item : *this) | 178 for (auto& item : *this) |
| 178 item->isImageValue() ? value->append(*toCSSImageValue(*item).valueWithUR
LMadeAbsolute()) : value->append(*item); | 179 item->isImageValue() ? value->append(*toCSSImageValue(*item).valueWithUR
LMadeAbsolute()) : value->append(*item); |
| 179 return value; | 180 return value; |
| 180 } | 181 } |
| 181 | 182 |
| 182 | 183 |
| 183 } // namespace blink | 184 } // namespace blink |
| OLD | NEW |