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

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: Addressed comments Created 3 years, 7 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 absolute_url_(url.GetString()), 45 absolute_url_(url.GetString()),
46 cached_image_(image) {} 46 cached_image_(image) {}
47 47
48 CSSImageValue::CSSImageValue(const AtomicString& absolute_url) 48 CSSImageValue::CSSImageValue(const AtomicString& absolute_url)
49 : CSSValue(kImageClass), 49 : CSSValue(kImageClass),
50 relative_url_(absolute_url), 50 relative_url_(absolute_url),
51 absolute_url_(absolute_url) {} 51 absolute_url_(absolute_url) {}
52 52
53 CSSImageValue::~CSSImageValue() {} 53 CSSImageValue::~CSSImageValue() {}
54 54
55 StyleImage* CSSImageValue::CacheImage(const Document& document, 55 StyleImage* CSSImageValue::CacheImage(
56 CrossOriginAttributeValue cross_origin) { 56 const Document& document,
57 FetchParameters::PlaceholderImageRequestType placeholder_image_request_type,
58 CrossOriginAttributeValue cross_origin) {
57 if (!cached_image_) { 59 if (!cached_image_) {
58 if (absolute_url_.IsEmpty()) 60 if (absolute_url_.IsEmpty())
59 ReResolveURL(document); 61 ReResolveURL(document);
60 ResourceRequest resource_request(absolute_url_); 62 ResourceRequest resource_request(absolute_url_);
61 resource_request.SetHTTPReferrer(SecurityPolicy::GenerateReferrer( 63 resource_request.SetHTTPReferrer(SecurityPolicy::GenerateReferrer(
62 referrer_.referrer_policy, resource_request.Url(), referrer_.referrer)); 64 referrer_.referrer_policy, resource_request.Url(), referrer_.referrer));
63 FetchParameters params(resource_request, initiator_name_.IsEmpty() 65 FetchParameters params(resource_request, initiator_name_.IsEmpty()
64 ? FetchInitiatorTypeNames::css 66 ? FetchInitiatorTypeNames::css
65 : initiator_name_); 67 : initiator_name_);
66 68
67 if (cross_origin != kCrossOriginAttributeNotSet) { 69 if (cross_origin != kCrossOriginAttributeNotSet) {
68 params.SetCrossOriginAccessControl(document.GetSecurityOrigin(), 70 params.SetCrossOriginAccessControl(document.GetSecurityOrigin(),
69 cross_origin); 71 cross_origin);
70 } 72 }
71 if (document.GetSettings() && 73 if (document.GetSettings() &&
72 document.GetSettings()->GetFetchImagePlaceholders()) 74 document.GetSettings()->GetFetchImagePlaceholders() &&
75 placeholder_image_request_type == FetchParameters::kAllowPlaceholder)
73 params.SetAllowImagePlaceholder(); 76 params.SetAllowImagePlaceholder();
74 77
75 if (ImageResourceContent* cached_image = 78 if (ImageResourceContent* cached_image =
76 ImageResourceContent::Fetch(params, document.Fetcher())) { 79 ImageResourceContent::Fetch(params, document.Fetcher())) {
77 cached_image_ = 80 cached_image_ =
78 StyleFetchedImage::Create(cached_image, document, params.Url()); 81 StyleFetchedImage::Create(cached_image, document, params.Url());
79 } else { 82 } else {
80 cached_image_ = StyleInvalidImage::Create(Url()); 83 cached_image_ = StyleInvalidImage::Create(Url());
81 } 84 }
82 } 85 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 void CSSImageValue::ReResolveURL(const Document& document) const { 132 void CSSImageValue::ReResolveURL(const Document& document) const {
130 KURL url = document.CompleteURL(relative_url_); 133 KURL url = document.CompleteURL(relative_url_);
131 AtomicString url_string(url.GetString()); 134 AtomicString url_string(url.GetString());
132 if (url_string == absolute_url_) 135 if (url_string == absolute_url_)
133 return; 136 return;
134 absolute_url_ = url_string; 137 absolute_url_ = url_string;
135 cached_image_.Clear(); 138 cached_image_.Clear();
136 } 139 }
137 140
138 } // namespace blink 141 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698