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

Side by Side Diff: ui/views/focus/focus_manager.cc

Issue 108063004: Give up focus if the focused view becomes unfocusable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made View::IsFocusable() non-virtual Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/focus/focus_manager.h ('k') | ui/views/view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/focus/focus_manager.h" 5 #include "ui/views/focus/focus_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 350
351 void FocusManager::ClearFocus() { 351 void FocusManager::ClearFocus() {
352 // SetFocusedView(NULL) is going to clear out the stored view to. We need to 352 // SetFocusedView(NULL) is going to clear out the stored view to. We need to
353 // persist it in this case. 353 // persist it in this case.
354 views::View* focused_view = GetStoredFocusView(); 354 views::View* focused_view = GetStoredFocusView();
355 SetFocusedView(NULL); 355 SetFocusedView(NULL);
356 ClearNativeFocus(); 356 ClearNativeFocus();
357 SetStoredFocusView(focused_view); 357 SetStoredFocusView(focused_view);
358 } 358 }
359 359
360 void FocusManager::AdvanceFocusIfNecessary() {
361 if (widget_->IsActive()) {
sky 2014/08/08 14:52:30 nit: I would early out if !active. Less indentatio
mohsen 2014/08/08 17:45:07 Done.
362 // If widget is active and focused view is not focusable, advance focus or,
363 // if not possible, clear focus.
364 if (focused_view_ && !focused_view_->IsAccessibilityFocusable()) {
365 AdvanceFocus(false);
366 if (focused_view_ && !focused_view_->IsAccessibilityFocusable())
367 ClearFocus();
368 }
369 }
370 // If widget is inactive, there is no focused view to check. The stored view
371 // will also be checked for focusability when it is being restored.
372 }
373
360 void FocusManager::StoreFocusedView(bool clear_native_focus) { 374 void FocusManager::StoreFocusedView(bool clear_native_focus) {
361 View* focused_view = focused_view_; 375 View* focused_view = focused_view_;
362 // Don't do anything if no focused view. Storing the view (which is NULL), in 376 // Don't do anything if no focused view. Storing the view (which is NULL), in
363 // this case, would clobber the view that was previously saved. 377 // this case, would clobber the view that was previously saved.
364 if (!focused_view_) 378 if (!focused_view_)
365 return; 379 return;
366 380
367 View* v = focused_view_; 381 View* v = focused_view_;
368 382
369 if (clear_native_focus) { 383 if (clear_native_focus) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 } 599 }
586 if (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN) { 600 if (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN) {
587 AdvanceFocus(false); 601 AdvanceFocus(false);
588 return true; 602 return true;
589 } 603 }
590 604
591 return false; 605 return false;
592 } 606 }
593 607
594 } // namespace views 608 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/focus/focus_manager.h ('k') | ui/views/view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698