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

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

Issue 2690053002: Calculate positioningArea and not just size, for tiling background. (Closed)
Patch Set: Created 3 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 | « no previous file | 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 85cfd59807b1c23ebcbcd70b8d39bdd30037b0da..b99d4c261c8fb26ceab93ca07985b2e888b63a83 100644
--- a/third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp
+++ b/third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp
@@ -419,7 +419,7 @@ void BackgroundImageGeometry::calculate(
const LayoutRect& paintRect) {
LayoutUnit left;
LayoutUnit top;
- LayoutSize positioningAreaSize;
+ LayoutRect positioningArea;
bool isLayoutView = obj.isLayoutView();
const LayoutBox* rootBox = nullptr;
if (isLayoutView) {
@@ -481,8 +481,9 @@ void BackgroundImageGeometry::calculate(
// The background of the box generated by the root element covers the
// entire canvas and will be painted by the view object, but the we should
// still use the root element box for positioning.
- positioningAreaSize =
- rootBox->size() - LayoutSize(left + right, top + bottom);
+ positioningArea.setSize(rootBox->size());
+ positioningArea.contractEdges(top, right, bottom, left);
+
// The input paint rect is specified in root element local coordinate
// (i.e. a transform is applied on the context for painting), and is
// expanded to cover the whole canvas. Since left/top is relative to the
@@ -490,12 +491,14 @@ void BackgroundImageGeometry::calculate(
left -= paintRect.x();
top -= paintRect.y();
} else {
- positioningAreaSize =
- (cellUsingContainerBackground
- ? getBackgroundObjectDimensions(toLayoutTableCell(obj),
- toLayoutBox(positioningBox))
- : paintRect.size()) -
- LayoutSize(left + right, top + bottom);
+ if (cellUsingContainerBackground) {
+ positioningArea.setSize(getBackgroundObjectDimensions(
+ toLayoutTableCell(obj), toLayoutBox(positioningBox)));
+ } else {
+ positioningArea = paintRect;
+ }
+
+ positioningArea.contractEdges(top, right, bottom, left);
}
} else {
setHasNonLocalGeometry();
@@ -517,11 +520,11 @@ void BackgroundImageGeometry::calculate(
LayoutPoint(-paintContainer->localToAbsolute(FloatPoint())));
setDestRect(viewportRect);
- positioningAreaSize = destRect().size();
+ positioningArea = viewportRect;
}
LayoutSize fillTileSize(
- calculateFillTileSize(positioningBox, fillLayer, positioningAreaSize));
+ calculateFillTileSize(positioningBox, fillLayer, positioningArea.size()));
// 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.
@@ -530,12 +533,10 @@ void BackgroundImageGeometry::calculate(
EFillRepeat backgroundRepeatX = fillLayer.repeatX();
EFillRepeat backgroundRepeatY = fillLayer.repeatY();
LayoutUnit unsnappedAvailableWidth =
- positioningAreaSize.width() - fillTileSize.width();
+ positioningArea.width() - fillTileSize.width();
LayoutUnit unsnappedAvailableHeight =
- positioningAreaSize.height() - fillTileSize.height();
- positioningAreaSize =
- LayoutSize(snapSizeToPixel(positioningAreaSize.width(), m_destRect.x()),
- snapSizeToPixel(positioningAreaSize.height(), m_destRect.y()));
+ positioningArea.height() - fillTileSize.height();
+ LayoutSize positioningAreaSize(positioningArea.pixelSnappedSize());
Stephen Chennney 2017/03/01 14:48:29 This is a subtle change that might change snapping
Karl Øygard 2017/03/03 15:00:07 Good catch, this does not belong here. Thanks!
LayoutUnit availableWidth = positioningAreaSize.width() - tileSize().width();
LayoutUnit availableHeight =
positioningAreaSize.height() - tileSize().height();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698