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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/geometry/rect.h" 5 #include "ui/gfx/geometry/rect.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 283 }
284 284
285 Rect BoundingRect(const Point& p1, const Point& p2) { 285 Rect BoundingRect(const Point& p1, const Point& p2) {
286 int rx = std::min(p1.x(), p2.x()); 286 int rx = std::min(p1.x(), p2.x());
287 int ry = std::min(p1.y(), p2.y()); 287 int ry = std::min(p1.y(), p2.y());
288 int rr = std::max(p1.x(), p2.x()); 288 int rr = std::max(p1.x(), p2.x());
289 int rb = std::max(p1.y(), p2.y()); 289 int rb = std::max(p1.y(), p2.y());
290 return Rect(rx, ry, rr - rx, rb - ry); 290 return Rect(rx, ry, rr - rx, rb - ry);
291 } 291 }
292 292
293 Point ConstrainToEnclosingRect(const Rect& rect, const Point& p) {
294 Point result = p;
295 if (result.x() < rect.x())
296 result.set_x(rect.x());
297 if (result.y() < rect.y())
298 result.set_y(rect.y());
299 if (result.x() > rect.right())
300 result.set_x(rect.right());
301 if (result.y() > rect.bottom())
302 result.set_y(rect.bottom());
303 return result;
304 }
305
293 } // namespace gfx 306 } // namespace gfx
OLDNEW
« 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