summaryrefslogtreecommitdiffstats
path: root/ash/wm
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-23 16:51:47 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-23 16:51:47 +0000
commitd40305001bfd61bef7e118c8580895f68d36b163 (patch)
tree05a4a731233c5cb3deb56306019231e22d474deb /ash/wm
parentea75f30985b5b24627bed4c613a1ef403235aa02 (diff)
downloadchromium_src-d40305001bfd61bef7e118c8580895f68d36b163.zip
chromium_src-d40305001bfd61bef7e118c8580895f68d36b163.tar.gz
chromium_src-d40305001bfd61bef7e118c8580895f68d36b163.tar.bz2
Make gfx::Rect class operations consistently mutate the class they are called on.
Currently some methods mutate the class, and some return a new value, requiring API users to know what kind of method they are calling each time, and making inconsistent code. For example: gfx::Rect rect; rect.Inset(1, 1, 1, 1); rect = rect.Intersect(other_rect); rect.Offset(1, 1); Instead of: gfx::Rect rect; rect.Inset(1, 1, 1, 1); rect.Intersect(other_rect); rect.Offset(1, 1); We could go either way - making the class immutable or all methods return a new instance - but I believe it is better to instead make all methods mutate the class. This allows for shorter lines of code by avoiding having to repeat the object's name twice in order to change it. This patch changes gfx::Rect classes and all the callsites that uses these methods. It should make no change in behaviour, so no new tests added. R=sky BUG=147395 Review URL: https://codereview.chromium.org/11110004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163579 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm')
-rw-r--r--ash/wm/base_layout_manager.cc4
-rw-r--r--ash/wm/partial_screenshot_view.cc4
-rw-r--r--ash/wm/shelf_layout_manager.cc6
-rw-r--r--ash/wm/system_modal_container_layout_manager.cc4
-rw-r--r--ash/wm/window_util.cc3
-rw-r--r--ash/wm/workspace/workspace_layout_manager2.cc4
-rw-r--r--ash/wm/workspace/workspace_window_resizer.cc4
7 files changed, 20 insertions, 9 deletions
diff --git a/ash/wm/base_layout_manager.cc b/ash/wm/base_layout_manager.cc
index 1bf6434a..78019cd 100644
--- a/ash/wm/base_layout_manager.cc
+++ b/ash/wm/base_layout_manager.cc
@@ -224,7 +224,9 @@ void BaseLayoutManager::AdjustWindowSizesForScreenChange() {
gfx::Rect display_rect =
ScreenAsh::GetDisplayWorkAreaBoundsInParent(window);
// Put as much of the window as possible within the display area.
- window->SetBounds(window->bounds().AdjustToFit(display_rect));
+ gfx::Rect bounds = window->bounds();
+ bounds.AdjustToFit(display_rect);
+ window->SetBounds(bounds);
}
}
}
diff --git a/ash/wm/partial_screenshot_view.cc b/ash/wm/partial_screenshot_view.cc
index 2c3e09d..dd0bd1da 100644
--- a/ash/wm/partial_screenshot_view.cc
+++ b/ash/wm/partial_screenshot_view.cc
@@ -121,8 +121,10 @@ void PartialScreenshotView::OnMouseReleased(const ui::MouseEvent& event) {
is_dragging_ = false;
if (screenshot_delegate_) {
aura::RootWindow *root_window = Shell::GetPrimaryRootWindow();
+ gfx::Rect root_window_screenshot_rect = root_window->bounds();
+ root_window_screenshot_rect.Intersect(GetScreenshotRect());
screenshot_delegate_->HandleTakePartialScreenshot(
- root_window, root_window->bounds().Intersect(GetScreenshotRect()));
+ root_window, root_window_screenshot_rect);
}
}
diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc
index 8aff1ae..307c3ba 100644
--- a/ash/wm/shelf_layout_manager.cc
+++ b/ash/wm/shelf_layout_manager.cc
@@ -746,7 +746,8 @@ void ShelfLayoutManager::UpdateTargetBoundsForGesture(
target_bounds->launcher_bounds_in_root.height() + move - translate);
// The statusbar should be in the center.
- gfx::Rect status_y = target_bounds->launcher_bounds_in_root.Center(
+ gfx::Rect status_y = target_bounds->launcher_bounds_in_root;
+ status_y.ClampToCenteredSize(
target_bounds->status_bounds_in_root.size());
target_bounds->status_bounds_in_root.set_y(status_y.y());
}
@@ -774,7 +775,8 @@ void ShelfLayoutManager::UpdateTargetBoundsForGesture(
}
// The statusbar should be in the center.
- gfx::Rect status_x = target_bounds->launcher_bounds_in_root.Center(
+ gfx::Rect status_x = target_bounds->launcher_bounds_in_root;
+ status_x.ClampToCenteredSize(
target_bounds->status_bounds_in_root.size());
target_bounds->status_bounds_in_root.set_x(status_x.x());
}
diff --git a/ash/wm/system_modal_container_layout_manager.cc b/ash/wm/system_modal_container_layout_manager.cc
index 2bfc73a..22dadc8 100644
--- a/ash/wm/system_modal_container_layout_manager.cc
+++ b/ash/wm/system_modal_container_layout_manager.cc
@@ -79,7 +79,9 @@ void SystemModalContainerLayoutManager::OnWindowResized() {
if (!modal_windows_.empty()) {
aura::Window::Windows::iterator it = modal_windows_.begin();
for (it = modal_windows_.begin(); it != modal_windows_.end(); ++it) {
- (*it)->SetBounds((*it)->bounds().AdjustToFit(container_->bounds()));
+ gfx::Rect bounds = (*it)->bounds();
+ bounds.AdjustToFit(container_->bounds());
+ (*it)->SetBounds(bounds);
}
}
}
diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc
index 8b9dcb0..55513af 100644
--- a/ash/wm/window_util.cc
+++ b/ash/wm/window_util.cc
@@ -110,7 +110,8 @@ void ToggleMaximizedWindow(aura::Window* window) {
void CenterWindow(aura::Window* window) {
const gfx::Display display =
Shell::GetScreen()->GetDisplayNearestWindow(window);
- gfx::Rect center = display.work_area().Center(window->bounds().size());
+ gfx::Rect center = display.work_area();
+ center.ClampToCenteredSize(window->bounds().size());
window->SetBounds(center);
}
diff --git a/ash/wm/workspace/workspace_layout_manager2.cc b/ash/wm/workspace/workspace_layout_manager2.cc
index 6731557..29e4c6c 100644
--- a/ash/wm/workspace/workspace_layout_manager2.cc
+++ b/ash/wm/workspace/workspace_layout_manager2.cc
@@ -289,7 +289,9 @@ void WorkspaceLayoutManager2::AdjustWindowSizeForScreenChange(
if (reason == ADJUST_WINDOW_SCREEN_SIZE_CHANGED) {
// The work area may be smaller than the full screen. Put as much of the
// window as possible within the display area.
- window->SetBounds(window->bounds().AdjustToFit(work_area_));
+ gfx::Rect bounds = window->bounds();
+ bounds.AdjustToFit(work_area_);
+ window->SetBounds(bounds);
} else if (reason == ADJUST_WINDOW_DISPLAY_INSETS_CHANGED) {
// If the window is completely outside the display work area, then move it
// enough to be visible again.
diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc
index e16ba23..d3cc9b7 100644
--- a/ash/wm/workspace/workspace_window_resizer.cc
+++ b/ash/wm/workspace/workspace_window_resizer.cc
@@ -688,8 +688,8 @@ void WorkspaceWindowResizer::UpdateDragPhantomWindow(const gfx::Rect& bounds,
const gfx::Rect root_bounds_in_screen(another_root->GetBoundsInScreen());
const gfx::Rect bounds_in_screen =
ScreenAsh::ConvertRectToScreen(window()->parent(), bounds);
- const gfx::Rect bounds_in_another_root =
- root_bounds_in_screen.Intersect(bounds_in_screen);
+ gfx::Rect bounds_in_another_root = root_bounds_in_screen;
+ bounds_in_another_root.Intersect(bounds_in_screen);
const float fraction_in_another_window =
(bounds_in_another_root.width() * bounds_in_another_root.height()) /