Chromium Code Reviews| Index: apps/size_constraints.cc |
| diff --git a/apps/size_constraints.cc b/apps/size_constraints.cc |
| index bf7729a1c2a16ef5f6b4a5b7886669a07fc70eac..5e267c09294be1f41801d3c55d924b1aa3052551 100644 |
| --- a/apps/size_constraints.cc |
| +++ b/apps/size_constraints.cc |
| @@ -17,19 +17,32 @@ SizeConstraints::SizeConstraints(const gfx::Size& min_size, |
| SizeConstraints::~SizeConstraints() {} |
| +// static |
| +gfx::Size SizeConstraints::InsetConstraints(const gfx::Size& size_constraints, |
| + const gfx::Insets& frame_insets) { |
| + return gfx::Size( |
| + size_constraints.width() == kUnboundedSize |
| + ? kUnboundedSize |
| + : size_constraints.width() - frame_insets.width(), |
|
tapted
2014/03/05 03:14:03
Do we need to worry about this going negative? Or
tmdiep
2014/03/05 04:29:06
Hmm good point. This is really just used to add in
|
| + size_constraints.height() == kUnboundedSize |
| + ? kUnboundedSize |
| + : size_constraints.height() - frame_insets.height()); |
| +} |
| + |
| gfx::Size SizeConstraints::ClampSize(gfx::Size size) const { |
| const gfx::Size max_size = GetMaximumSize(); |
| if (max_size.width() != kUnboundedSize) |
| - size.set_width(std::min(size.width(), GetMaximumSize().width())); |
| + size.set_width(std::min(size.width(), max_size.width())); |
| if (max_size.height() != kUnboundedSize) |
| - size.set_height(std::min(size.height(), GetMaximumSize().height())); |
| + size.set_height(std::min(size.height(), max_size.height())); |
| size.SetToMax(GetMinimumSize()); |
| return size; |
| } |
| bool SizeConstraints::HasMinimumSize() const { |
| - return GetMinimumSize().width() != kUnboundedSize || |
| - GetMinimumSize().height() != kUnboundedSize; |
| + const gfx::Size min_size = GetMinimumSize(); |
| + return min_size.width() != kUnboundedSize || |
| + min_size.height() != kUnboundedSize; |
| } |
| bool SizeConstraints::HasMaximumSize() const { |