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 the widget isn't active store the focused view and then attempt to |
| 321 // activate the widget. If activation succeeds |view| will be focused. |
| 322 // If activation fails |view| will be focused the next time the widget is |
| 323 // made active. |
| 324 if (view && !widget_->IsActive()) { |
| 325 SetStoredFocusView(view); |
| 326 widget_->Activate(); |
| 327 return; |
| 328 } |
| 329 #endif |
| 330 |
316 base::AutoReset<bool> auto_changing_focus(&is_changing_focus_, true); | 331 base::AutoReset<bool> auto_changing_focus(&is_changing_focus_, true); |
317 // Update the reason for the focus change (since this is checked by | 332 // Update the reason for the focus change (since this is checked by |
318 // some listeners), then notify all listeners. | 333 // some listeners), then notify all listeners. |
319 focus_change_reason_ = reason; | 334 focus_change_reason_ = reason; |
320 for (FocusChangeListener& observer : focus_change_listeners_) | 335 for (FocusChangeListener& observer : focus_change_listeners_) |
321 observer.OnWillChangeFocus(focused_view_, view); | 336 observer.OnWillChangeFocus(focused_view_, view); |
322 | 337 |
323 View* old_focused_view = focused_view_; | 338 View* old_focused_view = focused_view_; |
324 focused_view_ = view; | 339 focused_view_ = view; |
325 if (old_focused_view) | 340 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. | 568 // |keyboard_accessible_| is only used on Mac. |
554 #if defined(OS_MACOSX) | 569 #if defined(OS_MACOSX) |
555 return keyboard_accessible_ ? view->IsAccessibilityFocusable() | 570 return keyboard_accessible_ ? view->IsAccessibilityFocusable() |
556 : view->IsFocusable(); | 571 : view->IsFocusable(); |
557 #else | 572 #else |
558 return view->IsAccessibilityFocusable(); | 573 return view->IsAccessibilityFocusable(); |
559 #endif | 574 #endif |
560 } | 575 } |
561 | 576 |
562 } // namespace views | 577 } // namespace views |
OLD | NEW |