Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: third_party/WebKit/Source/core/css/CSSImageSetValue.cpp

Issue 2795173002: Do not show image placeholders for CSS sprites (Closed)
Patch Set: Addressed comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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"
sclittle 2017/06/21 20:46:56 nit: Remove unused include
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
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() &&
128 placeholder_image_request_type == FetchParameters::kAllowPlaceholder)
126 document.GetFrame()->MaybeAllowImagePlaceholder(params); 129 document.GetFrame()->MaybeAllowImagePlaceholder(params);
127 130
128 if (ImageResourceContent* cached_image = 131 if (ImageResourceContent* cached_image =
129 ImageResourceContent::Fetch(params, document.Fetcher())) { 132 ImageResourceContent::Fetch(params, document.Fetcher())) {
130 cached_image_ = StyleFetchedImageSet::Create( 133 cached_image_ = StyleFetchedImageSet::Create(
131 cached_image, image.scale_factor, this, params.Url()); 134 cached_image, image.scale_factor, this, params.Url());
132 } else { 135 } else {
133 cached_image_ = StyleInvalidImage::Create(image.image_url); 136 cached_image_ = StyleInvalidImage::Create(image.image_url);
134 } 137 }
135 cached_scale_factor_ = device_scale_factor; 138 cached_scale_factor_ = device_scale_factor;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 CSSImageSetValue* CSSImageSetValue::ValueWithURLsMadeAbsolute() { 187 CSSImageSetValue* CSSImageSetValue::ValueWithURLsMadeAbsolute() {
185 CSSImageSetValue* value = CSSImageSetValue::Create(); 188 CSSImageSetValue* value = CSSImageSetValue::Create();
186 for (auto& item : *this) 189 for (auto& item : *this)
187 item->IsImageValue() 190 item->IsImageValue()
188 ? value->Append(*ToCSSImageValue(*item).ValueWithURLMadeAbsolute()) 191 ? value->Append(*ToCSSImageValue(*item).ValueWithURLMadeAbsolute())
189 : value->Append(*item); 192 : value->Append(*item);
190 return value; 193 return value;
191 } 194 }
192 195
193 } // namespace blink 196 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698