Commit 1afda2ef authored by oshima@chromium.org's avatar oshima@chromium.org

Clear focused view if the focused view is in a window that is being destroyed.

Original CL (http://codereview.chromium.org/8821004/) was causing crash on some of browser_tests due to this.

BUG=104361
TEST=manual, and browser_tests now pass without crash


Review URL: http://codereview.chromium.org/8892025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114131 0039d316-1c4b-4281-b951-d872f2087c98
parent fe303c5f
...@@ -574,9 +574,6 @@ void NativeWidgetAura::OnFocus() { ...@@ -574,9 +574,6 @@ void NativeWidgetAura::OnFocus() {
if (widget->is_top_level()) { if (widget->is_top_level()) {
InputMethod* input_method = widget->GetInputMethod(); InputMethod* input_method = widget->GetInputMethod();
input_method->OnFocus(); input_method->OnFocus();
// See description of got_initial_focus_in_ for details on this.
// TODO(mazda): Investigate this is actually necessary.
// widget->GetFocusManager()->RestoreFocusedView();
} }
delegate_->OnNativeFocus(window_); delegate_->OnNativeFocus(window_);
} }
...@@ -586,7 +583,6 @@ void NativeWidgetAura::OnBlur() { ...@@ -586,7 +583,6 @@ void NativeWidgetAura::OnBlur() {
if (widget->is_top_level()) { if (widget->is_top_level()) {
InputMethod* input_method = widget->GetInputMethod(); InputMethod* input_method = widget->GetInputMethod();
input_method->OnBlur(); input_method->OnBlur();
widget->GetFocusManager()->StoreFocusedView();
} }
delegate_->OnNativeBlur(NULL); delegate_->OnNativeBlur(NULL);
} }
...@@ -672,12 +668,14 @@ bool NativeWidgetAura::ShouldActivate(aura::Event* event) { ...@@ -672,12 +668,14 @@ bool NativeWidgetAura::ShouldActivate(aura::Event* event) {
} }
void NativeWidgetAura::OnActivated() { void NativeWidgetAura::OnActivated() {
GetWidget()->GetFocusManager()->RestoreFocusedView();
delegate_->OnNativeWidgetActivationChanged(true); delegate_->OnNativeWidgetActivationChanged(true);
if (IsVisible() && GetWidget()->non_client_view()) if (IsVisible() && GetWidget()->non_client_view())
GetWidget()->non_client_view()->SchedulePaint(); GetWidget()->non_client_view()->SchedulePaint();
} }
void NativeWidgetAura::OnLostActive() { void NativeWidgetAura::OnLostActive() {
GetWidget()->GetFocusManager()->StoreFocusedView();
delegate_->OnNativeWidgetActivationChanged(false); delegate_->OnNativeWidgetActivationChanged(false);
if (IsVisible() && GetWidget()->non_client_view()) if (IsVisible() && GetWidget()->non_client_view())
GetWidget()->non_client_view()->SchedulePaint(); GetWidget()->non_client_view()->SchedulePaint();
......
...@@ -365,7 +365,6 @@ void Widget::ViewHierarchyChanged(bool is_add, View* parent, View* child) { ...@@ -365,7 +365,6 @@ void Widget::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
if (!is_add) { if (!is_add) {
if (child == dragged_view_) if (child == dragged_view_)
dragged_view_ = NULL; dragged_view_ = NULL;
FocusManager* focus_manager = GetFocusManager(); FocusManager* focus_manager = GetFocusManager();
if (focus_manager) if (focus_manager)
focus_manager->ViewRemoved(child); focus_manager->ViewRemoved(child);
...@@ -895,6 +894,10 @@ void Widget::OnNativeWidgetCreated() { ...@@ -895,6 +894,10 @@ void Widget::OnNativeWidgetCreated() {
} }
void Widget::OnNativeWidgetDestroying() { void Widget::OnNativeWidgetDestroying() {
// Tell the focus manager (if any) that root_view is being removed
// in case that the focused view is under this root view.
if (GetFocusManager())
GetFocusManager()->ViewRemoved(root_view_.get());
FOR_EACH_OBSERVER(Observer, observers_, OnWidgetClosing(this)); FOR_EACH_OBSERVER(Observer, observers_, OnWidgetClosing(this));
if (non_client_view_) if (non_client_view_)
non_client_view_->WindowClosing(); non_client_view_->WindowClosing();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment