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

Unified Diff: Source/core/svg/graphics/SVGImage.cpp

Issue 308643002: Teach SVGImage::containerSize() to deduce intrinsic values (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@remove-text-zoom-factor
Patch Set: Lower timeout and use expandedIntSize Created 6 years, 6 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/as-image/svg-as-image-intrinsic-size.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/graphics/SVGImage.cpp
diff --git a/Source/core/svg/graphics/SVGImage.cpp b/Source/core/svg/graphics/SVGImage.cpp
index 88cd91b701dece68fed9b64a2e83845ba2bb5218..240ad44a39e9fd60f98502f9986da5316002e6b1 100644
--- a/Source/core/svg/graphics/SVGImage.cpp
+++ b/Source/core/svg/graphics/SVGImage.cpp
@@ -162,16 +162,21 @@ IntSize SVGImage::containerSize() const
// Assure that a container size is always given for a non-identity zoom level.
ASSERT(renderer->style()->effectiveZoom() == 1);
- FloatSize currentSize;
- if (rootElement->hasIntrinsicWidth() && rootElement->hasIntrinsicHeight())
- currentSize = rootElement->currentViewportSize();
- else
- currentSize = rootElement->currentViewBoxRect().size();
+ FloatSize intrinsicSize;
+ double intrinsicRatio = 0;
+ renderer->computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio);
+
+ if (intrinsicSize.isEmpty() && intrinsicRatio) {
+ if (!intrinsicSize.width() && intrinsicSize.height())
+ intrinsicSize.setWidth(intrinsicSize.height() * intrinsicRatio);
+ else if (intrinsicSize.width() && !intrinsicSize.height())
+ intrinsicSize.setHeight(intrinsicSize.width() / intrinsicRatio);
+ }
- if (!currentSize.isEmpty())
- return IntSize(static_cast<int>(ceilf(currentSize.width())), static_cast<int>(ceilf(currentSize.height())));
+ if (!intrinsicSize.isEmpty())
+ return expandedIntSize(intrinsicSize);
- // As last resort, use CSS default intrinsic size.
+ // As last resort, use CSS replaced element fallback size.
return IntSize(300, 150);
}
« no previous file with comments | « LayoutTests/svg/as-image/svg-as-image-intrinsic-size.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698