Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Issue 1164063005: Replace gfx::ClampToInt with base::saturated_cast. (Closed)

Created:
5 years, 6 months ago by danakj
Modified:
5 years, 6 months ago
Reviewers:
jschuh, sky
CC:
chromium-reviews, chromium-apps-reviews_chromium.org, cc-bugs_chromium.org, erikwright+watch_chromium.org, tfarina, extensions-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

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. Committed: https://crrev.com/3193742f0f9014ac342f54b0085986cef724252d Cr-Commit-Position: refs/heads/master@{#333092}

Patch Set 1 #

Total comments: 1

Patch Set 2 : clamp: #

Patch Set 3 : clamp: . #

Patch Set 4 : clamp: . #

Patch Set 5 : clamp: . #

Unified diffs Side-by-side diffs Delta from patch set Stats (+24 lines, -78 lines) Patch
M base/numerics/safe_conversions_impl.h View 1 2 3 4 4 chunks +7 lines, -7 lines 0 comments Download
M base/numerics/safe_numerics_unittest.cc View 2 chunks +4 lines, -0 lines 0 comments Download
M chrome/browser/ui/views/extensions/bookmark_app_bubble_view.cc View 3 chunks +2 lines, -2 lines 0 comments Download
M ui/gfx/canvas_skia.cc View 3 chunks +4 lines, -3 lines 0 comments Download
M ui/gfx/geometry/rect_unittest.cc View 1 2 3 4 2 chunks +0 lines, -10 lines 0 comments Download
M ui/gfx/geometry/safe_integer_conversions.h View 3 chunks +7 lines, -16 lines 0 comments Download
M ui/gfx/geometry/safe_integer_conversions_unittest.cc View 1 2 3 3 chunks +0 lines, -29 lines 0 comments Download
M ui/gfx/transform_unittest.cc View 1 2 3 4 5 chunks +0 lines, -11 lines 0 comments Download

Messages

Total messages: 11 (3 generated)
danakj
5 years, 6 months ago (2015-06-05 00:17:10 UTC) #2
danakj
https://codereview.chromium.org/1164063005/diff/1/base/numerics/safe_conversions_impl.h File base/numerics/safe_conversions_impl.h (right): https://codereview.chromium.org/1164063005/diff/1/base/numerics/safe_conversions_impl.h#newcode152 base/numerics/safe_conversions_impl.h:152: value<std::numeric_limits<Dst>::max(), value> - This is some good clang-format mistake ...
5 years, 6 months ago (2015-06-05 00:19:59 UTC) #3
sky
I had to look at what saturated_cast does. IMO saturated does not describe what the ...
5 years, 6 months ago (2015-06-05 15:10:12 UTC) #4
jschuh
Nice catch. lgtm As for the name, it's a reference to "saturation arithmetic", and seemed ...
5 years, 6 months ago (2015-06-05 15:54:21 UTC) #5
sky
constrain_to_valid? make_valid? On Fri, Jun 5, 2015 at 8:54 AM, <jschuh@chromium.org> wrote: > Nice catch. ...
5 years, 6 months ago (2015-06-05 16:34:00 UTC) #6
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1164063005/80001
5 years, 6 months ago (2015-06-05 16:42:13 UTC) #9
commit-bot: I haz the power
Committed patchset #5 (id:80001)
5 years, 6 months ago (2015-06-05 18:15:19 UTC) #10
commit-bot: I haz the power
5 years, 6 months ago (2015-06-05 18:35:07 UTC) #11
Message was sent while issue was closed.
Patchset 5 (id:??) landed as
https://crrev.com/3193742f0f9014ac342f54b0085986cef724252d
Cr-Commit-Position: refs/heads/master@{#333092}

Powered by Google App Engine
This is Rietveld 408576698