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

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

Issue 2130523002: Fix aspect ratio for rounded background image size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove new tests; we already have coverage Created 4 years, 5 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-repeat-with-background-color.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 16803f4d728d784cef547e7e6e3a9a098f7bec34..a2fc11089a9f3b876d027649c19e7309f2bf34b9 100644
--- a/third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp
+++ b/third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp
@@ -354,13 +354,14 @@ void BackgroundImageGeometry::calculate(const LayoutBoxModelObject& obj, const L
LayoutUnit computedXPosition = roundedMinimumValueForLength(fillLayer.xPosition(), availableWidth);
if (backgroundRepeatX == RoundFill && positioningAreaSize.width() > LayoutUnit() && fillTileSize.width() > LayoutUnit()) {
int nrTiles = std::max(1, roundToInt(positioningAreaSize.width() / fillTileSize.width()));
-
- fillTileSize.setWidth(positioningAreaSize.width() / nrTiles);
+ LayoutUnit roundedWidth = positioningAreaSize.width() / nrTiles;
// Maintain aspect ratio if background-size: auto is set
if (fillLayer.size().size.height().isAuto() && backgroundRepeatY != RoundFill) {
- fillTileSize.setHeight(fillTileSize.height() * positioningAreaSize.width() / (nrTiles * fillTileSize.width()));
+ fillTileSize.setHeight(fillTileSize.height() * roundedWidth / fillTileSize.width());
}
+ fillTileSize.setWidth(roundedWidth);
+
setTileSize(applySubPixelHeuristicToImageSize(fillTileSize, m_destRect));
setPhaseX(tileSize().width()
? LayoutUnit(roundf(tileSize().width() - fmodf((computedXPosition + left), tileSize().width())))
@@ -371,13 +372,13 @@ void BackgroundImageGeometry::calculate(const LayoutBoxModelObject& obj, const L
LayoutUnit computedYPosition = roundedMinimumValueForLength(fillLayer.yPosition(), availableHeight);
if (backgroundRepeatY == RoundFill && positioningAreaSize.height() > LayoutUnit() && fillTileSize.height() > LayoutUnit()) {
int nrTiles = std::max(1, roundToInt(positioningAreaSize.height() / fillTileSize.height()));
-
- fillTileSize.setHeight(positioningAreaSize.height() / nrTiles);
-
+ LayoutUnit roundedHeight = positioningAreaSize.height() / nrTiles;
// Maintain aspect ratio if background-size: auto is set
if (fillLayer.size().size.width().isAuto() && backgroundRepeatX != RoundFill) {
- fillTileSize.setWidth(fillTileSize.width() * positioningAreaSize.height() / (nrTiles * fillTileSize.height()));
+ fillTileSize.setWidth(fillTileSize.width() * roundedHeight / fillTileSize.height());
}
+ fillTileSize.setHeight(roundedHeight);
+
setTileSize(applySubPixelHeuristicToImageSize(fillTileSize, m_destRect));
setPhaseY(tileSize().height()
? LayoutUnit(roundf(tileSize().height() - fmodf((computedYPosition + top), tileSize().height())))
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/backgrounds/background-repeat-with-background-color.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698