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

Unified Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGImage.cpp

Issue 2230963002: SVG Image intrinsic size should be used if css style size is 'auto' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename file Created 4 years, 4 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
Index: third_party/WebKit/Source/core/layout/svg/LayoutSVGImage.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGImage.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGImage.cpp
index 91867b267e3846e7871142f9b3e0af1f11131e9a..de08ab94133cf88d7ffcbb148b03d4ae8062c43f 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGImage.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGImage.cpp
@@ -61,17 +61,25 @@ void LayoutSVGImage::willBeDestroyed()
LayoutSVGModelObject::willBeDestroyed();
}
-void LayoutSVGImage::updateBoundingBox()
+bool LayoutSVGImage::updateBoundingBox()
{
FloatRect oldBoundaries = m_objectBoundingBox;
SVGLengthContext lengthContext(element());
+ ImageResource* cachedImage = m_imageResource->cachedImage();
+ FloatSize intrinsicSize;
+ if (cachedImage && !cachedImage->errorOccurred())
+ intrinsicSize = FloatSize(cachedImage->getImage()->size());
+
m_objectBoundingBox = FloatRect(
lengthContext.valueForLength(styleRef().svgStyle().x(), styleRef(), SVGLengthMode::Width),
lengthContext.valueForLength(styleRef().svgStyle().y(), styleRef(), SVGLengthMode::Height),
- lengthContext.valueForLength(styleRef().width(), styleRef(), SVGLengthMode::Width),
- lengthContext.valueForLength(styleRef().height(), styleRef(), SVGLengthMode::Height));
+ styleRef().width().isAuto() ? intrinsicSize.width() : lengthContext.valueForLength(styleRef().width(), styleRef(), SVGLengthMode::Width),
+ styleRef().height().isAuto() ? intrinsicSize.height() : lengthContext.valueForLength(styleRef().height(), styleRef(), SVGLengthMode::Height));
fs 2016/08/19 08:59:45 This is still not using what's specced by https://
Shanmuga Pandi 2016/08/19 11:56:42 Agree. I will study more about intrinsic dimension
Shanmuga Pandi 2016/09/14 09:20:16 Please check this.
+
m_needsBoundariesUpdate |= oldBoundaries != m_objectBoundingBox;
+
+ return oldBoundaries.size() != m_objectBoundingBox.size();
}
void LayoutSVGImage::layout()
@@ -146,6 +154,11 @@ void LayoutSVGImage::imageChanged(WrappedImagePtr, const IntRect*)
// representation of this image/layout object.
LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation(this, false);
+ if (styleRef().width().isAuto() || styleRef().height().isAuto()) {
+ if (updateBoundingBox())
+ setNeedsLayout(LayoutInvalidationReason::SizeChanged);
+ }
+
setShouldDoFullPaintInvalidation();
}

Powered by Google App Engine
This is Rietveld 408576698