| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "gfx/rect.h" | 5 #include "gfx/rect.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #elif defined(OS_MACOSX) | 9 #elif defined(OS_MACOSX) |
| 10 #include <CoreGraphics/CGGeometry.h> | 10 #include <CoreGraphics/CGGeometry.h> |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 110 } |
| 111 | 111 |
| 112 void Rect::Offset(int horizontal, int vertical) { | 112 void Rect::Offset(int horizontal, int vertical) { |
| 113 origin_.Offset(horizontal, vertical); | 113 origin_.Offset(horizontal, vertical); |
| 114 } | 114 } |
| 115 | 115 |
| 116 bool Rect::operator==(const Rect& other) const { | 116 bool Rect::operator==(const Rect& other) const { |
| 117 return origin_ == other.origin_ && size_ == other.size_; | 117 return origin_ == other.origin_ && size_ == other.size_; |
| 118 } | 118 } |
| 119 | 119 |
| 120 bool Rect::operator<(const Rect& other) const { |
| 121 if (origin_ == other.origin_) { |
| 122 if (width() == other.width()) { |
| 123 return height() < other.height(); |
| 124 } else { |
| 125 return width() < other.width(); |
| 126 } |
| 127 } else { |
| 128 return origin_ < other.origin_; |
| 129 } |
| 130 } |
| 131 |
| 120 #if defined(OS_WIN) | 132 #if defined(OS_WIN) |
| 121 RECT Rect::ToRECT() const { | 133 RECT Rect::ToRECT() const { |
| 122 RECT r; | 134 RECT r; |
| 123 r.left = x(); | 135 r.left = x(); |
| 124 r.right = right(); | 136 r.right = right(); |
| 125 r.top = y(); | 137 r.top = y(); |
| 126 r.bottom = bottom(); | 138 r.bottom = bottom(); |
| 127 return r; | 139 return r; |
| 128 } | 140 } |
| 129 #elif defined(OS_MACOSX) | 141 #elif defined(OS_MACOSX) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 (x() == rect.right() || right() == rect.x())) || | 240 (x() == rect.right() || right() == rect.x())) || |
| 229 (x() == rect.x() && width() == rect.width() && | 241 (x() == rect.x() && width() == rect.width() && |
| 230 (y() == rect.bottom() || bottom() == rect.y())); | 242 (y() == rect.bottom() || bottom() == rect.y())); |
| 231 } | 243 } |
| 232 | 244 |
| 233 } // namespace gfx | 245 } // namespace gfx |
| 234 | 246 |
| 235 std::ostream& operator<<(std::ostream& out, const gfx::Rect& r) { | 247 std::ostream& operator<<(std::ostream& out, const gfx::Rect& r) { |
| 236 return out << r.origin() << " " << r.size(); | 248 return out << r.origin() << " " << r.size(); |
| 237 } | 249 } |
| OLD | NEW |