| 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/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 #endif | 9 #endif |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "ui/gfx/size_base.h" | 13 #include "ui/gfx/size_base.h" |
| 14 | 14 |
| 15 namespace gfx { | 15 namespace gfx { |
| 16 | 16 |
| 17 template class SizeBase<Size, int>; | 17 template class SizeBase<Size, int>; |
| 18 | 18 |
| 19 Size::Size() : SizeBase<Size, int>(0, 0) {} | |
| 20 | |
| 21 Size::Size(int width, int height) : SizeBase<Size, int>(0, 0) { | |
| 22 set_width(width); | |
| 23 set_height(height); | |
| 24 } | |
| 25 | |
| 26 #if defined(OS_MACOSX) | 19 #if defined(OS_MACOSX) |
| 27 Size::Size(const CGSize& s) : SizeBase<Size, int>(0, 0) { | 20 Size::Size(const CGSize& s) : SizeBase<Size, int>(0, 0) { |
| 28 set_width(s.width); | 21 set_width(s.width); |
| 29 set_height(s.height); | 22 set_height(s.height); |
| 30 } | 23 } |
| 31 | 24 |
| 32 Size& Size::operator=(const CGSize& s) { | 25 Size& Size::operator=(const CGSize& s) { |
| 33 set_width(s.width); | 26 set_width(s.width); |
| 34 set_height(s.height); | 27 set_height(s.height); |
| 35 return *this; | 28 return *this; |
| 36 } | 29 } |
| 37 #endif | 30 #endif |
| 38 | 31 |
| 39 Size::~Size() {} | |
| 40 | |
| 41 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
| 42 SIZE Size::ToSIZE() const { | 33 SIZE Size::ToSIZE() const { |
| 43 SIZE s; | 34 SIZE s; |
| 44 s.cx = width(); | 35 s.cx = width(); |
| 45 s.cy = height(); | 36 s.cy = height(); |
| 46 return s; | 37 return s; |
| 47 } | 38 } |
| 48 #elif defined(OS_MACOSX) | 39 #elif defined(OS_MACOSX) |
| 49 CGSize Size::ToCGSize() const { | 40 CGSize Size::ToCGSize() const { |
| 50 return CGSizeMake(width(), height()); | 41 return CGSizeMake(width(), height()); |
| 51 } | 42 } |
| 52 #endif | 43 #endif |
| 53 | 44 |
| 54 std::string Size::ToString() const { | 45 std::string Size::ToString() const { |
| 55 return base::StringPrintf("%dx%d", width(), height()); | 46 return base::StringPrintf("%dx%d", width(), height()); |
| 56 } | 47 } |
| 57 | 48 |
| 58 } // namespace gfx | 49 } // namespace gfx |
| OLD | NEW |