diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-26 22:10:13 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-26 22:10:13 +0000 |
commit | be36adf48521bae3965b79a852501c696413f133 (patch) | |
tree | 0458f2785af75473570b2604431e3f77b7cd9d88 /base/gfx/size.h | |
parent | b50ed4828c28ac9b4baad3801a1f9938e913d289 (diff) | |
download | chromium_src-be36adf48521bae3965b79a852501c696413f133.zip chromium_src-be36adf48521bae3965b79a852501c696413f133.tar.gz chromium_src-be36adf48521bae3965b79a852501c696413f133.tar.bz2 |
Change Size::IsEmpty() to be consistent with Rect::IsEmpty()
Change Size to not accept negative dimensions to be consistent with Rect.
BUG=10992
TEST=base_unittests.exe --gtest_filter=RectTest.IsEmpty
Review URL: http://codereview.chromium.org/93131
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14567 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/gfx/size.h')
-rw-r--r-- | base/gfx/size.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/base/gfx/size.h b/base/gfx/size.h index f890a51..a7a471d 100644 --- a/base/gfx/size.h +++ b/base/gfx/size.h @@ -23,7 +23,7 @@ namespace gfx { class Size { public: Size() : width_(0), height_(0) {} - Size(int width, int height) : width_(width), height_(height) {} + Size(int width, int height); ~Size() {} @@ -31,17 +31,17 @@ class Size { int height() const { return height_; } void SetSize(int width, int height) { - width_ = width; - height_ = height; + set_width(width); + set_height(height); } void Enlarge(int width, int height) { - width_ += width; - height_ += height; + set_width(width_ + width); + set_height(height_ + height); } - void set_width(int width) { width_ = width; } - void set_height(int height) { height_ = height; } + void set_width(int width); + void set_height(int height); bool operator==(const Size& s) const { return width_ == s.width_ && height_ == s.height_; @@ -52,7 +52,8 @@ class Size { } bool IsEmpty() const { - return !width_ && !height_; + // Size doesn't allow negative dimensions, so testing for 0 is enough. + return (width_ == 0) || (height_ == 0); } #if defined(OS_WIN) |