| 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 "ui/base/ui_export.h" | 8 #include "ui/base/ui_export.h" |
| 9 | 9 |
| 10 namespace gfx { | 10 namespace gfx { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 set_height(height_ + height); | 28 set_height(height_ + height); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void set_width(Type width) { | 31 void set_width(Type width) { |
| 32 width_ = width < 0 ? 0 : width; | 32 width_ = width < 0 ? 0 : width; |
| 33 } | 33 } |
| 34 void set_height(Type height) { | 34 void set_height(Type height) { |
| 35 height_ = height < 0 ? 0 : height; | 35 height_ = height < 0 ? 0 : height; |
| 36 } | 36 } |
| 37 | 37 |
| 38 void ClampToMax(const Class& max) { | 38 void ClampToUpperBound(const Class& max) { |
| 39 width_ = width_ <= max.width_ ? width_ : max.width_; | 39 width_ = width_ <= max.width_ ? width_ : max.width_; |
| 40 height_ = height_ <= max.height_ ? height_ : max.height_; | 40 height_ = height_ <= max.height_ ? height_ : max.height_; |
| 41 } | 41 } |
| 42 | 42 |
| 43 void ClampToMin(const Class& min) { | 43 void ClampToLowerBound(const Class& min) { |
| 44 width_ = width_ >= min.width_ ? width_ : min.width_; | 44 width_ = width_ >= min.width_ ? width_ : min.width_; |
| 45 height_ = height_ >= min.height_ ? height_ : min.height_; | 45 height_ = height_ >= min.height_ ? height_ : min.height_; |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool IsEmpty() const { | 48 bool IsEmpty() const { |
| 49 return (width_ == 0) || (height_ == 0); | 49 return (width_ == 0) || (height_ == 0); |
| 50 } | 50 } |
| 51 | 51 |
| 52 protected: | 52 protected: |
| 53 SizeBase(Type width, Type height) | 53 SizeBase(Type width, Type height) |
| 54 : width_(width < 0 ? 0 : width), | 54 : width_(width < 0 ? 0 : width), |
| 55 height_(height < 0 ? 0 : height) { | 55 height_(height < 0 ? 0 : height) { |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Destructor is intentionally made non virtual and protected. | 58 // Destructor is intentionally made non virtual and protected. |
| 59 // Do not make this public. | 59 // Do not make this public. |
| 60 ~SizeBase() {} | 60 ~SizeBase() {} |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 Type width_; | 63 Type width_; |
| 64 Type height_; | 64 Type height_; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 } // namespace gfx | 67 } // namespace gfx |
| 68 | 68 |
| 69 #endif // UI_GFX_SIZE_BASE_H_ | 69 #endif // UI_GFX_SIZE_BASE_H_ |
| OLD | NEW |