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

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

Issue 1477813002: Move NinePieceImageGrid to LayoutUnit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to trunk for bot bouncing 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/NinePieceImageGrid.cpp
diff --git a/third_party/WebKit/Source/core/paint/NinePieceImageGrid.cpp b/third_party/WebKit/Source/core/paint/NinePieceImageGrid.cpp
index b59320dcaa719ad9b4f8285df0a6cdf38b6fd002..b04ed838883d24519980ffdfaa009a4658c9937d 100644
--- a/third_party/WebKit/Source/core/paint/NinePieceImageGrid.cpp
+++ b/third_party/WebKit/Source/core/paint/NinePieceImageGrid.cpp
@@ -9,7 +9,6 @@
#include "core/style/NinePieceImage.h"
#include "platform/LengthFunctions.h"
#include "platform/geometry/FloatSize.h"
-#include "platform/geometry/IntSize.h"
namespace blink {
@@ -28,7 +27,7 @@ static int computeEdgeSlice(const Length& slice, LayoutUnit maximum)
return std::min<int>(maximum, valueForLength(slice, maximum));
}
-NinePieceImageGrid::NinePieceImageGrid(const NinePieceImage& ninePieceImage, IntSize imageSize, IntRect borderImageArea,
+NinePieceImageGrid::NinePieceImageGrid(const NinePieceImage& ninePieceImage, LayoutSize imageSize, LayoutRect borderImageArea,
const IntRectOutsets& borderWidths)
: m_borderImageArea(borderImageArea)
, m_imageSize(imageSize)
@@ -71,7 +70,7 @@ NinePieceImageGrid::NinePieceImageGrid(const NinePieceImage& ninePieceImage, Int
// Given a rectangle, construct a subrectangle using offset, width and height. Negative offsets are relative to the
// extent of the given rectangle.
-static FloatRect subrect(IntRect rect, float offsetX, float offsetY, float width, float height)
+static FloatRect subrect(LayoutRect rect, float offsetX, float offsetY, float width, float height)
{
float baseX = rect.x();
if (offsetX < 0)
@@ -84,9 +83,11 @@ static FloatRect subrect(IntRect rect, float offsetX, float offsetY, float width
return FloatRect(baseX + offsetX, baseY + offsetY, width, height);
}
-static FloatRect subrect(IntSize size, float offsetX, float offsetY, float width, float height)
+// Given a size, construct a subrectangle using offset, width and height. Negative offsets are relative to the
+// extent of the given size.
+static FloatRect subrect(LayoutSize size, float offsetX, float offsetY, float width, float height)
{
- return subrect(IntRect(IntPoint(), size), offsetX, offsetY, width, height);
+ return subrect(LayoutRect(LayoutPoint(), size), offsetX, offsetY, width, height);
}
static inline void setCornerPiece(NinePieceImageGrid::NinePieceDrawInfo& drawInfo, bool isDrawable,
@@ -156,8 +157,8 @@ static inline void setVerticalEdge(NinePieceImageGrid::NinePieceDrawInfo& drawIn
void NinePieceImageGrid::setDrawInfoEdge(NinePieceDrawInfo& drawInfo, NinePiece piece) const
{
- IntSize edgeSourceSize = m_imageSize - IntSize(m_left.slice + m_right.slice, m_top.slice + m_bottom.slice);
- IntSize edgeDestinationSize = m_borderImageArea.size() - IntSize(m_left.width + m_right.width, m_top.width + m_bottom.width);
+ LayoutSize edgeSourceSize = m_imageSize - LayoutSize(m_left.slice + m_right.slice, m_top.slice + m_bottom.slice);
+ LayoutSize edgeDestinationSize = m_borderImageArea.size() - LayoutSize(m_left.width + m_right.width, m_top.width + m_bottom.width);
switch (piece) {
case LeftPiece:
@@ -192,9 +193,9 @@ void NinePieceImageGrid::setDrawInfoEdge(NinePieceDrawInfo& drawInfo, NinePiece
void NinePieceImageGrid::setDrawInfoMiddle(NinePieceDrawInfo& drawInfo) const
{
- IntSize sourceSize = m_imageSize - IntSize(m_left.slice + m_right.slice, m_top.slice + m_bottom.slice);
- IntSize destinationSize =
- m_borderImageArea.size() - IntSize(m_left.width + m_right.width, m_top.width + m_bottom.width);
+ LayoutSize sourceSize = m_imageSize - LayoutSize(m_left.slice + m_right.slice, m_top.slice + m_bottom.slice);
+ LayoutSize destinationSize =
+ m_borderImageArea.size() - LayoutSize(m_left.width + m_right.width, m_top.width + m_bottom.width);
drawInfo.isDrawable = m_fill && !sourceSize.isEmpty() && !destinationSize.isEmpty();
if (!drawInfo.isDrawable)

Powered by Google App Engine
This is Rietveld 408576698