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

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

Powered by Google App Engine
This is Rietveld 408576698