| Index: cc/base/math_util.cc
|
| diff --git a/cc/base/math_util.cc b/cc/base/math_util.cc
|
| index b492404683a881045225b71876b8de17d7f7bc9b..ca6e5711760f8b6a16ccfcb9f3e10c82b1f3ada7 100644
|
| --- a/cc/base/math_util.cc
|
| +++ b/cc/base/math_util.cc
|
| @@ -486,13 +486,17 @@ gfx::RectF MathUtil::ScaleRectProportional(const gfx::RectF& input_outer_rect,
|
| return output_inner_rect;
|
| }
|
|
|
| +static inline bool NearlyZero(double value) {
|
| + return std::abs(value) < std::numeric_limits<double>::epsilon();
|
| +}
|
| +
|
| static inline float ScaleOnAxis(double a, double b, double c) {
|
| - if (!b && !c)
|
| - return a;
|
| - if (!a && !c)
|
| - return b;
|
| - if (!a && !b)
|
| - return c;
|
| + if (NearlyZero(b) && NearlyZero(c))
|
| + return std::abs(a);
|
| + if (NearlyZero(a) && NearlyZero(c))
|
| + return std::abs(b);
|
| + if (NearlyZero(a) && NearlyZero(b))
|
| + return std::abs(c);
|
|
|
| // Do the sqrt as a double to not lose precision.
|
| return static_cast<float>(std::sqrt(a * a + b * b + c * c));
|
|
|