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

Unified Diff: ui/gfx/geometry/point.h

Issue 2499783002: Move SaturatedArithmetic from Blink to base (Closed)
Patch Set: Revert flag addition Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/ubsan/security_blacklist.txt ('k') | ui/gfx/geometry/rect.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/geometry/point.h
diff --git a/ui/gfx/geometry/point.h b/ui/gfx/geometry/point.h
index f1d1e3af76492b8d12e4f23eb192a1de6164002c..bb248d5432bee1f178f46bd966dde1a4aabeb705 100644
--- a/ui/gfx/geometry/point.h
+++ b/ui/gfx/geometry/point.h
@@ -9,8 +9,8 @@
#include <string>
#include <tuple>
+#include "base/numerics/saturated_arithmetic.h"
#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"
@@ -56,18 +56,18 @@ class GFX_EXPORT Point {
}
void Offset(int delta_x, int delta_y) {
- x_ = SafeAdd(x_, delta_x);
- y_ = SafeAdd(y_, delta_y);
+ x_ = base::SaturatedAddition(x_, delta_x);
+ y_ = base::SaturatedAddition(y_, delta_y);
}
void operator+=(const Vector2d& vector) {
- x_ = SafeAdd(x_, vector.x());
- y_ = SafeAdd(y_, vector.y());
+ x_ = base::SaturatedAddition(x_, vector.x());
+ y_ = base::SaturatedAddition(y_, vector.y());
}
void operator-=(const Vector2d& vector) {
- x_ = SafeSubtract(x_, vector.x());
- y_ = SafeSubtract(y_, vector.y());
+ x_ = base::SaturatedSubtraction(x_, vector.x());
+ y_ = base::SaturatedSubtraction(y_, vector.y());
}
void SetToMin(const Point& other);
@@ -116,8 +116,8 @@ inline Point operator-(const Point& lhs, const Vector2d& rhs) {
}
inline Vector2d operator-(const Point& lhs, const Point& rhs) {
- return Vector2d(SafeSubtract(lhs.x(), rhs.x()),
- SafeSubtract(lhs.y(), rhs.y()));
+ return Vector2d(base::SaturatedSubtraction(lhs.x(), rhs.x()),
+ base::SaturatedSubtraction(lhs.y(), rhs.y()));
}
inline Point PointAtOffsetFromOrigin(const Vector2d& offset_from_origin) {
« no previous file with comments | « tools/ubsan/security_blacklist.txt ('k') | ui/gfx/geometry/rect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698