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

Unified Diff: ui/gfx/size_base.h

Issue 10996037: Do not convert from RectF to Rect by flooring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing mac build. Created 8 years, 3 months 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
« no previous file with comments | « ui/gfx/size.cc ('k') | ui/gfx/size_base_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/size_base.h
diff --git a/ui/gfx/size_base.h b/ui/gfx/size_base.h
index ef687c697d9dd15bd21837b2b4e10c6ab5b9dbbe..788120b71251238599dc7ccdabed8552831f02aa 100644
--- a/ui/gfx/size_base.h
+++ b/ui/gfx/size_base.h
@@ -41,8 +41,8 @@ class UI_EXPORT SizeBase {
static_cast<Type>(height_ * y_scale));
}
- void set_width(Type width);
- void set_height(Type height);
+ void set_width(Type width) { width_ = width; }
+ void set_height(Type height) { height_ = height; }
bool operator==(const Class& s) const {
return width_ == s.width_ && height_ == s.height_;
@@ -53,15 +53,24 @@ class UI_EXPORT SizeBase {
}
bool IsEmpty() const {
- // Size doesn't allow negative dimensions, so testing for 0 is enough.
- return (width_ == 0) || (height_ == 0);
+ return (width_ <= 0) || (height_ <= 0);
+ }
+
+ void ClampToNonNegative() {
+ if (width_ < 0)
+ width_ = 0;
+ if (height_ < 0)
+ height_ = 0;
}
protected:
- SizeBase(Type width, Type height);
+ SizeBase(Type width, Type height)
+ : width_(width),
+ height_(height) {}
+
// Destructor is intentionally made non virtual and protected.
// Do not make this public.
- ~SizeBase();
+ ~SizeBase() {}
private:
Type width_;
« no previous file with comments | « ui/gfx/size.cc ('k') | ui/gfx/size_base_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698