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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/common/window_positioning_utils.cc
diff --git a/ash/wm/common/window_positioning_utils.cc b/ash/wm/common/window_positioning_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7ba629babc2eadcc9004da5bf1fd6c96bde662ad
--- /dev/null
+++ b/ash/wm/common/window_positioning_utils.cc
@@ -0,0 +1,50 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/wm/common/window_positioning_utils.h"
+
+#include <algorithm>
+
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/size.h"
+
+namespace ash {
+namespace wm {
+
+void AdjustBoundsSmallerThan(const gfx::Size& max_size, gfx::Rect* bounds) {
+ bounds->set_width(std::min(bounds->width(), max_size.width()));
+ bounds->set_height(std::min(bounds->height(), max_size.height()));
+}
+
+void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& visible_area,
+ int min_width,
+ int min_height,
+ gfx::Rect* bounds) {
+ AdjustBoundsSmallerThan(visible_area.size(), bounds);
+
+ min_width = std::min(min_width, visible_area.width());
+ min_height = std::min(min_height, visible_area.height());
+
+ if (bounds->right() < visible_area.x() + min_width) {
+ bounds->set_x(visible_area.x() + min_width - bounds->width());
+ } else if (bounds->x() > visible_area.right() - min_width) {
+ bounds->set_x(visible_area.right() - min_width);
+ }
+ if (bounds->bottom() < visible_area.y() + min_height) {
+ bounds->set_y(visible_area.y() + min_height - bounds->height());
+ } else if (bounds->y() > visible_area.bottom() - min_height) {
+ bounds->set_y(visible_area.bottom() - min_height);
+ }
+ if (bounds->y() < visible_area.y())
+ bounds->set_y(visible_area.y());
+}
+
+void AdjustBoundsToEnsureMinimumWindowVisibility(const gfx::Rect& visible_area,
+ gfx::Rect* bounds) {
+ AdjustBoundsToEnsureWindowVisibility(visible_area, kMinimumOnScreenArea,
+ kMinimumOnScreenArea, bounds);
+}
+
+} // namespace wm
+} // namespace ash
« 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