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

Unified Diff: Source/core/rendering/svg/RenderSVGImage.cpp

Issue 403393002: Always set the container size for a pAR=none image to the intrinsic size (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/svg/custom/svg-image-par-resize-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/svg/RenderSVGImage.cpp
diff --git a/Source/core/rendering/svg/RenderSVGImage.cpp b/Source/core/rendering/svg/RenderSVGImage.cpp
index 79ebf3a7ea1d9ab11e99d9f89133834a9141a5b0..daf418c5408508f21054fea22375002b711b28d2 100644
--- a/Source/core/rendering/svg/RenderSVGImage.cpp
+++ b/Source/core/rendering/svg/RenderSVGImage.cpp
@@ -65,26 +65,25 @@ bool RenderSVGImage::updateImageViewport()
SVGLengthContext lengthContext(image);
m_objectBoundingBox = FloatRect(image->x()->currentValue()->value(lengthContext), image->y()->currentValue()->value(lengthContext), image->width()->currentValue()->value(lengthContext), image->height()->currentValue()->value(lengthContext));
+ 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.
// 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 (ImageResource* cachedImage = m_imageResource->cachedImage()) {
- LayoutSize intrinsicSize = cachedImage->imageSizeForRenderer(0, style()->effectiveZoom());
- if (intrinsicSize != m_imageResource->imageSize(style()->effectiveZoom())) {
- m_imageResource->setContainerSizeForRenderer(roundedIntSize(intrinsicSize));
- updatedViewport = true;
- }
+ LayoutSize intrinsicSize = m_imageResource->intrinsicSize(style()->effectiveZoom());
+ if (intrinsicSize != m_imageResource->imageSize(style()->effectiveZoom())) {
+ newViewportSize = roundedIntSize(intrinsicSize);
+ updatedViewport = true;
}
- }
-
- if (oldBoundaries != m_objectBoundingBox) {
- if (!updatedViewport)
- m_imageResource->setContainerSizeForRenderer(enclosingIntRect(m_objectBoundingBox).size());
+ } else if (boundsChanged) {
+ newViewportSize = enclosingIntRect(m_objectBoundingBox).size();
updatedViewport = true;
- m_needsBoundariesUpdate = true;
}
-
+ if (updatedViewport)
+ m_imageResource->setContainerSizeForRenderer(newViewportSize);
+ m_needsBoundariesUpdate |= boundsChanged;
return updatedViewport;
}
« no previous file with comments | « LayoutTests/svg/custom/svg-image-par-resize-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698