summaryrefslogtreecommitdiffstats
path: root/ui/aura/desktop.cc
diff options
context:
space:
mode:
authoroshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-10 17:06:27 +0000
committeroshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-10 17:06:27 +0000
commitca163e027cdc3a8c8b8883323de2378e00acad6c (patch)
treefa6ed1d41dcc85de620ca9425ba6403ad1578edb /ui/aura/desktop.cc
parent9509f619e4b7320591f4181104a9b714fe50fb09 (diff)
downloadchromium_src-ca163e027cdc3a8c8b8883323de2378e00acad6c.zip
chromium_src-ca163e027cdc3a8c8b8883323de2378e00acad6c.tar.gz
chromium_src-ca163e027cdc3a8c8b8883323de2378e00acad6c.tar.bz2
Reset capture/focus window when the window is detachd from desktop
This was causing crash in a couple of browser tests because the desktop was accessing the focused_window which has already been deleted. BUG=103490 TEST=added new test cases to window_unittests Review URL: http://codereview.chromium.org/8510020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109443 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura/desktop.cc')
-rw-r--r--ui/aura/desktop.cc25
1 files changed, 21 insertions, 4 deletions
diff --git a/ui/aura/desktop.cc b/ui/aura/desktop.cc
index 36b9e2d..dd5cf98 100644
--- a/ui/aura/desktop.cc
+++ b/ui/aura/desktop.cc
@@ -513,10 +513,7 @@ void Desktop::SetCapture(Window* window) {
void Desktop::ReleaseCapture(Window* window) {
if (capture_window_ != window)
return;
-
- if (capture_window_ && capture_window_->delegate())
- capture_window_->delegate()->OnCaptureLost();
- capture_window_ = NULL;
+ SetCapture(NULL);
}
void Desktop::SetTransform(const ui::Transform& transform) {
@@ -613,6 +610,26 @@ Desktop* Desktop::GetDesktop() {
return this;
}
+void Desktop::WindowDetachedFromDesktop(Window* detached) {
+ DCHECK(capture_window_ != this);
+
+ // If the ancestor of the capture window is detached,
+ // release the capture.
+ aura::Window* window = capture_window_;
+ while (window && window != detached)
+ window = window->parent();
+ if (window && window != this)
+ ReleaseCapture(capture_window_);
+
+ // If the ancestor of the capture window is detached,
+ // release the focus.
+ window = focused_window_;
+ while (window && window != detached)
+ window = window->parent();
+ if (window)
+ SetFocusedWindow(NULL);
+}
+
void Desktop::OnLayerAnimationEnded(
const ui::LayerAnimationSequence* animation) {
OnHostResized(host_->GetSize());