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

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

Issue 2795173002: Do not show image placeholders for CSS sprites (Closed)
Patch Set: remove a test 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 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 absolute_url_(url.GetString()), 46 absolute_url_(url.GetString()),
47 cached_image_(image) {} 47 cached_image_(image) {}
48 48
49 CSSImageValue::CSSImageValue(const AtomicString& absolute_url) 49 CSSImageValue::CSSImageValue(const AtomicString& absolute_url)
50 : CSSValue(kImageClass), 50 : CSSValue(kImageClass),
51 relative_url_(absolute_url), 51 relative_url_(absolute_url),
52 absolute_url_(absolute_url) {} 52 absolute_url_(absolute_url) {}
53 53
54 CSSImageValue::~CSSImageValue() {} 54 CSSImageValue::~CSSImageValue() {}
55 55
56 StyleImage* CSSImageValue::CacheImage(const Document& document, 56 StyleImage* CSSImageValue::CacheImage(
57 CrossOriginAttributeValue cross_origin) { 57 const Document& document,
58 FetchParameters::PlaceholderImageRequestType placeholder_image_request_type,
59 CrossOriginAttributeValue cross_origin) {
58 if (!cached_image_) { 60 if (!cached_image_) {
59 if (absolute_url_.IsEmpty()) 61 if (absolute_url_.IsEmpty())
60 ReResolveURL(document); 62 ReResolveURL(document);
61 ResourceRequest resource_request(absolute_url_); 63 ResourceRequest resource_request(absolute_url_);
62 resource_request.SetHTTPReferrer(SecurityPolicy::GenerateReferrer( 64 resource_request.SetHTTPReferrer(SecurityPolicy::GenerateReferrer(
63 referrer_.referrer_policy, resource_request.Url(), referrer_.referrer)); 65 referrer_.referrer_policy, resource_request.Url(), referrer_.referrer));
64 ResourceLoaderOptions options; 66 ResourceLoaderOptions options;
65 options.initiator_info.name = initiator_name_.IsEmpty() 67 options.initiator_info.name = initiator_name_.IsEmpty()
66 ? FetchInitiatorTypeNames::css 68 ? FetchInitiatorTypeNames::css
67 : initiator_name_; 69 : initiator_name_;
68 FetchParameters params(resource_request, options); 70 FetchParameters params(resource_request, options);
69 71
70 if (cross_origin != kCrossOriginAttributeNotSet) { 72 if (cross_origin != kCrossOriginAttributeNotSet) {
71 params.SetCrossOriginAccessControl(document.GetSecurityOrigin(), 73 params.SetCrossOriginAccessControl(document.GetSecurityOrigin(),
72 cross_origin); 74 cross_origin);
73 } 75 }
74 76
75 if (document.GetFrame()) 77 if (document.GetFrame() &&
78 placeholder_image_request_type == FetchParameters::kAllowPlaceholder)
76 document.GetFrame()->MaybeAllowImagePlaceholder(params); 79 document.GetFrame()->MaybeAllowImagePlaceholder(params);
77 80
78 if (ImageResourceContent* cached_image = 81 if (ImageResourceContent* cached_image =
79 ImageResourceContent::Fetch(params, document.Fetcher())) { 82 ImageResourceContent::Fetch(params, document.Fetcher())) {
80 cached_image_ = 83 cached_image_ =
81 StyleFetchedImage::Create(cached_image, document, params.Url()); 84 StyleFetchedImage::Create(cached_image, document, params.Url());
82 } else { 85 } else {
83 cached_image_ = StyleInvalidImage::Create(Url()); 86 cached_image_ = StyleInvalidImage::Create(Url());
84 } 87 }
85 } 88 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 void CSSImageValue::ReResolveURL(const Document& document) const { 137 void CSSImageValue::ReResolveURL(const Document& document) const {
135 KURL url = document.CompleteURL(relative_url_); 138 KURL url = document.CompleteURL(relative_url_);
136 AtomicString url_string(url.GetString()); 139 AtomicString url_string(url.GetString());
137 if (url_string == absolute_url_) 140 if (url_string == absolute_url_)
138 return; 141 return;
139 absolute_url_ = url_string; 142 absolute_url_ = url_string;
140 cached_image_.Clear(); 143 cached_image_.Clear();
141 } 144 }
142 145
143 } // namespace blink 146 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698