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_| | |
sky
2016/10/04 15:47:03
I think you want something like:
If the widget is
Qiang(Joe) Xu
2016/10/10 16:40:00
Done.
| |
321 // right now, we just need to store this view. | |
322 if (view && !widget_->IsActive()) { | |
323 SetStoredFocusView(view); | |
324 widget_->Activate(); | |
325 return; | |
326 } | |
327 #endif | |
328 | |
316 base::AutoReset<bool> auto_changing_focus(&is_changing_focus_, true); | 329 base::AutoReset<bool> auto_changing_focus(&is_changing_focus_, true); |
317 // Update the reason for the focus change (since this is checked by | 330 // Update the reason for the focus change (since this is checked by |
318 // some listeners), then notify all listeners. | 331 // some listeners), then notify all listeners. |
319 focus_change_reason_ = reason; | 332 focus_change_reason_ = reason; |
320 FOR_EACH_OBSERVER(FocusChangeListener, focus_change_listeners_, | 333 FOR_EACH_OBSERVER(FocusChangeListener, focus_change_listeners_, |
321 OnWillChangeFocus(focused_view_, view)); | 334 OnWillChangeFocus(focused_view_, view)); |
322 | 335 |
323 View* old_focused_view = focused_view_; | 336 View* old_focused_view = focused_view_; |
324 focused_view_ = view; | 337 focused_view_ = view; |
325 if (old_focused_view) | 338 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. | 566 // |keyboard_accessible_| is only used on Mac. |
554 #if defined(OS_MACOSX) | 567 #if defined(OS_MACOSX) |
555 return keyboard_accessible_ ? view->IsAccessibilityFocusable() | 568 return keyboard_accessible_ ? view->IsAccessibilityFocusable() |
556 : view->IsFocusable(); | 569 : view->IsFocusable(); |
557 #else | 570 #else |
558 return view->IsAccessibilityFocusable(); | 571 return view->IsAccessibilityFocusable(); |
559 #endif | 572 #endif |
560 } | 573 } |
561 | 574 |
562 } // namespace views | 575 } // namespace views |
OLD | NEW |