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

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: Align with review comments 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..f81dcc8ccf2334bfca5e76f14a6f3b03aaea1ad9 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGImage.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGImage.cpp
@@ -66,11 +66,17 @@ void 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());
fs 2016/08/16 12:43:08 I checked the spec, and these seem to be the relev
Shanmuga Pandi 2016/08/19 07:20:28 I filed a spec bug: https://github.com/w3c/svgwg/i
+
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));
+
m_needsBoundariesUpdate |= oldBoundaries != m_objectBoundingBox;
}
@@ -146,6 +152,16 @@ void LayoutSVGImage::imageChanged(WrappedImagePtr, const IntRect*)
// representation of this image/layout object.
LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation(this, false);
+ if (styleRef().width().isAuto() || styleRef().height().isAuto()) {
+ FloatRect oldBoundaries = m_objectBoundingBox;
+ updateBoundingBox();
+ FloatRect newBoundaries = m_objectBoundingBox;
+ if (oldBoundaries.size() != newBoundaries.size()) {
fs 2016/08/16 12:43:08 Just make updateBoundingBox() return a bool instea
Shanmuga Pandi 2016/08/19 07:20:28 Done.
+ setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::SizeChanged);
fs 2016/08/16 12:43:08 Maybe just make this setNeedsLayout and then a fal
Shanmuga Pandi 2016/08/19 07:20:28 Done.
+ return;
+ }
+ }
+
setShouldDoFullPaintInvalidation();
}

Powered by Google App Engine
This is Rietveld 408576698