| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 94 } |
| 95 | 95 |
| 96 StyleImage* CSSImageSetValue::CachedImage(float device_scale_factor) const { | 96 StyleImage* CSSImageSetValue::CachedImage(float device_scale_factor) const { |
| 97 DCHECK(!IsCachePending(device_scale_factor)); | 97 DCHECK(!IsCachePending(device_scale_factor)); |
| 98 return cached_image_.Get(); | 98 return cached_image_.Get(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 StyleImage* CSSImageSetValue::CacheImage( | 101 StyleImage* CSSImageSetValue::CacheImage( |
| 102 const Document& document, | 102 const Document& document, |
| 103 float device_scale_factor, | 103 float device_scale_factor, |
| 104 CrossOriginAttributeValue cross_origin) { | 104 CrossOriginAttributeValue cross_origin, |
| 105 FetchParameters::PlaceholderImageRequestType |
| 106 placeholder_image_request_type) { |
| 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 FetchParameters params(resource_request, FetchInitiatorTypeNames::css); | 118 FetchParameters params(resource_request, FetchInitiatorTypeNames::css); |
| 117 | 119 |
| 118 if (cross_origin != kCrossOriginAttributeNotSet) { | 120 if (cross_origin != kCrossOriginAttributeNotSet) { |
| 119 params.SetCrossOriginAccessControl(document.GetSecurityOrigin(), | 121 params.SetCrossOriginAccessControl(document.GetSecurityOrigin(), |
| 120 cross_origin); | 122 cross_origin); |
| 121 } | 123 } |
| 122 if (document.GetSettings() && | 124 if (document.GetSettings() && |
| 123 document.GetSettings()->GetFetchImagePlaceholders()) | 125 document.GetSettings()->GetFetchImagePlaceholders() && |
| 126 placeholder_image_request_type == FetchParameters::kAllowPlaceholder) |
| 124 params.SetAllowImagePlaceholder(); | 127 params.SetAllowImagePlaceholder(); |
| 125 | 128 |
| 126 if (ImageResourceContent* cached_image = | 129 if (ImageResourceContent* cached_image = |
| 127 ImageResourceContent::Fetch(params, document.Fetcher())) { | 130 ImageResourceContent::Fetch(params, document.Fetcher())) { |
| 128 cached_image_ = StyleFetchedImageSet::Create( | 131 cached_image_ = StyleFetchedImageSet::Create( |
| 129 cached_image, image.scale_factor, this, params.Url()); | 132 cached_image, image.scale_factor, this, params.Url()); |
| 130 } else { | 133 } else { |
| 131 cached_image_ = StyleInvalidImage::Create(image.image_url); | 134 cached_image_ = StyleInvalidImage::Create(image.image_url); |
| 132 } | 135 } |
| 133 cached_scale_factor_ = device_scale_factor; | 136 cached_scale_factor_ = device_scale_factor; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 CSSImageSetValue* CSSImageSetValue::ValueWithURLsMadeAbsolute() { | 185 CSSImageSetValue* CSSImageSetValue::ValueWithURLsMadeAbsolute() { |
| 183 CSSImageSetValue* value = CSSImageSetValue::Create(); | 186 CSSImageSetValue* value = CSSImageSetValue::Create(); |
| 184 for (auto& item : *this) | 187 for (auto& item : *this) |
| 185 item->IsImageValue() | 188 item->IsImageValue() |
| 186 ? value->Append(*ToCSSImageValue(*item).ValueWithURLMadeAbsolute()) | 189 ? value->Append(*ToCSSImageValue(*item).ValueWithURLMadeAbsolute()) |
| 187 : value->Append(*item); | 190 : value->Append(*item); |
| 188 return value; | 191 return value; |
| 189 } | 192 } |
| 190 | 193 |
| 191 } // namespace blink | 194 } // namespace blink |
| OLD | NEW |