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

Side by Side Diff: components/native_app_window/size_constraints.cc

Issue 616253002: Extract NativeAppWindow from src/extensions Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: might fix athena. similarity=33 Created 6 years, 2 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
« no previous file with comments | « components/native_app_window/size_constraints.h ('k') | extensions/browser/DEPS » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "extensions/browser/app_window/size_constraints.h" 5 #include "components/native_app_window/size_constraints.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ui/gfx/insets.h" 9 #include "ui/gfx/insets.h"
10 10
11 namespace extensions { 11 namespace native_app_window {
12 12
13 SizeConstraints::SizeConstraints() 13 SizeConstraints::SizeConstraints()
14 : maximum_size_(kUnboundedSize, kUnboundedSize) {} 14 : maximum_size_(kUnboundedSize, kUnboundedSize) {
15 }
15 16
16 SizeConstraints::SizeConstraints(const gfx::Size& min_size, 17 SizeConstraints::SizeConstraints(const gfx::Size& min_size,
17 const gfx::Size& max_size) 18 const gfx::Size& max_size)
18 : minimum_size_(min_size), maximum_size_(max_size) {} 19 : minimum_size_(min_size), maximum_size_(max_size) {
20 }
19 21
20 SizeConstraints::~SizeConstraints() {} 22 SizeConstraints::~SizeConstraints() {
23 }
21 24
22 // static 25 // static
23 gfx::Size SizeConstraints::AddFrameToConstraints( 26 gfx::Size SizeConstraints::AddFrameToConstraints(
24 const gfx::Size& size_constraints, 27 const gfx::Size& size_constraints,
25 const gfx::Insets& frame_insets) { 28 const gfx::Insets& frame_insets) {
26 return gfx::Size( 29 return gfx::Size(size_constraints.width() == kUnboundedSize
27 size_constraints.width() == kUnboundedSize 30 ? kUnboundedSize
28 ? kUnboundedSize 31 : size_constraints.width() + frame_insets.width(),
29 : size_constraints.width() + frame_insets.width(), 32 size_constraints.height() == kUnboundedSize
30 size_constraints.height() == kUnboundedSize 33 ? kUnboundedSize
31 ? kUnboundedSize 34 : size_constraints.height() + frame_insets.height());
32 : size_constraints.height() + frame_insets.height());
33 } 35 }
34 36
35 gfx::Size SizeConstraints::ClampSize(gfx::Size size) const { 37 gfx::Size SizeConstraints::ClampSize(gfx::Size size) const {
36 const gfx::Size max_size = GetMaximumSize(); 38 const gfx::Size max_size = GetMaximumSize();
37 if (max_size.width() != kUnboundedSize) 39 if (max_size.width() != kUnboundedSize)
38 size.set_width(std::min(size.width(), max_size.width())); 40 size.set_width(std::min(size.width(), max_size.width()));
39 if (max_size.height() != kUnboundedSize) 41 if (max_size.height() != kUnboundedSize)
40 size.set_height(std::min(size.height(), max_size.height())); 42 size.set_height(std::min(size.height(), max_size.height()));
41 size.SetToMax(GetMinimumSize()); 43 size.SetToMax(GetMinimumSize());
42 return size; 44 return size;
(...skipping 30 matching lines...) Expand all
73 } 75 }
74 76
75 void SizeConstraints::set_minimum_size(const gfx::Size& min_size) { 77 void SizeConstraints::set_minimum_size(const gfx::Size& min_size) {
76 minimum_size_ = min_size; 78 minimum_size_ = min_size;
77 } 79 }
78 80
79 void SizeConstraints::set_maximum_size(const gfx::Size& max_size) { 81 void SizeConstraints::set_maximum_size(const gfx::Size& max_size) {
80 maximum_size_ = max_size; 82 maximum_size_ = max_size;
81 } 83 }
82 84
83 } // namespace extensions 85 } // namespace native_app_window
OLDNEW
« no previous file with comments | « components/native_app_window/size_constraints.h ('k') | extensions/browser/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698