Chromium Code Reviews| 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()); |
| } |
| } |