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

Unified Diff: apps/size_constraints.cc

Issue 186343002: Create windows for new app window bounds API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nit Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « apps/size_constraints.h ('k') | apps/ui/native_app_window.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/size_constraints.cc
diff --git a/apps/size_constraints.cc b/apps/size_constraints.cc
index bf7729a1c2a16ef5f6b4a5b7886669a07fc70eac..4686965f99f5f0963bd025030bc937dcb0a6ae51 100644
--- a/apps/size_constraints.cc
+++ b/apps/size_constraints.cc
@@ -6,6 +6,8 @@
#include <algorithm>
+#include "ui/gfx/insets.h"
+
namespace apps {
SizeConstraints::SizeConstraints()
@@ -17,19 +19,33 @@ SizeConstraints::SizeConstraints(const gfx::Size& min_size,
SizeConstraints::~SizeConstraints() {}
+// static
+gfx::Size SizeConstraints::AddFrameToConstraints(
+ const gfx::Size& size_constraints,
+ const gfx::Insets& frame_insets) {
+ return gfx::Size(
+ size_constraints.width() == kUnboundedSize
+ ? kUnboundedSize
+ : size_constraints.width() + frame_insets.width(),
+ 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 {
« no previous file with comments | « apps/size_constraints.h ('k') | apps/ui/native_app_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698