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

Side by Side Diff: Source/core/fetch/ImageResource.cpp

Issue 481753002: Use Shadow DOM to display fallback content for images (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 6 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 151 }
152 152
153 void ImageResource::allClientsRemoved() 153 void ImageResource::allClientsRemoved()
154 { 154 {
155 m_pendingContainerSizeRequests.clear(); 155 m_pendingContainerSizeRequests.clear();
156 if (m_image && !errorOccurred()) 156 if (m_image && !errorOccurred())
157 m_image->resetAnimation(); 157 m_image->resetAnimation();
158 Resource::allClientsRemoved(); 158 Resource::allClientsRemoved();
159 } 159 }
160 160
161 pair<blink::Image*, float> ImageResource::brokenImage(float deviceScaleFactor)
162 {
163 if (deviceScaleFactor >= 2) {
164 DEFINE_STATIC_REF(blink::Image, brokenImageHiRes, (blink::Image::loadPla tformResource("missingImage@2x")));
165 return std::make_pair(brokenImageHiRes, 2);
166 }
167
168 DEFINE_STATIC_REF(blink::Image, brokenImageLoRes, (blink::Image::loadPlatfor mResource("missingImage")));
169 return std::make_pair(brokenImageLoRes, 1);
170 }
171
172 bool ImageResource::willPaintBrokenImage() const
173 {
174 return errorOccurred();
175 }
176 161
177 blink::Image* ImageResource::image() 162 blink::Image* ImageResource::image()
178 { 163 {
179 ASSERT(!isPurgeable()); 164 ASSERT(!isPurgeable());
180 165
181 if (errorOccurred()) {
182 // Returning the 1x broken image is non-ideal, but we cannot reliably ac cess the appropriate
183 // deviceScaleFactor from here. It is critical that callers use ImageRes ource::brokenImage()
184 // when they need the real, deviceScaleFactor-appropriate broken image i con.
185 return brokenImage(1).first;
186 }
187
188 if (m_image) 166 if (m_image)
189 return m_image.get(); 167 return m_image.get();
190 168
191 return blink::Image::nullImage(); 169 return blink::Image::nullImage();
192 } 170 }
193 171
194 blink::Image* ImageResource::imageForRenderer(const RenderObject* renderer) 172 blink::Image* ImageResource::imageForRenderer(const RenderObject* renderer)
195 { 173 {
196 ASSERT(!isPurgeable()); 174 ASSERT(!isPurgeable());
197 175
198 if (errorOccurred()) {
199 // Returning the 1x broken image is non-ideal, but we cannot reliably ac cess the appropriate
200 // deviceScaleFactor from here. It is critical that callers use ImageRes ource::brokenImage()
201 // when they need the real, deviceScaleFactor-appropriate broken image i con.
202 return brokenImage(1).first;
203 }
204
205 if (!m_image) 176 if (!m_image)
206 return blink::Image::nullImage(); 177 return blink::Image::nullImage();
207 178
208 if (m_image->isSVGImage()) { 179 if (m_image->isSVGImage()) {
209 blink::Image* image = m_svgImageCache->imageForRenderer(renderer); 180 blink::Image* image = m_svgImageCache->imageForRenderer(renderer);
210 if (image != blink::Image::nullImage()) 181 if (image != blink::Image::nullImage())
211 return image; 182 return image;
212 } 183 }
213 184
214 return m_image.get(); 185 return m_image.get();
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 if (response().wasFetchedViaServiceWorker()) 461 if (response().wasFetchedViaServiceWorker())
491 return response().serviceWorkerResponseType() != WebServiceWorkerRespons eTypeOpaque; 462 return response().serviceWorkerResponseType() != WebServiceWorkerRespons eTypeOpaque;
492 if (!image()->currentFrameHasSingleSecurityOrigin()) 463 if (!image()->currentFrameHasSingleSecurityOrigin())
493 return false; 464 return false;
494 if (passesAccessControlCheck(securityOrigin)) 465 if (passesAccessControlCheck(securityOrigin))
495 return true; 466 return true;
496 return !securityOrigin->taintsCanvas(response().url()); 467 return !securityOrigin->taintsCanvas(response().url());
497 } 468 }
498 469
499 } // namespace blink 470 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698