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

Unified Diff: third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp

Issue 1811943003: Fix for lack of cover with background-size: cover (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/LayoutTests/fast/backgrounds/background-cover-rounding-expected.html ('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/paint/BackgroundImageGeometry.cpp
diff --git a/third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp b/third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp
index d403ec761ee292d5ddeb428a020ef3dc56d9a926..e203571fd92e3f607880ee763818b323a8621c9a 100644
--- a/third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp
+++ b/third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp
@@ -109,9 +109,18 @@ LayoutSize calculateFillTileSize(const LayoutBoxModelObject& obj, const FillLaye
? positioningAreaSize.width().toFloat() / imageIntrinsicSize.width() : 1.0f;
float verticalScaleFactor = imageIntrinsicSize.height()
? positioningAreaSize.height().toFloat() / imageIntrinsicSize.height() : 1.0f;
- float scaleFactor = type == Contain ? std::min(horizontalScaleFactor, verticalScaleFactor) : std::max(horizontalScaleFactor, verticalScaleFactor);
- return LayoutSize(std::max(1.0f, imageIntrinsicSize.width() * scaleFactor),
- std::max(1.0f, imageIntrinsicSize.height() * scaleFactor));
+ // Force the dimension that determines the size to exactly match the
+ // positioningAreaSize in that dimension, so that rounding of floating point
+ // approximation to LayoutUnit do not shrink the image to smaller than the
+ // positioningAreaSize.
Stephen Chennney 2016/03/17 19:46:29 Following the style guide makes the following code
+ if (type == Contain) {
+ if (horizontalScaleFactor < verticalScaleFactor)
+ return LayoutSize(positioningAreaSize.width(), LayoutUnit(std::max(1.0f, imageIntrinsicSize.height() * horizontalScaleFactor)));
+ return LayoutSize(LayoutUnit(std::max(1.0f, imageIntrinsicSize.width() * verticalScaleFactor)), positioningAreaSize.height());
+ }
+ if (horizontalScaleFactor > verticalScaleFactor)
+ return LayoutSize(positioningAreaSize.width(), LayoutUnit(std::max(1.0f, imageIntrinsicSize.height() * horizontalScaleFactor)));
+ return LayoutSize(LayoutUnit(std::max(1.0f, imageIntrinsicSize.width() * verticalScaleFactor)), positioningAreaSize.height());
}
}
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/backgrounds/background-cover-rounding-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698