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

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: remove a test Created 3 years, 5 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 FetchParameters::PlaceholderImageRequestType placeholder_image_request_type,
104 CrossOriginAttributeValue cross_origin) { 105 CrossOriginAttributeValue cross_origin) {
105 if (!images_in_set_.size()) 106 if (!images_in_set_.size())
106 FillImageSet(); 107 FillImageSet();
107 108
108 if (IsCachePending(device_scale_factor)) { 109 if (IsCachePending(device_scale_factor)) {
109 // FIXME: In the future, we want to take much more than deviceScaleFactor 110 // FIXME: In the future, we want to take much more than deviceScaleFactor
110 // into acount here. All forms of scale should be included: 111 // into acount here. All forms of scale should be included:
111 // Page::PageScaleFactor(), LocalFrame::PageZoomFactor(), and any CSS 112 // Page::PageScaleFactor(), LocalFrame::PageZoomFactor(), and any CSS
112 // transforms. https://bugs.webkit.org/show_bug.cgi?id=81698 113 // transforms. https://bugs.webkit.org/show_bug.cgi?id=81698
113 ImageWithScale image = BestImageForScaleFactor(device_scale_factor); 114 ImageWithScale image = BestImageForScaleFactor(device_scale_factor);
114 ResourceRequest resource_request(document.CompleteURL(image.image_url)); 115 ResourceRequest resource_request(document.CompleteURL(image.image_url));
115 resource_request.SetHTTPReferrer(image.referrer); 116 resource_request.SetHTTPReferrer(image.referrer);
116 ResourceLoaderOptions options; 117 ResourceLoaderOptions options;
117 options.initiator_info.name = FetchInitiatorTypeNames::css; 118 options.initiator_info.name = FetchInitiatorTypeNames::css;
118 FetchParameters params(resource_request, options); 119 FetchParameters params(resource_request, options);
119 120
120 if (cross_origin != kCrossOriginAttributeNotSet) { 121 if (cross_origin != kCrossOriginAttributeNotSet) {
121 params.SetCrossOriginAccessControl(document.GetSecurityOrigin(), 122 params.SetCrossOriginAccessControl(document.GetSecurityOrigin(),
122 cross_origin); 123 cross_origin);
123 } 124 }
124 125
125 if (document.GetFrame()) 126 if (document.GetFrame() &&
127 placeholder_image_request_type == FetchParameters::kAllowPlaceholder)
126 document.GetFrame()->MaybeAllowImagePlaceholder(params); 128 document.GetFrame()->MaybeAllowImagePlaceholder(params);
127 129
128 if (ImageResourceContent* cached_image = 130 if (ImageResourceContent* cached_image =
129 ImageResourceContent::Fetch(params, document.Fetcher())) { 131 ImageResourceContent::Fetch(params, document.Fetcher())) {
130 cached_image_ = StyleFetchedImageSet::Create( 132 cached_image_ = StyleFetchedImageSet::Create(
131 cached_image, image.scale_factor, this, params.Url()); 133 cached_image, image.scale_factor, this, params.Url());
132 } else { 134 } else {
133 cached_image_ = StyleInvalidImage::Create(image.image_url); 135 cached_image_ = StyleInvalidImage::Create(image.image_url);
134 } 136 }
135 cached_scale_factor_ = device_scale_factor; 137 cached_scale_factor_ = device_scale_factor;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 CSSImageSetValue* CSSImageSetValue::ValueWithURLsMadeAbsolute() { 186 CSSImageSetValue* CSSImageSetValue::ValueWithURLsMadeAbsolute() {
185 CSSImageSetValue* value = CSSImageSetValue::Create(); 187 CSSImageSetValue* value = CSSImageSetValue::Create();
186 for (auto& item : *this) 188 for (auto& item : *this)
187 item->IsImageValue() 189 item->IsImageValue()
188 ? value->Append(*ToCSSImageValue(*item).ValueWithURLMadeAbsolute()) 190 ? value->Append(*ToCSSImageValue(*item).ValueWithURLMadeAbsolute())
189 : value->Append(*item); 191 : value->Append(*item);
190 return value; 192 return value;
191 } 193 }
192 194
193 } // namespace blink 195 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSImageSetValue.h ('k') | third_party/WebKit/Source/core/css/CSSImageValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698