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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 // Disabling keyboard accessibility may cause the focused view to become not | 306 // Disabling keyboard accessibility may cause the focused view to become not |
307 // focusable. Hence advance focus if necessary. | 307 // focusable. Hence advance focus if necessary. |
308 AdvanceFocusIfNecessary(); | 308 AdvanceFocusIfNecessary(); |
309 } | 309 } |
310 | 310 |
311 void FocusManager::SetFocusedViewWithReason( | 311 void FocusManager::SetFocusedViewWithReason( |
312 View* view, FocusChangeReason reason) { | 312 View* view, FocusChangeReason reason) { |
313 if (focused_view_ == view) | 313 if (focused_view_ == view) |
314 return; | 314 return; |
315 | 315 |
316 #if !defined(OS_MACOSX) | |
317 // TODO(warx): There are some AccessiblePaneViewTest failed on macosx. | |
318 // crbug.com/650859. Remove !defined(OS_MACOSX) once that is fixed. | |
319 // | |
320 // If |widget_| is not active, focus is not allowed to set within |widget_| | |
321 // right now, we just need to store this view and call a ClearNativeFocus (see | |
322 // the comments in View::OnFocus. | |
323 if (view && !widget_->IsActive()) { | |
324 SetStoredFocusView(view); | |
325 ClearNativeFocus(); | |
sky
2016/10/03 15:56:18
I'm wrong. It's the call to Focus() on 346 that tr
Qiang(Joe) Xu
2016/10/03 20:24:50
I agree with it. In this way, activatable ones rem
| |
326 return; | |
327 } | |
328 #endif | |
329 | |
316 base::AutoReset<bool> auto_changing_focus(&is_changing_focus_, true); | 330 base::AutoReset<bool> auto_changing_focus(&is_changing_focus_, true); |
317 // Update the reason for the focus change (since this is checked by | 331 // Update the reason for the focus change (since this is checked by |
318 // some listeners), then notify all listeners. | 332 // some listeners), then notify all listeners. |
319 focus_change_reason_ = reason; | 333 focus_change_reason_ = reason; |
320 FOR_EACH_OBSERVER(FocusChangeListener, focus_change_listeners_, | 334 FOR_EACH_OBSERVER(FocusChangeListener, focus_change_listeners_, |
321 OnWillChangeFocus(focused_view_, view)); | 335 OnWillChangeFocus(focused_view_, view)); |
322 | 336 |
323 View* old_focused_view = focused_view_; | 337 View* old_focused_view = focused_view_; |
324 focused_view_ = view; | 338 focused_view_ = view; |
325 if (old_focused_view) | 339 if (old_focused_view) |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
553 // |keyboard_accessible_| is only used on Mac. | 567 // |keyboard_accessible_| is only used on Mac. |
554 #if defined(OS_MACOSX) | 568 #if defined(OS_MACOSX) |
555 return keyboard_accessible_ ? view->IsAccessibilityFocusable() | 569 return keyboard_accessible_ ? view->IsAccessibilityFocusable() |
556 : view->IsFocusable(); | 570 : view->IsFocusable(); |
557 #else | 571 #else |
558 return view->IsAccessibilityFocusable(); | 572 return view->IsAccessibilityFocusable(); |
559 #endif | 573 #endif |
560 } | 574 } |
561 | 575 |
562 } // namespace views | 576 } // namespace views |
OLD | NEW |