Replace gfx::ClampToInt with base::saturated_cast.
commit3193742f0f9014ac342f54b0085986cef724252d
authordanakj <danakj@chromium.org>
Fri, 5 Jun 2015 18:15:10 +0000 (5 11:15 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 5 Jun 2015 18:15:31 +0000 (5 18:15 +0000)
tree5371e8669c3559ccf19d3e34a92e78d7e36b7865
parentbb9d67e7b77484c4fa2a653c0f89b60cc3f894de
Replace gfx::ClampToInt with base::saturated_cast.

This found a bug in saturated_cast that was covered by ClampToInt tests
so it fixes that.

If you have a floating point value of MAX_INT, then comparing an
integer against it for equality with promote it to a float and
it will compare true. However if you cast the float to an int, its
actually outside the bounds of integer, so you can end up with a
negative int as a result. Added unittests to check this for
saturated_cast.

Review URL: https://codereview.chromium.org/1164063005

Cr-Commit-Position: refs/heads/master@{#333092}
base/numerics/safe_conversions_impl.h
base/numerics/safe_numerics_unittest.cc
chrome/browser/ui/views/extensions/bookmark_app_bubble_view.cc
ui/gfx/canvas_skia.cc
ui/gfx/geometry/rect_unittest.cc
ui/gfx/geometry/safe_integer_conversions.h
ui/gfx/geometry/safe_integer_conversions_unittest.cc
ui/gfx/transform_unittest.cc