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

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

Issue 889613002: Make sure a container size is always set for SVG images in <svg:image> (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 11 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-container-size-expected.html ('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 5e4fa8188291b8064133a2eac15769ddc5ea7bf3..11200b437224fc8270c1fbbd0e22b30968f80011 100644
--- a/Source/core/rendering/svg/RenderSVGImage.cpp
+++ b/Source/core/rendering/svg/RenderSVGImage.cpp
@@ -77,6 +77,15 @@ FloatSize RenderSVGImage::computeImageViewportSize(ImageResource& cachedImage) c
return intrinsicRatio;
}
+static bool containerSizeIsSetForRenderer(ImageResource& cachedImage, const RenderObject* renderer)
pdr. 2015/01/29 19:32:21 Can we put this on ImageResource?
fs 2015/01/30 09:30:20 I considered that, but since it didn't seem univer
+{
+ const Image* image = cachedImage.image();
+ // If a container size has been specified for this renderer, then
+ // imageForRenderer() will return the SVGImageForContainer while image()
+ // will return the underlying SVGImage.
+ return !image->isSVGImage() || image != cachedImage.imageForRenderer(renderer);
+}
+
bool RenderSVGImage::updateImageViewport()
{
SVGImageElement* image = toSVGImageElement(element());
@@ -90,7 +99,8 @@ bool RenderSVGImage::updateImageViewport()
ImageResource* cachedImage = m_imageResource->cachedImage();
if (cachedImage && cachedImage->usesImageContainerSize()) {
FloatSize imageViewportSize = computeImageViewportSize(*cachedImage);
- if (LayoutSize(imageViewportSize) != m_imageResource->imageSize(style()->effectiveZoom())) {
+ if (LayoutSize(imageViewportSize) != m_imageResource->imageSize(style()->effectiveZoom())
+ || !containerSizeIsSetForRenderer(*cachedImage, this)) {
m_imageResource->setContainerSizeForRenderer(roundedIntSize(imageViewportSize));
updatedViewport = true;
}
« no previous file with comments | « LayoutTests/svg/custom/svg-image-container-size-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698