| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 65 | 65 |
| 66 void Rect::Inset(int left, int top, int right, int bottom) { | 66 void Rect::Inset(int left, int top, int right, int bottom) { |
| 67 origin_ += Vector2d(left, top); | 67 origin_ += Vector2d(left, top); |
| 68 set_width(std::max(width() - left - right, static_cast<int>(0))); | 68 set_width(std::max(width() - left - right, static_cast<int>(0))); |
| 69 set_height(std::max(height() - top - bottom, static_cast<int>(0))); | 69 set_height(std::max(height() - top - bottom, static_cast<int>(0))); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void Rect::Offset(int horizontal, int vertical) { | 72 void Rect::Offset(int horizontal, int vertical) { |
| 73 origin_ += Vector2d(horizontal, vertical); | 73 origin_ += Vector2d(horizontal, vertical); |
| 74 // Ensure that width and height remain valid. |
| 75 set_width(width()); |
| 76 set_height(height()); |
| 74 } | 77 } |
| 75 | 78 |
| 76 void Rect::operator+=(const Vector2d& offset) { | 79 void Rect::operator+=(const Vector2d& offset) { |
| 77 origin_ += offset; | 80 origin_ += offset; |
| 81 // Ensure that width and height remain valid. |
| 82 set_width(width()); |
| 83 set_height(height()); |
| 78 } | 84 } |
| 79 | 85 |
| 80 void Rect::operator-=(const Vector2d& offset) { | 86 void Rect::operator-=(const Vector2d& offset) { |
| 81 origin_ -= offset; | 87 origin_ -= offset; |
| 82 } | 88 } |
| 83 | 89 |
| 84 Insets Rect::InsetsFrom(const Rect& inner) const { | 90 Insets Rect::InsetsFrom(const Rect& inner) const { |
| 85 return Insets(inner.y() - y(), | 91 return Insets(inner.y() - y(), |
| 86 inner.x() - x(), | 92 inner.x() - x(), |
| 87 bottom() - inner.bottom(), | 93 bottom() - inner.bottom(), |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 | 290 |
| 285 Rect BoundingRect(const Point& p1, const Point& p2) { | 291 Rect BoundingRect(const Point& p1, const Point& p2) { |
| 286 int rx = std::min(p1.x(), p2.x()); | 292 int rx = std::min(p1.x(), p2.x()); |
| 287 int ry = std::min(p1.y(), p2.y()); | 293 int ry = std::min(p1.y(), p2.y()); |
| 288 int rr = std::max(p1.x(), p2.x()); | 294 int rr = std::max(p1.x(), p2.x()); |
| 289 int rb = std::max(p1.y(), p2.y()); | 295 int rb = std::max(p1.y(), p2.y()); |
| 290 return Rect(rx, ry, rr - rx, rb - ry); | 296 return Rect(rx, ry, rr - rx, rb - ry); |
| 291 } | 297 } |
| 292 | 298 |
| 293 } // namespace gfx | 299 } // namespace gfx |
| OLD | NEW |