Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: ui/gfx/geometry/size.cc

Issue 662273002: gfx:: De-templatize Size and SizeF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: inlines-size: . Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/geometry/size.h ('k') | ui/gfx/geometry/size_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/geometry/size.h" 5 #include "ui/gfx/geometry/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/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 12
13 namespace gfx { 13 namespace gfx {
14 14
15 template class SizeBase<Size, int>; 15 #if defined(OS_WIN)
16 SIZE Size::ToSIZE() const {
17 SIZE s;
18 s.cx = width();
19 s.cy = height();
20 return s;
21 }
22 #endif
16 23
17 #if defined(OS_MACOSX) 24 #if defined(OS_MACOSX)
18 Size::Size(const CGSize& s)
19 : SizeBase<Size, int>(s.width, s.height) {
20 }
21
22 Size& Size::operator=(const CGSize& s) { 25 Size& Size::operator=(const CGSize& s) {
23 set_width(s.width); 26 set_width(s.width);
24 set_height(s.height); 27 set_height(s.height);
25 return *this; 28 return *this;
26 } 29 }
27 #endif 30 #endif
28 31
29 #if defined(OS_WIN) 32 int Size::GetArea() const {
30 SIZE Size::ToSIZE() const { 33 return width() * height();
31 SIZE s;
32 s.cx = width();
33 s.cy = height();
34 return s;
35 } 34 }
36 #elif defined(OS_MACOSX) 35
37 CGSize Size::ToCGSize() const { 36 void Size::Enlarge(int grow_width, int grow_height) {
38 return CGSizeMake(width(), height()); 37 SetSize(width() + grow_width, height() + grow_height);
39 } 38 }
40 #endif 39
40 void Size::SetToMin(const Size& other) {
41 width_ = width() <= other.width() ? width() : other.width();
42 height_ = height() <= other.height() ? height() : other.height();
43 }
44
45 void Size::SetToMax(const Size& other) {
46 width_ = width() >= other.width() ? width() : other.width();
47 height_ = height() >= other.height() ? height() : other.height();
48 }
41 49
42 std::string Size::ToString() const { 50 std::string Size::ToString() const {
43 return base::StringPrintf("%dx%d", width(), height()); 51 return base::StringPrintf("%dx%d", width(), height());
44 } 52 }
45 53
46 } // namespace gfx 54 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/geometry/size.h ('k') | ui/gfx/geometry/size_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698