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

Side by Side Diff: ui/gfx/size_base_impl.h

Issue 10996037: Do not convert from RectF to Rect by flooring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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 | Annotate | Revision Log
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_base.h" 5 #include "ui/gfx/size_base.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 9
10 // This file provides the implementation for SizeBaese template and 10 // This file provides the implementation for SizeBaese template and
11 // used to instantiate the base class for Size and SizeF classes. 11 // used to instantiate the base class for Size and SizeF classes.
12 #if !defined(UI_IMPLEMENTATION) 12 #if !defined(UI_IMPLEMENTATION)
13 #error "This file is intended for UI implementation only" 13 #error "This file is intended for UI implementation only"
14 #endif 14 #endif
15 15
16 namespace gfx { 16 namespace gfx {
17 17
18 template<typename Class, typename Type> 18 template<typename Class, typename Type>
19 SizeBase<Class, Type>::SizeBase(Type width, Type height) { 19 SizeBase<Class, Type>::SizeBase(Type width, Type height)
20 : allow_negative_size_(false),
21 crash_if_negative_(false) {
20 set_width(width); 22 set_width(width);
21 set_height(height); 23 set_height(height);
22 } 24 }
23 25
24 template<typename Class, typename Type> 26 template<typename Class, typename Type>
25 SizeBase<Class, Type>::~SizeBase() {} 27 SizeBase<Class, Type>::~SizeBase() {}
26 28
27 template<typename Class, typename Type> 29 template<typename Class, typename Type>
28 void SizeBase<Class, Type>::set_width(Type width) { 30 void SizeBase<Class, Type>::set_width(Type width) {
29 if (width < 0) { 31 if (!allow_negative_size_ && width < 0) {
30 NOTREACHED() << "negative width:" << width; 32 if (crash_if_negative_)
33 NOTREACHED() << "negative width:" << width;
31 width = 0; 34 width = 0;
32 } 35 }
33 width_ = width; 36 width_ = width;
34 } 37 }
35 38
36 template<typename Class, typename Type> 39 template<typename Class, typename Type>
37 void SizeBase<Class, Type>::set_height(Type height) { 40 void SizeBase<Class, Type>::set_height(Type height) {
38 if (height < 0) { 41 if (!allow_negative_size_ && height < 0) {
39 NOTREACHED() << "negative height:" << height; 42 if (crash_if_negative_)
43 NOTREACHED() << "negative height:" << height;
40 height = 0; 44 height = 0;
41 } 45 }
42 height_ = height; 46 height_ = height;
43 } 47 }
44 48
45 } // namespace gfx 49 } // namespace gfx
OLDNEW
« ui/gfx/size_base.h ('K') | « ui/gfx/size_base.h ('k') | ui/ui.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698