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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 SetFocusedView(NULL); | 380 SetFocusedView(NULL); |
| 381 SetStoredFocusView(focused_view); | 381 SetStoredFocusView(focused_view); |
| 382 } | 382 } |
| 383 | 383 |
| 384 if (v) | 384 if (v) |
| 385 v->SchedulePaint(); // Remove focus border. | 385 v->SchedulePaint(); // Remove focus border. |
| 386 } | 386 } |
| 387 | 387 |
| 388 bool FocusManager::RestoreFocusedView() { | 388 bool FocusManager::RestoreFocusedView() { |
| 389 View* view = GetStoredFocusView(); | 389 View* view = GetStoredFocusView(); |
| 390 if (view && ContainsView(view)) { | 390 if (view) { |
|
karandeepb
2016/05/13 09:05:31
This is the same as the code before https://codere
| |
| 391 // This usually just sets the focus if this view is accessibility | 391 if (ContainsView(view)) { |
| 392 // focusable, but let the view override RequestFocus if necessary. | 392 if (!view->IsFocusable() && view->IsAccessibilityFocusable()) { |
| 393 view->RequestFocus(); | 393 // RequestFocus would fail, but we want to restore focus to controls |
| 394 // that had focus in accessibility mode. | |
| 395 SetFocusedViewWithReason(view, kReasonFocusRestore); | |
| 396 } else { | |
| 397 // This usually just sets the focus if this view is focusable, but | |
| 398 // let the view override RequestFocus if necessary. | |
| 399 view->RequestFocus(); | |
| 394 | 400 |
| 395 // If it succeeded, the reason would be incorrect; set it to | 401 // If it succeeded, the reason would be incorrect; set it to |
| 396 // focus restore. | 402 // focus restore. |
| 397 if (focused_view_ == view) | 403 if (focused_view_ == view) |
| 398 focus_change_reason_ = kReasonFocusRestore; | 404 focus_change_reason_ = kReasonFocusRestore; |
| 399 | 405 } |
| 406 } | |
| 400 // The |keyboard_accessible_| mode may have changed while the widget was | 407 // The |keyboard_accessible_| mode may have changed while the widget was |
| 401 // inactive. | 408 // inactive. |
| 402 AdvanceFocusIfNecessary(); | 409 AdvanceFocusIfNecessary(); |
| 403 } | 410 } |
| 404 return view && view == focused_view_; | 411 return view && view == focused_view_; |
| 405 } | 412 } |
| 406 | 413 |
| 407 void FocusManager::SetStoredFocusView(View* focus_view) { | 414 void FocusManager::SetStoredFocusView(View* focus_view) { |
| 408 ViewStorage* view_storage = ViewStorage::GetInstance(); | 415 ViewStorage* view_storage = ViewStorage::GetInstance(); |
| 409 if (!view_storage) { | 416 if (!view_storage) { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 // |keyboard_accessible_| is only used on Mac. | 552 // |keyboard_accessible_| is only used on Mac. |
| 546 #if defined(OS_MACOSX) | 553 #if defined(OS_MACOSX) |
| 547 return keyboard_accessible_ ? view->IsAccessibilityFocusable() | 554 return keyboard_accessible_ ? view->IsAccessibilityFocusable() |
| 548 : view->IsFocusable(); | 555 : view->IsFocusable(); |
| 549 #else | 556 #else |
| 550 return view->IsAccessibilityFocusable(); | 557 return view->IsAccessibilityFocusable(); |
| 551 #endif | 558 #endif |
| 552 } | 559 } |
| 553 | 560 |
| 554 } // namespace views | 561 } // namespace views |
| OLD | NEW |