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

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

Issue 2749513011: Stabilize empty rect handling in EnclosingRect. (Closed)
Patch Set: Use size in Enclosing computation Created 3 years, 9 months 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 | « no previous file | ui/gfx/geometry/rect_unittest.cc » ('j') | ui/gfx/geometry/size_f.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/geometry/rect_conversions.cc
diff --git a/ui/gfx/geometry/rect_conversions.cc b/ui/gfx/geometry/rect_conversions.cc
index b4ef3d44ec9c4e434b93ae64531cde2f6197014e..3a0c60333a976b7f9096ad591d4b8e5bb395d257 100644
--- a/ui/gfx/geometry/rect_conversions.cc
+++ b/ui/gfx/geometry/rect_conversions.cc
@@ -17,18 +17,13 @@ Rect ToEnclosingRect(const RectF& rect) {
int min_y = ToFlooredInt(rect.y());
float max_x = rect.right();
float max_y = rect.bottom();
- int width =
- rect.width() == 0
- ? 0
- : std::max(
- ToCeiledInt(static_cast<double>(ToCeiledInt(max_x)) - min_x),
- 0);
+ int width = rect.size().HasWidth()
+ ? ToCeiledInt(static_cast<double>(ToCeiledInt(max_x)) - min_x)
+ : 0;
int height =
- rect.height() == 0
- ? 0
- : std::max(
- ToCeiledInt(static_cast<double>(ToCeiledInt(max_y)) - min_y),
- 0);
+ rect.size().HasHeight()
+ ? ToCeiledInt(static_cast<double>(ToCeiledInt(max_y)) - min_y)
+ : 0;
return Rect(min_x, min_y, width, height);
}
@@ -91,4 +86,3 @@ Rect ToFlooredRectDeprecated(const RectF& rect) {
}
} // namespace gfx
-
Peter Mayo 2017/03/20 18:53:50 git cl format did this.
« no previous file with comments | « no previous file | ui/gfx/geometry/rect_unittest.cc » ('j') | ui/gfx/geometry/size_f.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698