Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 510 // static | 510 // static |
| 511 bool FocusManager::IsTabTraversalKeyEvent(const ui::KeyEvent& key_event) { | 511 bool FocusManager::IsTabTraversalKeyEvent(const ui::KeyEvent& key_event) { |
| 512 return key_event.key_code() == ui::VKEY_TAB && !key_event.IsControlDown(); | 512 return key_event.key_code() == ui::VKEY_TAB && !key_event.IsControlDown(); |
| 513 } | 513 } |
| 514 | 514 |
| 515 void FocusManager::ViewRemoved(View* removed) { | 515 void FocusManager::ViewRemoved(View* removed) { |
| 516 // If the view being removed contains (or is) the focused view, | 516 // If the view being removed contains (or is) the focused view, |
| 517 // clear the focus. However, it's not safe to call ClearFocus() | 517 // clear the focus. However, it's not safe to call ClearFocus() |
| 518 // (and in turn ClearNativeFocus()) here because ViewRemoved() can | 518 // (and in turn ClearNativeFocus()) here because ViewRemoved() can |
| 519 // be called while the top level widget is being destroyed. | 519 // be called while the top level widget is being destroyed. |
| 520 if (focused_view_ && removed->Contains(focused_view_)) | 520 if (focused_view_ && removed && removed->Contains(focused_view_)) |
|
sky
2016/06/06 16:30:45
This code shouldn't have to check for a null suppl
| |
| 521 SetFocusedView(NULL); | 521 SetFocusedView(NULL); |
| 522 } | 522 } |
| 523 | 523 |
| 524 void FocusManager::AddFocusChangeListener(FocusChangeListener* listener) { | 524 void FocusManager::AddFocusChangeListener(FocusChangeListener* listener) { |
| 525 focus_change_listeners_.AddObserver(listener); | 525 focus_change_listeners_.AddObserver(listener); |
| 526 } | 526 } |
| 527 | 527 |
| 528 void FocusManager::RemoveFocusChangeListener(FocusChangeListener* listener) { | 528 void FocusManager::RemoveFocusChangeListener(FocusChangeListener* listener) { |
| 529 focus_change_listeners_.RemoveObserver(listener); | 529 focus_change_listeners_.RemoveObserver(listener); |
| 530 } | 530 } |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 552 // |keyboard_accessible_| is only used on Mac. | 552 // |keyboard_accessible_| is only used on Mac. |
| 553 #if defined(OS_MACOSX) | 553 #if defined(OS_MACOSX) |
| 554 return keyboard_accessible_ ? view->IsAccessibilityFocusable() | 554 return keyboard_accessible_ ? view->IsAccessibilityFocusable() |
| 555 : view->IsFocusable(); | 555 : view->IsFocusable(); |
| 556 #else | 556 #else |
| 557 return view->IsAccessibilityFocusable(); | 557 return view->IsAccessibilityFocusable(); |
| 558 #endif | 558 #endif |
| 559 } | 559 } |
| 560 | 560 |
| 561 } // namespace views | 561 } // namespace views |
| OLD | NEW |