Index: ui/gfx/geometry/point.h |
diff --git a/ui/gfx/geometry/point.h b/ui/gfx/geometry/point.h |
index 6de899c3d3c4d64d76304b8f9708a2a92cb4d5f6..f1d1e3af76492b8d12e4f23eb192a1de6164002c 100644 |
--- a/ui/gfx/geometry/point.h |
+++ b/ui/gfx/geometry/point.h |
@@ -10,6 +10,7 @@ |
#include <tuple> |
#include "build/build_config.h" |
+#include "ui/gfx/geometry/safe_integer_conversions.h" |
#include "ui/gfx/geometry/vector2d.h" |
#include "ui/gfx/gfx_export.h" |
@@ -55,18 +56,18 @@ class GFX_EXPORT Point { |
} |
void Offset(int delta_x, int delta_y) { |
- x_ += delta_x; |
- y_ += delta_y; |
+ x_ = SafeAdd(x_, delta_x); |
+ y_ = SafeAdd(y_, delta_y); |
} |
void operator+=(const Vector2d& vector) { |
- x_ += vector.x(); |
- y_ += vector.y(); |
+ x_ = SafeAdd(x_, vector.x()); |
+ y_ = SafeAdd(y_, vector.y()); |
} |
void operator-=(const Vector2d& vector) { |
- x_ -= vector.x(); |
- y_ -= vector.y(); |
+ x_ = SafeSubtract(x_, vector.x()); |
+ y_ = SafeSubtract(y_, vector.y()); |
} |
void SetToMin(const Point& other); |
@@ -115,7 +116,8 @@ inline Point operator-(const Point& lhs, const Vector2d& rhs) { |
} |
inline Vector2d operator-(const Point& lhs, const Point& rhs) { |
- return Vector2d(lhs.x() - rhs.x(), lhs.y() - rhs.y()); |
+ return Vector2d(SafeSubtract(lhs.x(), rhs.x()), |
+ SafeSubtract(lhs.y(), rhs.y())); |
} |
inline Point PointAtOffsetFromOrigin(const Vector2d& offset_from_origin) { |