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

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

Issue 1092033006: [Mac/Cleanup] Trim down Foundation.h and ApplicationServices.h includes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include -> import Created 5 years, 7 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') | no next file » | 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 #elif defined(OS_IOS)
10 #include <CoreGraphics/CoreGraphics.h>
11 #elif defined(OS_MACOSX)
12 #include <ApplicationServices/ApplicationServices.h>
9 #endif 13 #endif
10 14
11 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
12 16
13 namespace gfx { 17 namespace gfx {
14 18
19 #if defined(OS_MACOSX)
20 Size::Size(const CGSize& s)
21 : width_(s.width < 0 ? 0 : s.width),
22 height_(s.height < 0 ? 0 : s.height) {
23 }
24
25 Size& Size::operator=(const CGSize& s) {
26 set_width(s.width);
27 set_height(s.height);
28 return *this;
29 }
30 #endif
31
15 #if defined(OS_WIN) 32 #if defined(OS_WIN)
16 SIZE Size::ToSIZE() const { 33 SIZE Size::ToSIZE() const {
17 SIZE s; 34 SIZE s;
18 s.cx = width(); 35 s.cx = width();
19 s.cy = height(); 36 s.cy = height();
20 return s; 37 return s;
21 } 38 }
22 #endif 39 #elif defined(OS_MACOSX)
23 40 CGSize Size::ToCGSize() const {
24 #if defined(OS_MACOSX) 41 return CGSizeMake(width(), height());
25 Size& Size::operator=(const CGSize& s) {
26 set_width(s.width);
27 set_height(s.height);
28 return *this;
29 } 42 }
30 #endif 43 #endif
31 44
32 int Size::GetArea() const { 45 int Size::GetArea() const {
33 return width() * height(); 46 return width() * height();
34 } 47 }
35 48
36 void Size::Enlarge(int grow_width, int grow_height) { 49 void Size::Enlarge(int grow_width, int grow_height) {
37 SetSize(width() + grow_width, height() + grow_height); 50 SetSize(width() + grow_width, height() + grow_height);
38 } 51 }
39 52
40 void Size::SetToMin(const Size& other) { 53 void Size::SetToMin(const Size& other) {
41 width_ = width() <= other.width() ? width() : other.width(); 54 width_ = width() <= other.width() ? width() : other.width();
42 height_ = height() <= other.height() ? height() : other.height(); 55 height_ = height() <= other.height() ? height() : other.height();
43 } 56 }
44 57
45 void Size::SetToMax(const Size& other) { 58 void Size::SetToMax(const Size& other) {
46 width_ = width() >= other.width() ? width() : other.width(); 59 width_ = width() >= other.width() ? width() : other.width();
47 height_ = height() >= other.height() ? height() : other.height(); 60 height_ = height() >= other.height() ? height() : other.height();
48 } 61 }
49 62
50 std::string Size::ToString() const { 63 std::string Size::ToString() const {
51 return base::StringPrintf("%dx%d", width(), height()); 64 return base::StringPrintf("%dx%d", width(), height());
52 } 65 }
53 66
54 } // namespace gfx 67 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/geometry/size.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698