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

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

Issue 11275243: Revert 167062 - ui: Remove gfx::Size::ClampToNonNegative, prevent negative sizes always. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « ui/gfx/rect_unittest.cc ('k') | ui/gfx/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/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/stringprintf.h" 12 #include "base/stringprintf.h"
12 #include "ui/gfx/size_base_impl.h" 13 #include "ui/gfx/size_base.h"
13 14
14 namespace gfx { 15 namespace gfx {
15 16
16 template class SizeBase<Size, int>; 17 template class SizeBase<Size, int>;
17 18
18 Size::Size() : SizeBase<Size, int>(0, 0) {} 19 Size::Size() : SizeBase<Size, int>(0, 0) {}
19 20
20 Size::Size(int width, int height) 21 Size::Size(int width, int height) : SizeBase<Size, int>(0, 0) {
21 : SizeBase<Size, int>(width, height) { 22 set_width(width);
23 set_height(height);
22 } 24 }
23 25
24 #if defined(OS_MACOSX) 26 #if defined(OS_MACOSX)
25 Size::Size(const CGSize& s) 27 Size::Size(const CGSize& s) : SizeBase<Size, int>(0, 0) {
26 : SizeBase<Size, int>(s.width, s.height) { 28 set_width(s.width);
29 set_height(s.height);
27 } 30 }
28 31
29 Size& Size::operator=(const CGSize& s) { 32 Size& Size::operator=(const CGSize& s) {
30 set_width(s.width); 33 set_width(s.width);
31 set_height(s.height); 34 set_height(s.height);
32 return *this; 35 return *this;
33 } 36 }
34 #endif 37 #endif
35 38
36 Size::~Size() {} 39 Size::~Size() {}
37 40
38 #if defined(OS_WIN) 41 #if defined(OS_WIN)
39 SIZE Size::ToSIZE() const { 42 SIZE Size::ToSIZE() const {
40 SIZE s; 43 SIZE s;
41 s.cx = width(); 44 s.cx = width();
42 s.cy = height(); 45 s.cy = height();
43 return s; 46 return s;
44 } 47 }
45 #elif defined(OS_MACOSX) 48 #elif defined(OS_MACOSX)
46 CGSize Size::ToCGSize() const { 49 CGSize Size::ToCGSize() const {
47 return CGSizeMake(width(), height()); 50 return CGSizeMake(width(), height());
48 } 51 }
49 #endif 52 #endif
50 53
51 std::string Size::ToString() const { 54 std::string Size::ToString() const {
52 return base::StringPrintf("%dx%d", width(), height()); 55 return base::StringPrintf("%dx%d", width(), height());
53 } 56 }
54 57
55 } // namespace gfx 58 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/rect_unittest.cc ('k') | ui/gfx/size_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698