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

Side by Side Diff: ash/wm/common/window_positioning_utils.cc

Issue 1900443002: Removes aura dependencies from WindowPositioner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nuke GetWorkAreaForWindowInParent and fix windows Created 4 years, 8 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 | « ash/wm/common/window_positioning_utils.h ('k') | ash/wm/common/wm_globals.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/wm/common/window_positioning_utils.h"
6
7 #include <algorithm>
8
9 #include "ui/gfx/geometry/rect.h"
10 #include "ui/gfx/geometry/size.h"
11
12 namespace ash {
13 namespace wm {
14
15 void AdjustBoundsSmallerThan(const gfx::Size& max_size, gfx::Rect* bounds) {
16 bounds->set_width(std::min(bounds->width(), max_size.width()));
17 bounds->set_height(std::min(bounds->height(), max_size.height()));
18 }
19
20 void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& visible_area,
21 int min_width,
22 int min_height,
23 gfx::Rect* bounds) {
24 AdjustBoundsSmallerThan(visible_area.size(), bounds);
25
26 min_width = std::min(min_width, visible_area.width());
27 min_height = std::min(min_height, visible_area.height());
28
29 if (bounds->right() < visible_area.x() + min_width) {
30 bounds->set_x(visible_area.x() + min_width - bounds->width());
31 } else if (bounds->x() > visible_area.right() - min_width) {
32 bounds->set_x(visible_area.right() - min_width);
33 }
34 if (bounds->bottom() < visible_area.y() + min_height) {
35 bounds->set_y(visible_area.y() + min_height - bounds->height());
36 } else if (bounds->y() > visible_area.bottom() - min_height) {
37 bounds->set_y(visible_area.bottom() - min_height);
38 }
39 if (bounds->y() < visible_area.y())
40 bounds->set_y(visible_area.y());
41 }
42
43 void AdjustBoundsToEnsureMinimumWindowVisibility(const gfx::Rect& visible_area,
44 gfx::Rect* bounds) {
45 AdjustBoundsToEnsureWindowVisibility(visible_area, kMinimumOnScreenArea,
46 kMinimumOnScreenArea, bounds);
47 }
48
49 } // namespace wm
50 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/common/window_positioning_utils.h ('k') | ash/wm/common/wm_globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698