| Index: ui/gfx/geometry/size_f.h
|
| diff --git a/ui/gfx/geometry/size_f.h b/ui/gfx/geometry/size_f.h
|
| index 9d1bb5d7e3ed6c18d4ff3d3193a510ae85c70c48..1009ac47df61420c6ebd298bf0c016d153bfc241 100644
|
| --- a/ui/gfx/geometry/size_f.h
|
| +++ b/ui/gfx/geometry/size_f.h
|
| @@ -14,12 +14,15 @@
|
|
|
| namespace gfx {
|
|
|
| +static constexpr float kTrivial = 8.f * std::numeric_limits<float>::epsilon();
|
| +
|
| // A floating version of gfx::Size.
|
| class GFX_EXPORT SizeF {
|
| public:
|
| constexpr SizeF() : width_(0.f), height_(0.f) {}
|
| constexpr SizeF(float width, float height)
|
| - : width_(width >= 0 ? width : 0), height_(height >= 0 ? height : 0) {}
|
| + : width_(width >= kTrivial ? width : 0.f),
|
| + height_(height >= kTrivial ? height : 0.f) {}
|
|
|
| constexpr explicit SizeF(const Size& size)
|
| : SizeF(static_cast<float>(size.width()),
|
| @@ -28,8 +31,8 @@ class GFX_EXPORT SizeF {
|
| constexpr float width() const { return width_; }
|
| constexpr float height() const { return height_; }
|
|
|
| - void set_width(float width) { width_ = fmaxf(0, width); }
|
| - void set_height(float height) { height_ = fmaxf(0, height); }
|
| + void set_width(float width) { width_ = width >= kTrivial ? width : 0.f; }
|
| + void set_height(float height) { height_ = height >= kTrivial ? height : 0.f; }
|
|
|
| float GetArea() const;
|
|
|
| @@ -43,7 +46,9 @@ class GFX_EXPORT SizeF {
|
| void SetToMin(const SizeF& other);
|
| void SetToMax(const SizeF& other);
|
|
|
| - bool IsEmpty() const { return !width() || !height(); }
|
| + bool HasHeight() const { return height() > kTrivial; }
|
| + bool HasWidth() const { return width() > kTrivial; }
|
| + bool IsEmpty() const { return !HasHeight() || !HasWidth(); }
|
|
|
| void Scale(float scale) {
|
| Scale(scale, scale);
|
|
|