summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-03 00:58:01 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-03 00:58:01 +0000
commit9d1d60bd8c4369d3b1e07a0345d5bfd831775957 (patch)
treee62bd3a6080064872152e8fcc3c45724d651d3ee
parent133ddca5e0dd084a830ca941f44790ee9d58fed2 (diff)
downloadchromium_src-9d1d60bd8c4369d3b1e07a0345d5bfd831775957.zip
chromium_src-9d1d60bd8c4369d3b1e07a0345d5bfd831775957.tar.gz
chromium_src-9d1d60bd8c4369d3b1e07a0345d5bfd831775957.tar.bz2
Fixes bug in MultiWindowResizeController where it wasn't removing
observers properly if the resizer stayed visible after a resize. BUG=139227 TEST=covered by unit tests R=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/10830148 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149756 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/wm/workspace/multi_window_resize_controller.cc11
-rw-r--r--ash/wm/workspace/multi_window_resize_controller_unittest.cc7
2 files changed, 16 insertions, 2 deletions
diff --git a/ash/wm/workspace/multi_window_resize_controller.cc b/ash/wm/workspace/multi_window_resize_controller.cc
index aa23b16..d774e58 100644
--- a/ash/wm/workspace/multi_window_resize_controller.cc
+++ b/ash/wm/workspace/multi_window_resize_controller.cc
@@ -399,6 +399,7 @@ void MultiWindowResizeController::StartResize(
ConvertPointFromScreen(windows_.window2->parent(), &location_in_parent);
std::vector<aura::Window*> windows;
windows.push_back(windows_.window2);
+ DCHECK(windows_.other_windows.empty());
FindWindowsTouching(windows_.window2, windows_.direction,
&windows_.other_windows);
for (size_t i = 0; i < windows_.other_windows.size(); ++i) {
@@ -433,8 +434,16 @@ void MultiWindowResizeController::CompleteResize(int event_flags) {
// Mouse may still be over resizer, if not hide.
gfx::Point screen_loc = gfx::Screen::GetCursorScreenPoint();
- if (!resize_widget_->GetWindowBoundsInScreen().Contains(screen_loc))
+ if (!resize_widget_->GetWindowBoundsInScreen().Contains(screen_loc)) {
Hide();
+ } else {
+ // If the mouse is over the resizer we need to remove observers on any of
+ // the |other_windows|. If we start another resize we'll recalculate the
+ // |other_windows| and invoke AddObserver() as necessary.
+ for (size_t i = 0; i < windows_.other_windows.size(); ++i)
+ windows_.other_windows[i]->RemoveObserver(this);
+ windows_.other_windows.clear();
+ }
}
void MultiWindowResizeController::CancelResize() {
diff --git a/ash/wm/workspace/multi_window_resize_controller_unittest.cc b/ash/wm/workspace/multi_window_resize_controller_unittest.cc
index 12dc0c92..6b29d6532 100644
--- a/ash/wm/workspace/multi_window_resize_controller_unittest.cc
+++ b/ash/wm/workspace/multi_window_resize_controller_unittest.cc
@@ -246,7 +246,12 @@ TEST_F(MultiWindowResizeControllerTest, Three) {
generator.MoveMouseTo(bounds.x() + 11, bounds.y() + 10);
EXPECT_TRUE(HasTarget(w3.get()));
-}
+ // Release the mouse. The resizer should still be visible and a subsequent
+ // press should not trigger a DCHECK.
+ generator.ReleaseLeftButton();
+ EXPECT_TRUE(IsShowing());
+ generator.PressLeftButton();
+}
} // namespace internal
} // namespace ash