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

Side by Side Diff: third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp

Issue 1431103005: Avoid truncation to int when setting background-position coordinates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Limit test to the bug; background-repeat: no-repeat has further issues Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/backgrounds/background-position-zoomed-expected.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/paint/BackgroundImageGeometry.h" 6 #include "core/paint/BackgroundImageGeometry.h"
7 7
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/layout/LayoutBox.h" 9 #include "core/layout/LayoutBox.h"
10 #include "core/layout/LayoutBoxModelObject.h" 10 #include "core/layout/LayoutBoxModelObject.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (fillLayer.size().size.width().isAuto() && backgroundRepeatX != Round Fill) { 295 if (fillLayer.size().size.width().isAuto() && backgroundRepeatX != Round Fill) {
296 fillTileSize.setWidth(fillTileSize.width() * positioningAreaSize.hei ght() / (nrTiles * fillTileSize.height())); 296 fillTileSize.setWidth(fillTileSize.width() * positioningAreaSize.hei ght() / (nrTiles * fillTileSize.height()));
297 } 297 }
298 298
299 setTileSize(fillTileSize); 299 setTileSize(fillTileSize);
300 setPhaseY(tileSize().height() ? tileSize().height() - roundToInt(compute dYPosition + top) % tileSize().height() : 0); 300 setPhaseY(tileSize().height() ? tileSize().height() - roundToInt(compute dYPosition + top) % tileSize().height() : 0);
301 setSpaceSize(IntSize()); 301 setSpaceSize(IntSize());
302 } 302 }
303 303
304 if (backgroundRepeatX == RepeatFill) { 304 if (backgroundRepeatX == RepeatFill) {
305 int xOffset = fillLayer.backgroundXOrigin() == RightEdge ? availableWidt h - computedXPosition : computedXPosition; 305 LayoutUnit xOffset = fillLayer.backgroundXOrigin() == RightEdge ? availa bleWidth - computedXPosition : computedXPosition;
306 setPhaseX(tileSize().width() ? tileSize().width() - roundToInt(xOffset + left) % tileSize().width() : 0); 306 setPhaseX(tileSize().width() ? tileSize().width() - roundToInt(xOffset + left) % tileSize().width() : 0);
307 setSpaceSize(IntSize()); 307 setSpaceSize(IntSize());
308 } else if (backgroundRepeatX == SpaceFill && fillTileSize.width() > 0) { 308 } else if (backgroundRepeatX == SpaceFill && fillTileSize.width() > 0) {
309 int space = getSpaceBetweenImageTiles(positioningAreaSize.width(), tileS ize().width()); 309 int space = getSpaceBetweenImageTiles(positioningAreaSize.width(), tileS ize().width());
310 int actualWidth = tileSize().width() + space; 310 int actualWidth = tileSize().width() + space;
311 311
312 if (space >= 0) { 312 if (space >= 0) {
313 computedXPosition = roundedMinimumValueForLength(Length(), available Width); 313 computedXPosition = roundedMinimumValueForLength(Length(), available Width);
314 setSpaceSize(IntSize(space, 0)); 314 setSpaceSize(IntSize(space, 0));
315 setPhaseX(actualWidth ? actualWidth - roundToInt(computedXPosition + left) % actualWidth : 0); 315 setPhaseX(actualWidth ? actualWidth - roundToInt(computedXPosition + left) % actualWidth : 0);
316 } else { 316 } else {
317 backgroundRepeatX = NoRepeatFill; 317 backgroundRepeatX = NoRepeatFill;
318 } 318 }
319 } 319 }
320 if (backgroundRepeatX == NoRepeatFill) { 320 if (backgroundRepeatX == NoRepeatFill) {
321 int xOffset = fillLayer.backgroundXOrigin() == RightEdge ? availableWidt h - computedXPosition : computedXPosition; 321 LayoutUnit xOffset = fillLayer.backgroundXOrigin() == RightEdge ? availa bleWidth - computedXPosition : computedXPosition;
322 setNoRepeatX(left + xOffset); 322 setNoRepeatX(left + xOffset);
323 setSpaceSize(IntSize(0, spaceSize().height())); 323 setSpaceSize(IntSize(0, spaceSize().height()));
324 } 324 }
325 325
326 if (backgroundRepeatY == RepeatFill) { 326 if (backgroundRepeatY == RepeatFill) {
327 int yOffset = fillLayer.backgroundYOrigin() == BottomEdge ? availableHei ght - computedYPosition : computedYPosition; 327 LayoutUnit yOffset = fillLayer.backgroundYOrigin() == BottomEdge ? avail ableHeight - computedYPosition : computedYPosition;
328 setPhaseY(tileSize().height() ? tileSize().height() - roundToInt(yOffset + top) % tileSize().height() : 0); 328 setPhaseY(tileSize().height() ? tileSize().height() - roundToInt(yOffset + top) % tileSize().height() : 0);
329 setSpaceSize(IntSize(spaceSize().width(), 0)); 329 setSpaceSize(IntSize(spaceSize().width(), 0));
330 } else if (backgroundRepeatY == SpaceFill && fillTileSize.height() > 0) { 330 } else if (backgroundRepeatY == SpaceFill && fillTileSize.height() > 0) {
331 int space = getSpaceBetweenImageTiles(positioningAreaSize.height(), tile Size().height()); 331 int space = getSpaceBetweenImageTiles(positioningAreaSize.height(), tile Size().height());
332 int actualHeight = tileSize().height() + space; 332 int actualHeight = tileSize().height() + space;
333 333
334 if (space >= 0) { 334 if (space >= 0) {
335 computedYPosition = roundedMinimumValueForLength(Length(), available Height); 335 computedYPosition = roundedMinimumValueForLength(Length(), available Height);
336 setSpaceSize(IntSize(spaceSize().width(), space)); 336 setSpaceSize(IntSize(spaceSize().width(), space));
337 setPhaseY(actualHeight ? actualHeight - roundToInt(computedYPosition + top) % actualHeight : 0); 337 setPhaseY(actualHeight ? actualHeight - roundToInt(computedYPosition + top) % actualHeight : 0);
338 } else { 338 } else {
339 backgroundRepeatY = NoRepeatFill; 339 backgroundRepeatY = NoRepeatFill;
340 } 340 }
341 } 341 }
342 if (backgroundRepeatY == NoRepeatFill) { 342 if (backgroundRepeatY == NoRepeatFill) {
343 int yOffset = fillLayer.backgroundYOrigin() == BottomEdge ? availableHei ght - computedYPosition : computedYPosition; 343 LayoutUnit yOffset = fillLayer.backgroundYOrigin() == BottomEdge ? avail ableHeight - computedYPosition : computedYPosition;
344 setNoRepeatY(top + yOffset); 344 setNoRepeatY(top + yOffset);
345 setSpaceSize(IntSize(spaceSize().width(), 0)); 345 setSpaceSize(IntSize(spaceSize().width(), 0));
346 } 346 }
347 347
348 if (fixedAttachment) 348 if (fixedAttachment)
349 useFixedAttachment(snappedPaintRect.location()); 349 useFixedAttachment(snappedPaintRect.location());
350 350
351 clip(snappedPaintRect); 351 clip(snappedPaintRect);
352 } 352 }
353 353
354 } // namespace blink 354 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/backgrounds/background-position-zoomed-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698