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

Unified Diff: ui/gfx/geometry/size.cc

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 | « ui/gfx/geometry/safe_integer_conversions_unittest.cc ('k') | ui/gfx/geometry/vector2d.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/geometry/size.cc
diff --git a/ui/gfx/geometry/size.cc b/ui/gfx/geometry/size.cc
index 33f5de17c353d85a2e2136155015cc2910a17c27..69486723a1de43ef2eb487b9c24658764119f475 100644
--- a/ui/gfx/geometry/size.cc
+++ b/ui/gfx/geometry/size.cc
@@ -13,6 +13,7 @@
#endif
#include "base/numerics/safe_math.h"
+#include "base/numerics/saturated_arithmetic.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "ui/gfx/geometry/safe_integer_conversions.h"
@@ -57,7 +58,8 @@ base::CheckedNumeric<int> Size::GetCheckedArea() const {
}
void Size::Enlarge(int grow_width, int grow_height) {
- SetSize(SafeAdd(width(), grow_width), SafeAdd(height(), grow_height));
+ SetSize(base::SaturatedAddition(width(), grow_width),
+ base::SaturatedAddition(height(), grow_height));
}
void Size::SetToMin(const Size& other) {
« no previous file with comments | « ui/gfx/geometry/safe_integer_conversions_unittest.cc ('k') | ui/gfx/geometry/vector2d.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698