diff options
Diffstat (limited to 'ui/gfx')
-rw-r--r-- | ui/gfx/rect_f.h | 5 | ||||
-rw-r--r-- | ui/gfx/size.cc | 7 | ||||
-rw-r--r-- | ui/gfx/size_base.h | 22 | ||||
-rw-r--r-- | ui/gfx/size_f.cc | 1 |
4 files changed, 13 insertions, 22 deletions
diff --git a/ui/gfx/rect_f.h b/ui/gfx/rect_f.h index bbc16cc..78524a0 100644 --- a/ui/gfx/rect_f.h +++ b/ui/gfx/rect_f.h @@ -49,10 +49,7 @@ class UI_EXPORT RectF void Scale(float x_scale, float y_scale) { set_origin(ScalePoint(origin(), x_scale, y_scale)); - - SizeF new_size = gfx::ScaleSize(size(), x_scale, y_scale); - new_size.ClampToNonNegative(); - set_size(new_size); + set_size(ScaleSize(size(), x_scale, y_scale)); } // This method reports if the RectF can be safely converted to an integer diff --git a/ui/gfx/size.cc b/ui/gfx/size.cc index a9a0bdd..b91f70e 100644 --- a/ui/gfx/size.cc +++ b/ui/gfx/size.cc @@ -8,18 +8,15 @@ #include <windows.h> #endif -#include "base/logging.h" #include "base/stringprintf.h" -#include "ui/gfx/size_base.h" namespace gfx { template class SizeBase<Size, int>; #if defined(OS_MACOSX) -Size::Size(const CGSize& s) : SizeBase<Size, int>(0, 0) { - set_width(s.width); - set_height(s.height); +Size::Size(const CGSize& s) + : SizeBase<Size, int>(s.width, s.height) { } Size& Size::operator=(const CGSize& s) { diff --git a/ui/gfx/size_base.h b/ui/gfx/size_base.h index 0ec62e4..57e4700 100644 --- a/ui/gfx/size_base.h +++ b/ui/gfx/size_base.h @@ -28,8 +28,12 @@ class UI_EXPORT SizeBase { set_height(height_ + height); } - void set_width(Type width) { width_ = width; } - void set_height(Type height) { height_ = height; } + void set_width(Type width) { + width_ = width < 0 ? 0 : width; + } + void set_height(Type height) { + height_ = height < 0 ? 0 : height; + } void ClampToMax(const Class& max) { width_ = width_ <= max.width_ ? width_ : max.width_; @@ -42,20 +46,14 @@ class UI_EXPORT SizeBase { } bool IsEmpty() const { - return (width_ <= 0) || (height_ <= 0); - } - - void ClampToNonNegative() { - if (width_ < 0) - width_ = 0; - if (height_ < 0) - height_ = 0; + return (width_ == 0) || (height_ == 0); } protected: SizeBase(Type width, Type height) - : width_(width), - height_(height) {} + : width_(width < 0 ? 0 : width), + height_(height < 0 ? 0 : height) { + } // Destructor is intentionally made non virtual and protected. // Do not make this public. diff --git a/ui/gfx/size_f.cc b/ui/gfx/size_f.cc index 69e0ee9..cbdae03 100644 --- a/ui/gfx/size_f.cc +++ b/ui/gfx/size_f.cc @@ -4,7 +4,6 @@ #include "ui/gfx/size_f.h" -#include "base/logging.h" #include "base/stringprintf.h" namespace gfx { |