Chromium Code Reviews| Index: Source/core/fetch/ImageResource.cpp |
| diff --git a/Source/core/fetch/ImageResource.cpp b/Source/core/fetch/ImageResource.cpp |
| index be73b8411561c903ef2be9f6350a61a1f6188fc0..9c07e4a1fc4818d7f7c6c1984b4ad07cadab523a 100644 |
| --- a/Source/core/fetch/ImageResource.cpp |
| +++ b/Source/core/fetch/ImageResource.cpp |
| @@ -241,6 +241,32 @@ bool ImageResource::imageHasRelativeHeight() const |
| return false; |
| } |
| +void ImageResource::applyMultiplier(LayoutSize& imageSize, float multiplier) const |
| +{ |
| + if (multiplier == 1.0f) |
| + return; |
| + |
| + // Don't let images that have a width/height >= 1 shrink below 1 when zoomed. |
| + float widthScale = m_image->hasRelativeWidth() ? 1.0f : multiplier; |
| + float heightScale = m_image->hasRelativeHeight() ? 1.0f : multiplier; |
| + LayoutSize minimumSize(imageSize.width() > 0 ? 1 : 0, imageSize.height() > 0 ? 1 : 0); |
| + imageSize.scale(widthScale, heightScale); |
| + imageSize.clampToMinimumSize(minimumSize); |
| + ASSERT(multiplier != 1.0f || (imageSize.width().fraction() == 0.0f && imageSize.height().fraction() == 0.0f)); |
| +} |
| + |
| +LayoutSize ImageResource::bitmapImageSizeRespectingOrientation(float multiplier) const |
| +{ |
| + ASSERT(!isPurgeable()); |
| + |
| + if (!m_image || !m_image->isBitmapImage()) |
| + return IntSize(); |
|
abarth-chromium
2014/02/15 18:58:33
So, this won't work for SVG images? Should this b
|
| + |
| + LayoutSize imageSize = toBitmapImage(m_image.get())->sizeRespectingOrientation(); |
| + applyMultiplier(imageSize, multiplier); |
| + return imageSize; |
| +} |
| + |
| LayoutSize ImageResource::imageSizeForRenderer(const RenderObject* renderer, float multiplier, SizeType sizeType) |
| { |
| ASSERT(!isPurgeable()); |
| @@ -257,16 +283,7 @@ LayoutSize ImageResource::imageSizeForRenderer(const RenderObject* renderer, flo |
| else |
| imageSize = m_image->size(); |
| - if (multiplier == 1.0f) |
| - return imageSize; |
| - |
| - // Don't let images that have a width/height >= 1 shrink below 1 when zoomed. |
| - float widthScale = m_image->hasRelativeWidth() ? 1.0f : multiplier; |
| - float heightScale = m_image->hasRelativeHeight() ? 1.0f : multiplier; |
| - LayoutSize minimumSize(imageSize.width() > 0 ? 1 : 0, imageSize.height() > 0 ? 1 : 0); |
| - imageSize.scale(widthScale, heightScale); |
| - imageSize.clampToMinimumSize(minimumSize); |
| - ASSERT(multiplier != 1.0f || (imageSize.width().fraction() == 0.0f && imageSize.height().fraction() == 0.0f)); |
| + applyMultiplier(imageSize, multiplier); |
| return imageSize; |
| } |