| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |