Chromium Code Reviews| 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 12 matching lines...) Expand all Loading... | |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | 23 * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "core/css/CSSImageSetValue.h" | 26 #include "core/css/CSSImageSetValue.h" |
| 27 | 27 |
| 28 #include <algorithm> | 28 #include <algorithm> |
| 29 #include "core/css/CSSImageValue.h" | 29 #include "core/css/CSSImageValue.h" |
| 30 #include "core/css/CSSPrimitiveValue.h" | 30 #include "core/css/CSSPrimitiveValue.h" |
| 31 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
| 32 #include "core/frame/LocalFrame.h" | 32 #include "core/frame/LocalFrame.h" |
| 33 #include "core/frame/Settings.h" | |
| 33 #include "core/loader/resource/ImageResourceContent.h" | 34 #include "core/loader/resource/ImageResourceContent.h" |
| 34 #include "core/style/StyleFetchedImageSet.h" | 35 #include "core/style/StyleFetchedImageSet.h" |
| 35 #include "core/style/StyleInvalidImage.h" | 36 #include "core/style/StyleInvalidImage.h" |
| 36 #include "platform/loader/fetch/FetchInitiatorTypeNames.h" | 37 #include "platform/loader/fetch/FetchInitiatorTypeNames.h" |
| 37 #include "platform/loader/fetch/FetchParameters.h" | 38 #include "platform/loader/fetch/FetchParameters.h" |
| 38 #include "platform/loader/fetch/ResourceFetcher.h" | 39 #include "platform/loader/fetch/ResourceFetcher.h" |
| 39 #include "platform/loader/fetch/ResourceLoaderOptions.h" | 40 #include "platform/loader/fetch/ResourceLoaderOptions.h" |
| 40 #include "platform/weborigin/KURL.h" | 41 #include "platform/weborigin/KURL.h" |
| 41 #include "platform/weborigin/SecurityPolicy.h" | 42 #include "platform/weborigin/SecurityPolicy.h" |
| 42 #include "platform/wtf/text/StringBuilder.h" | 43 #include "platform/wtf/text/StringBuilder.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 } | 95 } |
| 95 | 96 |
| 96 StyleImage* CSSImageSetValue::CachedImage(float device_scale_factor) const { | 97 StyleImage* CSSImageSetValue::CachedImage(float device_scale_factor) const { |
| 97 DCHECK(!IsCachePending(device_scale_factor)); | 98 DCHECK(!IsCachePending(device_scale_factor)); |
| 98 return cached_image_.Get(); | 99 return cached_image_.Get(); |
| 99 } | 100 } |
| 100 | 101 |
| 101 StyleImage* CSSImageSetValue::CacheImage( | 102 StyleImage* CSSImageSetValue::CacheImage( |
| 102 const Document& document, | 103 const Document& document, |
| 103 float device_scale_factor, | 104 float device_scale_factor, |
| 105 FetchParameters::PlaceholderImageRequestType placeholder_image_request_type, | |
| 104 CrossOriginAttributeValue cross_origin) { | 106 CrossOriginAttributeValue cross_origin) { |
| 105 if (!images_in_set_.size()) | 107 if (!images_in_set_.size()) |
| 106 FillImageSet(); | 108 FillImageSet(); |
| 107 | 109 |
| 108 if (IsCachePending(device_scale_factor)) { | 110 if (IsCachePending(device_scale_factor)) { |
| 109 // FIXME: In the future, we want to take much more than deviceScaleFactor | 111 // FIXME: In the future, we want to take much more than deviceScaleFactor |
| 110 // into acount here. All forms of scale should be included: | 112 // into acount here. All forms of scale should be included: |
| 111 // Page::PageScaleFactor(), LocalFrame::PageZoomFactor(), and any CSS | 113 // Page::PageScaleFactor(), LocalFrame::PageZoomFactor(), and any CSS |
| 112 // transforms. https://bugs.webkit.org/show_bug.cgi?id=81698 | 114 // transforms. https://bugs.webkit.org/show_bug.cgi?id=81698 |
| 113 ImageWithScale image = BestImageForScaleFactor(device_scale_factor); | 115 ImageWithScale image = BestImageForScaleFactor(device_scale_factor); |
| 114 ResourceRequest resource_request(document.CompleteURL(image.image_url)); | 116 ResourceRequest resource_request(document.CompleteURL(image.image_url)); |
| 115 resource_request.SetHTTPReferrer(image.referrer); | 117 resource_request.SetHTTPReferrer(image.referrer); |
| 116 ResourceLoaderOptions options(kAllowStoredCredentials, | 118 ResourceLoaderOptions options(kAllowStoredCredentials, |
| 117 kClientRequestedCredentials); | 119 kClientRequestedCredentials); |
| 118 options.initiator_info.name = FetchInitiatorTypeNames::css; | 120 options.initiator_info.name = FetchInitiatorTypeNames::css; |
| 119 FetchParameters params(resource_request, options); | 121 FetchParameters params(resource_request, options); |
| 120 | 122 |
| 121 if (cross_origin != kCrossOriginAttributeNotSet) { | 123 if (cross_origin != kCrossOriginAttributeNotSet) { |
| 122 params.SetCrossOriginAccessControl(document.GetSecurityOrigin(), | 124 params.SetCrossOriginAccessControl(document.GetSecurityOrigin(), |
| 123 cross_origin); | 125 cross_origin); |
| 124 } | 126 } |
| 125 if (document.GetFrame()) | 127 if (document.GetFrame() && document.GetSettings() && |
| 128 document.GetSettings()->GetFetchImagePlaceholders() && | |
|
sclittle
2017/06/13 00:28:27
Could you remove the Settings checks here? That lo
rajendrant
2017/06/21 19:00:57
Done.
| |
| 129 placeholder_image_request_type == FetchParameters::kAllowPlaceholder) | |
| 126 document.GetFrame()->MaybeAllowImagePlaceholder(params); | 130 document.GetFrame()->MaybeAllowImagePlaceholder(params); |
| 127 | 131 |
| 128 if (ImageResourceContent* cached_image = | 132 if (ImageResourceContent* cached_image = |
| 129 ImageResourceContent::Fetch(params, document.Fetcher())) { | 133 ImageResourceContent::Fetch(params, document.Fetcher())) { |
| 130 cached_image_ = StyleFetchedImageSet::Create( | 134 cached_image_ = StyleFetchedImageSet::Create( |
| 131 cached_image, image.scale_factor, this, params.Url()); | 135 cached_image, image.scale_factor, this, params.Url()); |
| 132 } else { | 136 } else { |
| 133 cached_image_ = StyleInvalidImage::Create(image.image_url); | 137 cached_image_ = StyleInvalidImage::Create(image.image_url); |
| 134 } | 138 } |
| 135 cached_scale_factor_ = device_scale_factor; | 139 cached_scale_factor_ = device_scale_factor; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 CSSImageSetValue* CSSImageSetValue::ValueWithURLsMadeAbsolute() { | 188 CSSImageSetValue* CSSImageSetValue::ValueWithURLsMadeAbsolute() { |
| 185 CSSImageSetValue* value = CSSImageSetValue::Create(); | 189 CSSImageSetValue* value = CSSImageSetValue::Create(); |
| 186 for (auto& item : *this) | 190 for (auto& item : *this) |
| 187 item->IsImageValue() | 191 item->IsImageValue() |
| 188 ? value->Append(*ToCSSImageValue(*item).ValueWithURLMadeAbsolute()) | 192 ? value->Append(*ToCSSImageValue(*item).ValueWithURLMadeAbsolute()) |
| 189 : value->Append(*item); | 193 : value->Append(*item); |
| 190 return value; | 194 return value; |
| 191 } | 195 } |
| 192 | 196 |
| 193 } // namespace blink | 197 } // namespace blink |
| OLD | NEW |