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

Side by Side Diff: Source/core/rendering/RenderImage.cpp

Issue 23083003: Make brokenImage() a static member of ImageResource class (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebaselined patch Created 7 years, 4 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
« no previous file with comments | « Source/core/fetch/ImageResource.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com)
6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
8 * Copyright (C) 2010 Google Inc. All rights reserved. 8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. 9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved.
10 * 10 *
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 static const int maxAltTextHeight = 256; 92 static const int maxAltTextHeight = 256;
93 93
94 IntSize RenderImage::imageSizeForError(ImageResource* newImage) const 94 IntSize RenderImage::imageSizeForError(ImageResource* newImage) const
95 { 95 {
96 ASSERT_ARG(newImage, newImage); 96 ASSERT_ARG(newImage, newImage);
97 ASSERT_ARG(newImage, newImage->imageForRenderer(this)); 97 ASSERT_ARG(newImage, newImage->imageForRenderer(this));
98 98
99 IntSize imageSize; 99 IntSize imageSize;
100 if (newImage->willPaintBrokenImage()) { 100 if (newImage->willPaintBrokenImage()) {
101 float deviceScaleFactor = WebCore::deviceScaleFactor(frame()); 101 float deviceScaleFactor = WebCore::deviceScaleFactor(frame());
102 pair<Image*, float> brokenImageAndImageScaleFactor = newImage->brokenIma ge(deviceScaleFactor); 102 pair<Image*, float> brokenImageAndImageScaleFactor = ImageResource::brok enImage(deviceScaleFactor);
103 imageSize = brokenImageAndImageScaleFactor.first->size(); 103 imageSize = brokenImageAndImageScaleFactor.first->size();
104 imageSize.scale(1 / brokenImageAndImageScaleFactor.second); 104 imageSize.scale(1 / brokenImageAndImageScaleFactor.second);
105 } else 105 } else
106 imageSize = newImage->imageForRenderer(this)->size(); 106 imageSize = newImage->imageForRenderer(this)->size();
107 107
108 // imageSize() returns 0 for the error image. We need the true size of the 108 // imageSize() returns 0 for the error image. We need the true size of the
109 // error image, so we have to get it by grabbing image() directly. 109 // error image, so we have to get it by grabbing image() directly.
110 return IntSize(paddingWidth + imageSize.width() * style()->effectiveZoom(), paddingHeight + imageSize.height() * style()->effectiveZoom()); 110 return IntSize(paddingWidth + imageSize.width() * style()->effectiveZoom(), paddingHeight + imageSize.height() * style()->effectiveZoom());
111 } 111 }
112 112
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 // When calculating the usable dimensions, exclude the pixels of 309 // When calculating the usable dimensions, exclude the pixels of
310 // the ouline rect so the error image/alt text doesn't draw on it. 310 // the ouline rect so the error image/alt text doesn't draw on it.
311 LayoutUnit usableWidth = cWidth - 2 * borderWidth; 311 LayoutUnit usableWidth = cWidth - 2 * borderWidth;
312 LayoutUnit usableHeight = cHeight - 2 * borderWidth; 312 LayoutUnit usableHeight = cHeight - 2 * borderWidth;
313 313
314 RefPtr<Image> image = m_imageResource->image(); 314 RefPtr<Image> image = m_imageResource->image();
315 315
316 if (m_imageResource->errorOccurred() && !image->isNull() && usableWi dth >= image->width() && usableHeight >= image->height()) { 316 if (m_imageResource->errorOccurred() && !image->isNull() && usableWi dth >= image->width() && usableHeight >= image->height()) {
317 float deviceScaleFactor = WebCore::deviceScaleFactor(frame()); 317 float deviceScaleFactor = WebCore::deviceScaleFactor(frame());
318 // Call brokenImage() explicitly to ensure we get the broken ima ge icon at the appropriate resolution. 318 // Call brokenImage() explicitly to ensure we get the broken ima ge icon at the appropriate resolution.
319 pair<Image*, float> brokenImageAndImageScaleFactor = m_imageReso urce->cachedImage()->brokenImage(deviceScaleFactor); 319 pair<Image*, float> brokenImageAndImageScaleFactor = ImageResour ce::brokenImage(deviceScaleFactor);
320 image = brokenImageAndImageScaleFactor.first; 320 image = brokenImageAndImageScaleFactor.first;
321 IntSize imageSize = image->size(); 321 IntSize imageSize = image->size();
322 imageSize.scale(1 / brokenImageAndImageScaleFactor.second); 322 imageSize.scale(1 / brokenImageAndImageScaleFactor.second);
323 // Center the error image, accounting for border and padding. 323 // Center the error image, accounting for border and padding.
324 LayoutUnit centerX = (usableWidth - imageSize.width()) / 2; 324 LayoutUnit centerX = (usableWidth - imageSize.width()) / 2;
325 if (centerX < 0) 325 if (centerX < 0)
326 centerX = 0; 326 centerX = 0;
327 LayoutUnit centerY = (usableHeight - imageSize.height()) / 2; 327 LayoutUnit centerY = (usableHeight - imageSize.height()) / 2;
328 if (centerY < 0) 328 if (centerY < 0)
329 centerY = 0; 329 centerY = 0;
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 return 0; 586 return 0;
587 587
588 ImageResource* cachedImage = m_imageResource->cachedImage(); 588 ImageResource* cachedImage = m_imageResource->cachedImage();
589 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( )) 589 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( ))
590 return static_cast<SVGImage*>(cachedImage->image())->embeddedContentBox( ); 590 return static_cast<SVGImage*>(cachedImage->image())->embeddedContentBox( );
591 591
592 return 0; 592 return 0;
593 } 593 }
594 594
595 } // namespace WebCore 595 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/fetch/ImageResource.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698