diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gfx/rect_f.cc | 7 | ||||
-rw-r--r-- | ui/gfx/rect_f.h | 6 | ||||
-rw-r--r-- | ui/gfx/rect_unittest.cc | 31 | ||||
-rw-r--r-- | ui/gfx/safe_integer_conversions.cc | 12 | ||||
-rw-r--r-- | ui/gfx/safe_integer_conversions.h | 1 |
5 files changed, 1 insertions, 56 deletions
diff --git a/ui/gfx/rect_f.cc b/ui/gfx/rect_f.cc index fa4e99d..ffa9faa 100644 --- a/ui/gfx/rect_f.cc +++ b/ui/gfx/rect_f.cc @@ -10,7 +10,6 @@ #include "base/stringprintf.h" #include "ui/gfx/insets_f.h" #include "ui/gfx/rect_base_impl.h" -#include "ui/gfx/safe_integer_conversions.h" namespace gfx { @@ -40,12 +39,6 @@ RectF::RectF(const gfx::PointF& origin, const gfx::SizeF& size) RectF::~RectF() {} -bool RectF::IsExpressibleAsRect() const { - return IsExpressibleAsInt(x()) && IsExpressibleAsInt(y()) && - IsExpressibleAsInt(width()) && IsExpressibleAsInt(height()) && - IsExpressibleAsInt(right()) && IsExpressibleAsInt(bottom()); -} - std::string RectF::ToString() const { return base::StringPrintf("%s %s", origin().ToString().c_str(), diff --git a/ui/gfx/rect_f.h b/ui/gfx/rect_f.h index b3734f9..499c9be 100644 --- a/ui/gfx/rect_f.h +++ b/ui/gfx/rect_f.h @@ -40,12 +40,6 @@ class UI_EXPORT RectF set_size(newSize); } - // This method reports if the RectF can be safely converted to an integer - // Rect. When it is false, some dimension of the RectF is outside the bounds - // of what an integer can represent, and converting it to a Rect will require - // clamping. - bool IsExpressibleAsRect() const; - std::string ToString() const; }; diff --git a/ui/gfx/rect_unittest.cc b/ui/gfx/rect_unittest.cc index a45fe5c..f57c388 100644 --- a/ui/gfx/rect_unittest.cc +++ b/ui/gfx/rect_unittest.cc @@ -670,35 +670,4 @@ TEST(RectTest, BoundingRect) { } } -TEST(RectTest, IsExpressibleAsRect) { - //EXPECT_TRUE(gfx::RectF().IsExpressibleAsRect()); - - float min = std::numeric_limits<int>::min(); - float max = std::numeric_limits<int>::max(); - float infinity = std::numeric_limits<float>::infinity(); - - EXPECT_TRUE(RectF(min, min, max, max).IsExpressibleAsRect()); - EXPECT_TRUE(RectF(min + 500, min, max, max).IsExpressibleAsRect()); - EXPECT_TRUE(RectF(min, min + 500, max, max).IsExpressibleAsRect()); - EXPECT_FALSE(RectF(min - 500, min, max, max).IsExpressibleAsRect()); - EXPECT_FALSE(RectF(min, min - 500, max, max).IsExpressibleAsRect()); - EXPECT_TRUE(RectF(min, min, max - 500, max).IsExpressibleAsRect()); - EXPECT_TRUE(RectF(min, min, max, max - 500).IsExpressibleAsRect()); - EXPECT_FALSE(RectF(min, min, max + 500, max).IsExpressibleAsRect()); - EXPECT_FALSE(RectF(min, min, max, max + 500).IsExpressibleAsRect()); - - EXPECT_TRUE(RectF(0, 0, max, max).IsExpressibleAsRect()); - EXPECT_FALSE(RectF(500, 0, max, max).IsExpressibleAsRect()); - EXPECT_FALSE(RectF(0, 500, max, max).IsExpressibleAsRect()); - EXPECT_TRUE(RectF(0, 0, max - 500, max).IsExpressibleAsRect()); - EXPECT_TRUE(RectF(0, 0, max, max - 500).IsExpressibleAsRect()); - EXPECT_FALSE(RectF(0, 0, max + 500, max).IsExpressibleAsRect()); - EXPECT_FALSE(RectF(0, 0, max, max + 500).IsExpressibleAsRect()); - - EXPECT_FALSE(RectF(infinity, 0, 1, 1).IsExpressibleAsRect()); - EXPECT_FALSE(RectF(0, infinity, 1, 1).IsExpressibleAsRect()); - EXPECT_FALSE(RectF(0, 0, infinity, 1).IsExpressibleAsRect()); - EXPECT_FALSE(RectF(0, 0, 1, infinity).IsExpressibleAsRect()); -} - } // namespace gfx diff --git a/ui/gfx/safe_integer_conversions.cc b/ui/gfx/safe_integer_conversions.cc index 00d44c2..e354353 100644 --- a/ui/gfx/safe_integer_conversions.cc +++ b/ui/gfx/safe_integer_conversions.cc @@ -11,7 +11,7 @@ namespace gfx { int ClampToInt(float value) { if (value != value) - return 0; // no int NaN. + return 0; // no int NaN. if (value >= std::numeric_limits<int>::max()) return std::numeric_limits<int>::max(); if (value <= std::numeric_limits<int>::min()) @@ -36,14 +36,4 @@ int ToRoundedInt(float value) { return ClampToInt(rounded); } -bool IsExpressibleAsInt(float value) { - if (value != value) - return false; // no int NaN. - if (value > std::numeric_limits<int>::max()) - return false; - if (value < std::numeric_limits<int>::min()) - return false; - return true; -} - } // namespace gfx diff --git a/ui/gfx/safe_integer_conversions.h b/ui/gfx/safe_integer_conversions.h index 55d7ac1..1cbfb88 100644 --- a/ui/gfx/safe_integer_conversions.h +++ b/ui/gfx/safe_integer_conversions.h @@ -13,7 +13,6 @@ UI_EXPORT int ClampToInt(float value); UI_EXPORT int ToFlooredInt(float value); UI_EXPORT int ToCeiledInt(float value); UI_EXPORT int ToRoundedInt(float value); -UI_EXPORT bool IsExpressibleAsInt(float value); } // namespace gfx |