| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/rect.h" | 5 #include "ui/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> |
| 11 #elif defined(TOOLKIT_USES_GTK) | 11 #elif defined(TOOLKIT_USES_GTK) |
| 12 #include <gdk/gdk.h> | 12 #include <gdk/gdk.h> |
| 13 #endif | 13 #endif |
| 14 #if defined(USE_WAYLAND) | 14 #if defined(USE_WAYLAND) |
| 15 #include <cairo.h> | 15 #include <cairo.h> |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/stringprintf.h" | 19 #include "base/stringprintf.h" |
| 20 #include "ui/gfx/insets.h" | 20 #include "ui/gfx/insets.h" |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 void AdjustAlongAxis(int dst_origin, int dst_size, int* origin, int* size) { | 24 void AdjustAlongAxis(int dst_origin, int dst_size, int* origin, int* size) { |
| 25 if (*origin < dst_origin) { | 25 *size = std::min(dst_size, *size); |
| 26 if (*origin < dst_origin) |
| 26 *origin = dst_origin; | 27 *origin = dst_origin; |
| 27 *size = std::min(dst_size, *size); | 28 else |
| 28 } else { | |
| 29 *size = std::min(dst_size, *size); | |
| 30 *origin = std::min(dst_origin + dst_size, *origin + *size) - *size; | 29 *origin = std::min(dst_origin + dst_size, *origin + *size) - *size; |
| 31 } | |
| 32 } | 30 } |
| 33 | 31 |
| 34 } // namespace | 32 } // namespace |
| 35 | 33 |
| 36 namespace gfx { | 34 namespace gfx { |
| 37 | 35 |
| 38 Rect::Rect() { | 36 Rect::Rect() { |
| 39 } | 37 } |
| 40 | 38 |
| 41 Rect::Rect(int width, int height) | 39 Rect::Rect(int width, int height) |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 (y() == rect.bottom() || bottom() == rect.y())); | 283 (y() == rect.bottom() || bottom() == rect.y())); |
| 286 } | 284 } |
| 287 | 285 |
| 288 std::string Rect::ToString() const { | 286 std::string Rect::ToString() const { |
| 289 return base::StringPrintf("%s %s", | 287 return base::StringPrintf("%s %s", |
| 290 origin_.ToString().c_str(), | 288 origin_.ToString().c_str(), |
| 291 size_.ToString().c_str()); | 289 size_.ToString().c_str()); |
| 292 } | 290 } |
| 293 | 291 |
| 294 } // namespace gfx | 292 } // namespace gfx |
| OLD | NEW |