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

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

Issue 11410024: ui: Remove gfx::Size::ClampToNonNegative, prevent negative sizes always. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: negative-width Created 7 years, 11 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
« no previous file with comments | « ui/gfx/size.cc ('k') | ui/gfx/size_base_impl.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 #ifndef UI_GFX_SIZE_BASE_H_ 5 #ifndef UI_GFX_SIZE_BASE_H_
6 #define UI_GFX_SIZE_BASE_H_ 6 #define UI_GFX_SIZE_BASE_H_
7 7
8 #include "ui/base/ui_export.h" 8 #include "ui/base/ui_export.h"
9 9
10 namespace gfx { 10 namespace gfx {
(...skipping 10 matching lines...) Expand all
21 void SetSize(Type width, Type height) { 21 void SetSize(Type width, Type height) {
22 set_width(width); 22 set_width(width);
23 set_height(height); 23 set_height(height);
24 } 24 }
25 25
26 void Enlarge(Type width, Type height) { 26 void Enlarge(Type width, Type height) {
27 set_width(width_ + width); 27 set_width(width_ + width);
28 set_height(height_ + height); 28 set_height(height_ + height);
29 } 29 }
30 30
31 void set_width(Type width) { width_ = width; } 31 void set_width(Type width);
32 void set_height(Type height) { height_ = height; } 32 void set_height(Type height);
33 33
34 void ClampToMax(const Class& max) { 34 void ClampToMax(const Class& max) {
35 width_ = width_ <= max.width_ ? width_ : max.width_; 35 width_ = width_ <= max.width_ ? width_ : max.width_;
36 height_ = height_ <= max.height_ ? height_ : max.height_; 36 height_ = height_ <= max.height_ ? height_ : max.height_;
37 } 37 }
38 38
39 void ClampToMin(const Class& min) { 39 void ClampToMin(const Class& min) {
40 width_ = width_ >= min.width_ ? width_ : min.width_; 40 width_ = width_ >= min.width_ ? width_ : min.width_;
41 height_ = height_ >= min.height_ ? height_ : min.height_; 41 height_ = height_ >= min.height_ ? height_ : min.height_;
42 } 42 }
43 43
44 bool IsEmpty() const { 44 bool IsEmpty() const {
45 return (width_ <= 0) || (height_ <= 0); 45 return (width_ == 0) || (height_ == 0);
46 }
47
48 void ClampToNonNegative() {
49 if (width_ < 0)
50 width_ = 0;
51 if (height_ < 0)
52 height_ = 0;
53 } 46 }
54 47
55 protected: 48 protected:
56 SizeBase(Type width, Type height) 49 SizeBase(Type width, Type height);
57 : width_(width),
58 height_(height) {}
59 50
60 // Destructor is intentionally made non virtual and protected. 51 // Destructor is intentionally made non virtual and protected.
61 // Do not make this public. 52 // Do not make this public.
62 ~SizeBase() {} 53 ~SizeBase() {}
63 54
64 private: 55 private:
65 Type width_; 56 Type width_;
66 Type height_; 57 Type height_;
67 }; 58 };
68 59
69 } // namespace gfx 60 } // namespace gfx
70 61
71 #endif // UI_GFX_SIZE_BASE_H_ 62 #endif // UI_GFX_SIZE_BASE_H_
OLDNEW
« no previous file with comments | « ui/gfx/size.cc ('k') | ui/gfx/size_base_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698