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

Unified Diff: ui/aura/desktop.cc

Issue 8700013: Release aura::Desktop event handler windows on detaching an ancestor window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment block of methods. Created 9 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/desktop.cc
diff --git a/ui/aura/desktop.cc b/ui/aura/desktop.cc
index 90ee1716fc309bb76a50e7dfeace8cd369d75bda..53e08fd6cb7b714b4b60bd72d91d4664e14c61c3 100644
--- a/ui/aura/desktop.cc
+++ b/ui/aura/desktop.cc
@@ -100,6 +100,13 @@ void GetEventFiltersToNotify(Window* target, EventFilters* filters) {
}
}
+// Returns true if |descendant| is a descendant of |ancestor|.
+bool IsAncestor(Window* ancestor, Window* descendant) {
+ while (descendant && descendant != ancestor)
+ descendant = descendant->parent();
+ return descendant == ancestor;
Ben Goodger (Google) 2011/11/28 17:50:19 Rather than defining this here, can you add a Cont
flackr 2011/11/28 20:36:35 Done.
+}
+
} // namespace
Desktop* Desktop::instance_ = NULL;
@@ -533,19 +540,22 @@ void Desktop::WindowDetachedFromDesktop(Window* detached) {
// 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)
+ if (IsAncestor(detached, capture_window_) && capture_window_ != this)
sky 2011/11/28 17:20:22 Is the capture_window_ condition necessary? Also,
flackr 2011/11/28 20:36:35 Oops, seems like I converted the old statement inc
ReleaseCapture(capture_window_);
- // If the ancestor of the capture window is detached,
+ // If the ancestor of the focused window is detached,
// release the focus.
- window = focused_window_;
- while (window && window != detached)
- window = window->parent();
- if (window)
+ if (IsAncestor(detached, focused_window_))
SetFocusedWindow(NULL);
+
+ // If the ancestor of any event handler windows are detached, release the
+ // pointer to those windows.
+ if (IsAncestor(detached, mouse_pressed_handler_))
+ mouse_pressed_handler_ = NULL;
+ if (IsAncestor(detached, mouse_moved_handler_))
+ mouse_moved_handler_ = NULL;
+ if (IsAncestor(detached, touch_event_handler_))
+ touch_event_handler_ = NULL;
}
void Desktop::OnLayerAnimationEnded(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698