diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-29 17:52:05 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-29 17:52:05 +0000 |
commit | 4234ab017a352322ec2badde8f8bd6183c37079b (patch) | |
tree | 658f9c8e8844e464240d1e9635bbb59ac6b145ac | |
parent | 05d4b0ae3154d410443f5ac5d6f74c970ce8d700 (diff) | |
download | chromium_src-4234ab017a352322ec2badde8f8bd6183c37079b.zip chromium_src-4234ab017a352322ec2badde8f8bd6183c37079b.tar.gz chromium_src-4234ab017a352322ec2badde8f8bd6183c37079b.tar.bz2 |
The new version of Inset() Ben added a while ago didn't work quite right for rects whose origin wasn't (0,0). Fix this and reduce some redundancy.
Review URL: http://codereview.chromium.org/19457
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8893 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/gfx/rect.cc | 10 | ||||
-rw-r--r-- | base/gfx/rect.h | 4 |
2 files changed, 4 insertions, 10 deletions
diff --git a/base/gfx/rect.cc b/base/gfx/rect.cc index c86aa42..64d68db 100644 --- a/base/gfx/rect.cc +++ b/base/gfx/rect.cc @@ -112,18 +112,10 @@ void Rect::SetRect(int x, int y, int width, int height) { set_height(height); } -void Rect::Inset(int horizontal, int vertical) { - set_x(x() + horizontal); - set_y(y() + vertical); - set_width(std::max(width() - (horizontal * 2), 0)); - set_height(std::max(height() - (vertical * 2), 0)); -} - void Rect::Inset(int left, int top, int right, int bottom) { + Offset(left, top); set_width(std::max(width() - left - right, 0)); set_height(std::max(height() - top - bottom, 0)); - set_x(left); - set_y(top); } void Rect::Offset(int horizontal, int vertical) { diff --git a/base/gfx/rect.h b/base/gfx/rect.h index 364b03b..362cd31 100644 --- a/base/gfx/rect.h +++ b/base/gfx/rect.h @@ -72,7 +72,9 @@ class Rect { void SetRect(int x, int y, int width, int height); // Shrink the rectangle by a horizontal and vertical distance on all sides. - void Inset(int horizontal, int vertical); + void Inset(int horizontal, int vertical) { + Inset(horizontal, vertical, horizontal, vertical); + } // Shrink the rectangle by the specified amount on each side. void Inset(int left, int top, int right, int bottom); |