Fixes cases where we incorrectly convert from RectF to Rect by flooring. In all cases...
[chromium-blink-merge.git] / ui / gfx / size.cc
blob6d28ded281ab4b039bd63aea70ae695214269588
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
3 // found in the LICENSE file.
5 #include "ui/gfx/size.h"
7 #if defined(OS_WIN)
8 #include <windows.h>
9 #endif
11 #include "base/logging.h"
12 #include "base/stringprintf.h"
13 #include "ui/gfx/size_base.h"
15 namespace gfx {
17 template class SizeBase<Size, int>;
19 Size::Size() : SizeBase<Size, int>(0, 0) {}
21 Size::Size(int width, int height) : SizeBase<Size, int>(0, 0) {
22 set_width(width);
23 set_height(height);
26 #if defined(OS_MACOSX)
27 Size::Size(const CGSize& s) : SizeBase<Size, int>(0, 0) {
28 set_width(s.width);
29 set_height(s.height);
32 Size& Size::operator=(const CGSize& s) {
33 set_width(s.width);
34 set_height(s.height);
35 return *this;
37 #endif
39 Size::~Size() {}
41 #if defined(OS_WIN)
42 SIZE Size::ToSIZE() const {
43 SIZE s;
44 s.cx = width();
45 s.cy = height();
46 return s;
48 #elif defined(OS_MACOSX)
49 CGSize Size::ToCGSize() const {
50 return CGSizeMake(width(), height());
52 #endif
54 std::string Size::ToString() const {
55 return base::StringPrintf("%dx%d", width(), height());
58 } // namespace gfx