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

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

Issue 11365160: ui: Remove gfx::Size::ClampToNonNegative, prevent negative sizes always. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix unit tests that use negative values or NaN 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"
12 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
13 #include "ui/gfx/size_base.h" 12 #include "ui/gfx/size_base_impl.h"
14 13
15 namespace gfx { 14 namespace gfx {
16 15
17 template class SizeBase<Size, int>; 16 template class SizeBase<Size, int>;
18 17
19 Size::Size() : SizeBase<Size, int>(0, 0) {} 18 Size::Size() : SizeBase<Size, int>(0, 0) {}
20 19
21 Size::Size(int width, int height) : SizeBase<Size, int>(0, 0) { 20 Size::Size(int width, int height)
22 set_width(width); 21 : SizeBase<Size, int>(width, height) {
23 set_height(height);
24 } 22 }
25 23
26 #if defined(OS_MACOSX) 24 #if defined(OS_MACOSX)
27 Size::Size(const CGSize& s) : SizeBase<Size, int>(0, 0) { 25 Size::Size(const CGSize& s)
28 set_width(s.width); 26 : SizeBase<Size, int>(s.width, s.height) {
29 set_height(s.height);
30 } 27 }
31 28
32 Size& Size::operator=(const CGSize& s) { 29 Size& Size::operator=(const CGSize& s) {
33 set_width(s.width); 30 set_width(s.width);
34 set_height(s.height); 31 set_height(s.height);
35 return *this; 32 return *this;
36 } 33 }
37 #endif 34 #endif
38 35
39 Size::~Size() {} 36 Size::~Size() {}
40 37
41 #if defined(OS_WIN) 38 #if defined(OS_WIN)
42 SIZE Size::ToSIZE() const { 39 SIZE Size::ToSIZE() const {
43 SIZE s; 40 SIZE s;
44 s.cx = width(); 41 s.cx = width();
45 s.cy = height(); 42 s.cy = height();
46 return s; 43 return s;
47 } 44 }
48 #elif defined(OS_MACOSX) 45 #elif defined(OS_MACOSX)
49 CGSize Size::ToCGSize() const { 46 CGSize Size::ToCGSize() const {
50 return CGSizeMake(width(), height()); 47 return CGSizeMake(width(), height());
51 } 48 }
52 #endif 49 #endif
53 50
54 std::string Size::ToString() const { 51 std::string Size::ToString() const {
55 return base::StringPrintf("%dx%d", width(), height()); 52 return base::StringPrintf("%dx%d", width(), height());
56 } 53 }
57 54
58 } // namespace gfx 55 } // 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