summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/IntRect.h
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-05-18 13:36:51 +0100
committerSteve Block <steveblock@google.com>2011-05-24 15:38:28 +0100
commit2fc2651226baac27029e38c9d6ef883fa32084db (patch)
treee396d4bf89dcce6ed02071be66212495b1df1dec /Source/WebCore/platform/graphics/IntRect.h
parentb3725cedeb43722b3b175aaeff70552e562d2c94 (diff)
downloadexternal_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.zip
external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.gz
external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.bz2
Merge WebKit at r78450: Initial merge by git.
Change-Id: I6d3e5f1f868ec266a0aafdef66182ddc3f265dc1
Diffstat (limited to 'Source/WebCore/platform/graphics/IntRect.h')
-rw-r--r--Source/WebCore/platform/graphics/IntRect.h26
1 files changed, 9 insertions, 17 deletions
diff --git a/Source/WebCore/platform/graphics/IntRect.h b/Source/WebCore/platform/graphics/IntRect.h
index 638db75..3a2433d 100644
--- a/Source/WebCore/platform/graphics/IntRect.h
+++ b/Source/WebCore/platform/graphics/IntRect.h
@@ -91,6 +91,8 @@ public:
int x() const { return m_location.x(); }
int y() const { return m_location.y(); }
+ int maxX() const { return x() + width(); }
+ int maxY() const { return y() + height(); }
int width() const { return m_size.width(); }
int height() const { return m_size.height(); }
@@ -99,18 +101,8 @@ public:
void setWidth(int width) { m_size.setWidth(width); }
void setHeight(int height) { m_size.setHeight(height); }
- // Be careful with these functions. The point is considered to be to the right and below. These are not
- // substitutes for right() and bottom().
- IntPoint topLeft() const { return m_location; }
- IntPoint topRight() const { return IntPoint(right() - 1, y()); }
- IntPoint bottomLeft() const { return IntPoint(x(), bottom() - 1); }
- IntPoint bottomRight() const { return IntPoint(right() - 1, bottom() - 1); }
-
bool isEmpty() const { return m_size.isEmpty(); }
- int right() const { return x() + width(); }
- int bottom() const { return y() + height(); }
-
// NOTE: The result is rounded to integer values, and thus may be not the exact
// center point.
IntPoint center() const { return IntPoint(x() + width() / 2, y() + height() / 2); }
@@ -118,26 +110,26 @@ public:
void move(const IntSize& s) { m_location += s; }
void move(int dx, int dy) { m_location.move(dx, dy); }
- void shiftLeftEdgeTo(int edge)
+ void shiftXEdgeTo(int edge)
{
int delta = edge - x();
setX(edge);
setWidth(std::max(0, width() - delta));
}
- void shiftRightEdgeTo(int edge)
+ void shiftMaxXEdgeTo(int edge)
{
- int delta = edge - right();
+ int delta = edge - maxX();
setWidth(std::max(0, width() + delta));
}
- void shiftTopEdgeTo(int edge)
+ void shiftYEdgeTo(int edge)
{
int delta = edge - y();
setY(edge);
setHeight(std::max(0, height() - delta));
}
- void shiftBottomEdgeTo(int edge)
+ void shiftMaxYEdgeTo(int edge)
{
- int delta = edge - bottom();
+ int delta = edge - maxY();
setHeight(std::max(0, height() + delta));
}
@@ -147,7 +139,7 @@ public:
// This checks to see if the rect contains x,y in the traditional sense.
// Equivalent to checking if the rect contains a 1x1 rect below and to the right of (px,py).
bool contains(int px, int py) const
- { return px >= x() && px < right() && py >= y() && py < bottom(); }
+ { return px >= x() && px < maxX() && py >= y() && py < maxY(); }
bool contains(const IntPoint& point) const { return contains(point.x(), point.y()); }
void intersect(const IntRect&);