summaryrefslogtreecommitdiffstats
path: root/views/widget/widget.cc
diff options
context:
space:
mode:
authorasanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-12 04:02:15 +0000
committerasanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-12 04:02:15 +0000
commitaab6916887fca00a37ea6b2c3644398337cdbd3a (patch)
tree4c2ebd2c05742f19ac94ab53c6478e727fb59f8d /views/widget/widget.cc
parentb40df40ee49eb79124ccb020f3b0d12d607ed17a (diff)
downloadchromium_src-aab6916887fca00a37ea6b2c3644398337cdbd3a.zip
chromium_src-aab6916887fca00a37ea6b2c3644398337cdbd3a.tar.gz
chromium_src-aab6916887fca00a37ea6b2c3644398337cdbd3a.tar.bz2
Avoid dangling references to Views from FocusManager.
When handling a native view hierarchy change, make sure any Views that are going to become disassociated from the FocusManager are removed from focus. BUG=75172 TEST=none Review URL: http://codereview.chromium.org/6670010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77918 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget/widget.cc')
-rw-r--r--views/widget/widget.cc19
1 files changed, 14 insertions, 5 deletions
diff --git a/views/widget/widget.cc b/views/widget/widget.cc
index c34eb09..4a58b32 100644
--- a/views/widget/widget.cc
+++ b/views/widget/widget.cc
@@ -60,15 +60,24 @@ void Widget::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
dragged_view_ = NULL;
FocusManager* focus_manager = GetFocusManager();
- if (focus_manager) {
- if (focus_manager->GetFocusedView() == child)
- focus_manager->SetFocusedView(NULL);
- focus_manager->ViewRemoved(parent, child);
- }
+ if (focus_manager)
+ focus_manager->ViewRemoved(child);
ViewStorage::GetInstance()->ViewRemoved(parent, child);
}
}
+void Widget::NotifyNativeViewHierarchyChanged(bool attached,
+ gfx::NativeView native_view) {
+ if (!attached) {
+ FocusManager* focus_manager = GetFocusManager();
+ // We are being removed from a window hierarchy. Treat this as
+ // the root_view_ being removed.
+ if (focus_manager)
+ focus_manager->ViewRemoved(root_view_.get());
+ }
+ root_view_->NotifyNativeViewHierarchyChanged(attached, native_view);
+}
+
// Converted methods (see header) ----------------------------------------------
Widget* Widget::GetTopLevelWidget() {