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

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

Issue 1504463002: Turn down BackgroundImageGeometry aggressive LayoutUnit conversion by a notch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment to additional sub-pixel heuristic call Created 5 years 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
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 ef37cf3ece731dcf97b5bd801b738181c5decaba..0bd22707697bebe0e3a489634ec7a68eef699a60 100644
--- a/third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp
+++ b/third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp
@@ -161,14 +161,15 @@ void BackgroundImageGeometry::clip(const LayoutRect& clipRect)
m_destRect.intersect(clipRect);
}
-// When we match the destination rect in a dimension, we snap the same way. Otherwise
-// we floor to avoid growing our tile size. Often these tiles are from a sprite map,
-// and bleeding adjactent sprites is visually worse than clipping the intenteded one.
+// When we match the sub-pixel fraction of the destination rect in a dimension, we
+// snap the same way. Otherwise we floor to avoid growing our tile size. Often these
+// tiles are from a sprite map, and bleeding adjactent sprites is visually worse
+// than clipping the intenteded one.
static LayoutSize applySubPixelHeuristicToImageSize(const LayoutSize& size, const LayoutRect& destination)
davve 2015/12/08 20:19:21 nit: If you like you can put this function in the
{
LayoutSize snappedSize = LayoutSize(
- size.width() == destination.width() ? destination.pixelSnappedWidth() : size.width().floor(),
- size.height() == destination.height() ? destination.pixelSnappedHeight() : size.height().floor());
+ size.width().fraction() == destination.width().fraction() ? snapSizeToPixel(size.width(), destination.x()) : size.width().floor(),
davve 2015/12/08 20:19:21 The other change below is easier to understand tha
+ size.height().fraction() == destination.height().fraction() ? snapSizeToPixel(size.height(), destination.y()) : size.height().floor());
return snappedSize;
}
@@ -265,7 +266,10 @@ void BackgroundImageGeometry::calculate(const LayoutBoxModelObject& obj, const L
positioningAreaSize = destRect().size();
}
- LayoutSize fillTileSize = calculateFillTileSize(positioningBox, fillLayer, positioningAreaSize);
+ LayoutSize fillTileSize(calculateFillTileSize(positioningBox, fillLayer, positioningAreaSize));
+ // It's necessary to apply the heuristic here prior to any further calculations to avoid
+ // incorrectly using sub-pixel values that won't be present in the painted tile.
+ fillTileSize = applySubPixelHeuristicToImageSize(fillTileSize, m_destRect);
setTileSize(fillTileSize);
setImageContainerSize(fillTileSize);

Powered by Google App Engine
This is Rietveld 408576698