From 4234ab017a352322ec2badde8f8bd6183c37079b Mon Sep 17 00:00:00 2001
From: "pkasting@chromium.org"
 <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Thu, 29 Jan 2009 17:52:05 +0000
Subject: 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
---
 base/gfx/rect.cc | 10 +---------
 base/gfx/rect.h  |  4 +++-
 2 files changed, 4 insertions(+), 10 deletions(-)

(limited to 'base')

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);
-- 
cgit v1.1