OLD | NEW |
---|---|
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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 | 46 |
47 bool operator==(const Class& s) const { | 47 bool operator==(const Class& s) const { |
48 return width_ == s.width_ && height_ == s.height_; | 48 return width_ == s.width_ && height_ == s.height_; |
49 } | 49 } |
50 | 50 |
51 bool operator!=(const Class& s) const { | 51 bool operator!=(const Class& s) const { |
52 return !(*this == s); | 52 return !(*this == s); |
53 } | 53 } |
54 | 54 |
55 bool IsEmpty() const { | 55 bool IsEmpty() const { |
56 // Size doesn't allow negative dimensions, so testing for 0 is enough. | 56 return (width_ <= 0) || (height_ <= 0); |
57 return (width_ == 0) || (height_ == 0); | 57 } |
58 | |
59 void set_allow_negative_size(bool allow) { | |
60 allow_negative_size_ = allow; | |
61 } | |
62 | |
63 void set_crash_if_negative(bool crash) { | |
64 crash_if_negative_ = crash; | |
58 } | 65 } |
59 | 66 |
60 protected: | 67 protected: |
61 SizeBase(Type width, Type height); | 68 SizeBase(Type width, Type height); |
62 // Destructor is intentionally made non virtual and protected. | 69 // Destructor is intentionally made non virtual and protected. |
63 // Do not make this public. | 70 // Do not make this public. |
64 ~SizeBase(); | 71 ~SizeBase(); |
65 | 72 |
66 private: | 73 private: |
74 bool allow_negative_size_; | |
sky
2012/09/27 17:48:30
Having special cases where Size is some times nega
| |
75 bool crash_if_negative_; | |
67 Type width_; | 76 Type width_; |
68 Type height_; | 77 Type height_; |
69 }; | 78 }; |
70 | 79 |
71 } // namespace gfx | 80 } // namespace gfx |
72 | 81 |
73 #endif // UI_GFX_SIZE_BASE_H_ | 82 #endif // UI_GFX_SIZE_BASE_H_ |
OLD | NEW |