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

Unified Diff: ui/views/focus/focus_manager.cc

Issue 2696223003: [Not For Review] Handle a view that that isn't a part of Widget tree focusManager handles (Closed)
Patch Set: Created 3 years, 10 months 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/views/focus/focus_manager.cc
diff --git a/ui/views/focus/focus_manager.cc b/ui/views/focus/focus_manager.cc
index b482dbe5128b40112ffb0572db11f019d819834f..3a045cb0cd729999245046b63cedb06cf321d4c1 100644
--- a/ui/views/focus/focus_manager.cc
+++ b/ui/views/focus/focus_manager.cc
@@ -301,9 +301,6 @@ void FocusManager::SetFocusedViewWithReason(
View* view, FocusChangeReason reason) {
if (focused_view_ == view)
return;
- // TODO(oshima|achuith): This is to diagnose crbug.com/687232.
- // Change this to DCHECK once it's resolved.
- CHECK(!view || ContainsView(view));
#if !defined(OS_MACOSX)
// TODO(warx): There are some AccessiblePaneViewTest failed on macosx.
@@ -327,15 +324,26 @@ void FocusManager::SetFocusedViewWithReason(
observer.OnWillChangeFocus(focused_view_, view);
View* old_focused_view = focused_view_;
- focused_view_ = view;
+
+ bool focused_view_on_other_widget = view && !ContainsView(view);
+ if (focused_view_on_other_widget) {
+ focused_view_ = nullptr;
+ } else {
+ focused_view_ = view;
+ }
if (old_focused_view)
old_focused_view->Blur();
// Also make |focused_view_| the stored focus view. This way the stored focus
// view is remembered if focus changes are requested prior to a show or while
// hidden.
- SetStoredFocusView(focused_view_);
- if (focused_view_)
+ if (!focused_view_on_other_widget) {
+ SetStoredFocusView(focused_view_);
+ }
+ if (focused_view_) {
focused_view_->Focus();
+ } else if (view) {
+ view->RequestFocus();
+ }
for (FocusChangeListener& observer : focus_change_listeners_)
observer.OnDidChangeFocus(old_focused_view, focused_view_);
« 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