| Index: third_party/WebKit/Source/core/paint/SVGImagePainter.cpp
|
| diff --git a/third_party/WebKit/Source/core/paint/SVGImagePainter.cpp b/third_party/WebKit/Source/core/paint/SVGImagePainter.cpp
|
| index 1f1be3863911238d9340fbb289e22b3cfab9f0a9..fec17f72e67ea3e15047f5894ccbece6e66dd19b 100644
|
| --- a/third_party/WebKit/Source/core/paint/SVGImagePainter.cpp
|
| +++ b/third_party/WebKit/Source/core/paint/SVGImagePainter.cpp
|
| @@ -51,7 +51,12 @@ void SVGImagePainter::paint(const PaintInfo& paintInfo)
|
|
|
| void SVGImagePainter::paintForeground(const PaintInfo& paintInfo)
|
| {
|
| - RefPtr<Image> image = m_layoutSVGImage.imageResource()->image(IntSize());
|
| + const LayoutImageResource* imageResource = m_layoutSVGImage.imageResource();
|
| + IntSize imageViewportSize = expandedIntSize(computeImageViewportSize());
|
| + if (imageViewportSize.isEmpty())
|
| + return;
|
| +
|
| + RefPtr<Image> image = imageResource->image(imageViewportSize, m_layoutSVGImage.style()->effectiveZoom());
|
| FloatRect destRect = m_layoutSVGImage.objectBoundingBox();
|
| FloatRect srcRect(0, 0, image->width(), image->height());
|
|
|
| @@ -67,4 +72,24 @@ void SVGImagePainter::paintForeground(const PaintInfo& paintInfo)
|
| paintInfo.context->setImageInterpolationQuality(previousInterpolationQuality);
|
| }
|
|
|
| +FloatSize SVGImagePainter::computeImageViewportSize() const
|
| +{
|
| + ASSERT(m_layoutSVGImage.imageResource()->hasImage());
|
| +
|
| + if (toSVGImageElement(m_layoutSVGImage.element())->preserveAspectRatio()->currentValue()->align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
|
| + return m_layoutSVGImage.objectBoundingBox().size();
|
| +
|
| + ImageResource* cachedImage = m_layoutSVGImage.imageResource()->cachedImage();
|
| +
|
| + // Images with preserveAspectRatio=none should force non-uniform
|
| + // scaling. This can be achieved by setting the image's container size to
|
| + // its viewport size (i.e. if a viewBox is available - use that - else use intrinsic size.)
|
| + // See: http://www.w3.org/TR/SVG/single-page.html, 7.8 The 'preserveAspectRatio' attribute.
|
| + Length intrinsicWidth;
|
| + Length intrinsicHeight;
|
| + FloatSize intrinsicRatio;
|
| + cachedImage->computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, intrinsicRatio);
|
| + return intrinsicRatio;
|
| +}
|
| +
|
| } // namespace blink
|
|
|