| OLD | NEW |
| 1 // Copyright (c) 2006-2008 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/size.h" | 5 #include "ui/gfx/size.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 #endif | 11 #endif |
| 12 | 12 |
| 13 #include <ostream> | |
| 14 | |
| 15 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/stringprintf.h" |
| 16 | 15 |
| 17 namespace gfx { | 16 namespace gfx { |
| 18 | 17 |
| 18 Size::Size() : width_(0), height_(0) {} |
| 19 |
| 19 Size::Size(int width, int height) { | 20 Size::Size(int width, int height) { |
| 20 set_width(width); | 21 set_width(width); |
| 21 set_height(height); | 22 set_height(height); |
| 22 } | 23 } |
| 23 | 24 |
| 24 #if defined(OS_MACOSX) | 25 #if defined(OS_MACOSX) |
| 25 Size::Size(const CGSize& s) { | 26 Size::Size(const CGSize& s) { |
| 26 set_width(s.width); | 27 set_width(s.width); |
| 27 set_height(s.height); | 28 set_height(s.height); |
| 28 } | 29 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 56 } | 57 } |
| 57 | 58 |
| 58 void Size::set_height(int height) { | 59 void Size::set_height(int height) { |
| 59 if (height < 0) { | 60 if (height < 0) { |
| 60 NOTREACHED() << "negative height:" << height; | 61 NOTREACHED() << "negative height:" << height; |
| 61 height = 0; | 62 height = 0; |
| 62 } | 63 } |
| 63 height_ = height; | 64 height_ = height; |
| 64 } | 65 } |
| 65 | 66 |
| 66 std::ostream& operator<<(std::ostream& out, const gfx::Size& s) { | 67 std::string Size::ToString() const { |
| 67 return out << s.width() << "x" << s.height(); | 68 return base::StringPrintf("%dx%d", width_, height_); |
| 68 } | 69 } |
| 69 | 70 |
| 70 } // namespace gfx | 71 } // namespace gfx |
| OLD | NEW |