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

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

Issue 1704493002: Use Image::updateConcreteSize() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add-image-updateconcretesize
Patch Set: Move test here from dependency CL. Created 4 years, 10 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 | « third_party/WebKit/Source/core/style/StyleImage.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
diff --git a/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp b/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
index 76fde922cbf101dade18414fcb163d962847520f..229cd2b029cb7512328496dff05173e968d2a975 100644
--- a/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
+++ b/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
@@ -208,11 +208,25 @@ FloatSize SVGImage::calculateConcreteObjectSize(const FloatSize& defaultObjectSi
}
if (!intrinsicSizingInfo.aspectRatio.isEmpty()) {
- // TODO(davve): According to the specification, the concrete object size should resolve as a
- // contain constraint against the default object size at this stage. Until the
- // defaultObjectSize is context sensitive - right now it's hard-coded to 300x150 - we have
- // to preserve legacy behavior by returning the aspectRatio as the concrete object size.
- return intrinsicSizingInfo.aspectRatio;
+ // "A contain constraint is resolved by setting the concrete object size to the largest
+ // rectangle that has the object's intrinsic aspect ratio and additionally has neither
+ // width nor height larger than the constraint rectangle's width and height, respectively."
+ float solutionWidth = resolveWidthForRatio(defaultObjectSize.height(), intrinsicSizingInfo.aspectRatio);
+ float solutionHeight = resolveHeightForRatio(defaultObjectSize.width(), intrinsicSizingInfo.aspectRatio);
+ if (solutionWidth <= defaultObjectSize.width()) {
+ if (solutionHeight <= defaultObjectSize.height()) {
+ float areaOne = solutionWidth * defaultObjectSize.height();
+ float areaTwo = defaultObjectSize.width() * solutionHeight;
+ if (areaOne < areaTwo)
+ return FloatSize(defaultObjectSize.width(), solutionHeight);
+ return FloatSize(solutionWidth, defaultObjectSize.height());
+ }
+
+ return FloatSize(solutionWidth, defaultObjectSize.height());
+ }
+
+ ASSERT(solutionHeight <= defaultObjectSize.height());
+ return FloatSize(defaultObjectSize.width(), solutionHeight);
}
return defaultObjectSize;
« no previous file with comments | « third_party/WebKit/Source/core/style/StyleImage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698