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

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

Issue 1877043003: [EXPERIMENT] MacViews: Implement Tab Dragging Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format Created 4 years, 8 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 | « ui/gfx/geometry/rect.h ('k') | ui/gfx/geometry/rect_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/geometry/rect.cc
diff --git a/ui/gfx/geometry/rect.cc b/ui/gfx/geometry/rect.cc
index e7a3aa2aac93f14eb96c4832a130f4bbeafa9253..a8e628792cce51a70c09ca0973b3f483eaaa6e2d 100644
--- a/ui/gfx/geometry/rect.cc
+++ b/ui/gfx/geometry/rect.cc
@@ -290,4 +290,17 @@ Rect BoundingRect(const Point& p1, const Point& p2) {
return Rect(rx, ry, rr - rx, rb - ry);
}
+Point ConstrainToEnclosingRect(const Rect& rect, const Point& p) {
+ Point result = p;
+ if (result.x() < rect.x())
+ result.set_x(rect.x());
+ if (result.y() < rect.y())
+ result.set_y(rect.y());
+ if (result.x() > rect.right())
+ result.set_x(rect.right());
+ if (result.y() > rect.bottom())
+ result.set_y(rect.bottom());
+ return result;
+}
+
} // namespace gfx
« no previous file with comments | « ui/gfx/geometry/rect.h ('k') | ui/gfx/geometry/rect_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698