Fix overflow/underflow in ui/gfx once and for all

ui/gfx/geometry currently has a number of spots where adding or
subtracting two integers can cause overflow or underflow.  Fix this so
that Point/Vector2d/Size/Rect all correctly clamp integer arithmetic to
not fall into undefined overflow or underflow.

The behavior is now that any operation that would have overflowed or
underflowed is now clamped to the max or min integer.  Additionally, for
rects, if their size is large enough to overflow right/bottom, this will
also be clamped.

gfx::Insets is left unchanged as it is only used by ui/views and so is
much more likely to be under user control and not overflow.

This patch also fixes an overflow error in the unit test that happened
in Rect::Inset.

BUG=648214

Review-Url: https://codereview.chromium.org/2354783004
Cr-Commit-Position: refs/heads/master@{#423243}


CrOS-Libchrome-Original-Commit: 8c14bf7d37bec879a5caa162f2c72a303da1a6e0
12 files changed
tree: 03d2c8ddc8bb3933e07762f72762a960abb5ad9a
  1. base/
  2. build/
  3. components/
  4. dbus/
  5. device/
  6. ipc/
  7. mojo/
  8. testing/
  9. third_party/
  10. ui/