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

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

Issue 2261663002: Disallow cast/implicit conversion from LayoutUnit to int/unsigned (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: - Created 4 years, 4 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
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 919d296d7aa9812f00f22d05acee38c26ae05c13..efe82d9aad99032318b143726a65a19ac5ab77c1 100644
--- a/third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp
+++ b/third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp
@@ -20,7 +20,7 @@ namespace {
// Return the amount of space to leave between image tiles for the background-repeat: space property.
inline LayoutUnit getSpaceBetweenImageTiles(LayoutUnit areaSize, LayoutUnit tileSize)
{
- int numberOfTiles = areaSize / tileSize;
+ int numberOfTiles = (areaSize / tileSize).toInt();
LayoutUnit space(-1);
if (numberOfTiles > 1) {
@@ -161,7 +161,7 @@ LayoutSize applySubPixelHeuristicToImageSize(const LayoutSize& size, const Layou
void BackgroundImageGeometry::setNoRepeatX(LayoutUnit xOffset)
{
int roundedOffset = roundToInt(xOffset);
- m_destRect.move(std::max(roundedOffset, 0), LayoutUnit());
+ m_destRect.move(std::max(roundedOffset, 0), 0);
setPhaseX(LayoutUnit(-std::min(roundedOffset, 0)));
m_destRect.setWidth(m_tileSize.width() + std::min(roundedOffset, 0));
setSpaceSize(LayoutSize(LayoutUnit(), spaceSize().height()));
@@ -170,7 +170,7 @@ void BackgroundImageGeometry::setNoRepeatX(LayoutUnit xOffset)
void BackgroundImageGeometry::setNoRepeatY(LayoutUnit yOffset)
{
int roundedOffset = roundToInt(yOffset);
- m_destRect.move(LayoutUnit(), std::max(roundedOffset, 0));
+ m_destRect.move(0, std::max(roundedOffset, 0));
setPhaseY(LayoutUnit(-std::min(roundedOffset, 0)));
m_destRect.setHeight(m_tileSize.height() + std::min(roundedOffset, 0));
setSpaceSize(LayoutSize(spaceSize().width(), LayoutUnit()));
@@ -231,7 +231,8 @@ void BackgroundImageGeometry::setRepeatY(
void BackgroundImageGeometry::setSpaceX(LayoutUnit space, LayoutUnit availableWidth, LayoutUnit extraOffset)
{
LayoutUnit computedXPosition = roundedMinimumValueForLength(Length(), availableWidth);
- setSpaceSize(LayoutSize(space.round(), spaceSize().height()));
+ // TODO(crbug.com/638981): Is the conversion to int intentional?
Stephen Chennney 2016/08/22 17:46:10 Yes, definitely intentional.
Xianzhu 2016/08/22 18:14:37 Done.
+ setSpaceSize(LayoutSize(space.round(), spaceSize().height().toInt()));
LayoutUnit actualWidth = tileSize().width() + space;
setPhaseX(actualWidth ? LayoutUnit(roundf(actualWidth - fmodf((computedXPosition + extraOffset), actualWidth))) : LayoutUnit());
}
@@ -239,7 +240,8 @@ void BackgroundImageGeometry::setSpaceX(LayoutUnit space, LayoutUnit availableWi
void BackgroundImageGeometry::setSpaceY(LayoutUnit space, LayoutUnit availableHeight, LayoutUnit extraOffset)
{
LayoutUnit computedYPosition = roundedMinimumValueForLength(Length(), availableHeight);
- setSpaceSize(LayoutSize(spaceSize().width(), space.round()));
+ // TODO(crbug.com/638981): Is the conversion to int intentional?
Stephen Chennney 2016/08/22 17:46:10 Yes, definitely intentional.
Xianzhu 2016/08/22 18:14:37 Done.
+ setSpaceSize(LayoutSize(spaceSize().width().toInt(), space.round()));
LayoutUnit actualHeight = tileSize().height() + space;
setPhaseY(actualHeight ? LayoutUnit(roundf(actualHeight - fmodf((computedYPosition + extraOffset), actualHeight))) : LayoutUnit());
}

Powered by Google App Engine
This is Rietveld 408576698