Chromium Code Reviews| Index: Source/core/rendering/svg/RenderSVGImage.cpp |
| diff --git a/Source/core/rendering/svg/RenderSVGImage.cpp b/Source/core/rendering/svg/RenderSVGImage.cpp |
| index 842319d72e3da3cdb116fbfda47fb4e1c7062ba4..a9cf83413a48fd51fd58e01637956ed73d9a38a0 100644 |
| --- a/Source/core/rendering/svg/RenderSVGImage.cpp |
| +++ b/Source/core/rendering/svg/RenderSVGImage.cpp |
| @@ -37,6 +37,7 @@ |
| #include "core/rendering/svg/SVGResources.h" |
| #include "core/rendering/svg/SVGResourcesCache.h" |
| #include "core/svg/SVGImageElement.h" |
| +#include "platform/LengthFunctions.h" |
| #include "platform/graphics/GraphicsContextStateSaver.h" |
| namespace blink { |
| @@ -61,6 +62,21 @@ void RenderSVGImage::destroy() |
| RenderSVGModelObject::destroy(); |
| } |
| +static bool hasIntrinsicSize(ImageResource* imageResource) |
| +{ |
| + if (!imageResource) |
| + return false; |
| + Length intrinsicWidth; |
| + Length intrinsicHeight; |
| + FloatSize intrinsicRatio; |
| + imageResource->computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, intrinsicRatio); |
| + if (!intrinsicWidth.isFixed() || !intrinsicHeight.isFixed()) |
| + return false; |
| + if (!floatValueForLength(intrinsicWidth, 0) || !floatValueForLength(intrinsicHeight, 0)) |
|
pdr.
2014/09/10 03:21:48
Are these checks correct when the user does want a
fs
2014/09/10 09:31:00
This could be considered a "counter-weight" to how
|
| + return false; |
| + return true; |
| +} |
| + |
| bool RenderSVGImage::updateImageViewport() |
| { |
| SVGImageElement* image = toSVGImageElement(element()); |
| @@ -72,11 +88,14 @@ bool RenderSVGImage::updateImageViewport() |
| bool boundsChanged = oldBoundaries != m_objectBoundingBox; |
| - // Images with preserveAspectRatio=none should force non-uniform scaling. This can be achieved |
| - // by setting the image's container size to its intrinsic size. |
| + // Images with preserveAspectRatio=none should force non-uniform |
| + // scaling. This can be achieved by setting the image's container size to |
| + // its intrinsic size. If the image does not have an intrinsic size, set |
| + // the container size to the bounds as in pAR!=none cases. |
| // See: http://www.w3.org/TR/SVG/single-page.html, 7.8 The ‘preserveAspectRatio’ attribute. |
| IntSize newViewportSize; |
| - if (image->preserveAspectRatio()->currentValue()->align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE) { |
| + if (image->preserveAspectRatio()->currentValue()->align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE |
|
pdr.
2014/09/10 03:21:48
The code change here looks good but I think we can
fs
2014/09/10 09:31:00
Certainly looks better. Done.
|
| + && hasIntrinsicSize(m_imageResource->cachedImage())) { |
| LayoutSize intrinsicSize = m_imageResource->intrinsicSize(style()->effectiveZoom()); |
| if (intrinsicSize != m_imageResource->imageSize(style()->effectiveZoom())) { |
| newViewportSize = roundedIntSize(intrinsicSize); |