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 26 matching lines...) Expand all Loading... | |
37 static const int kEventFlagsMask = ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | | 37 static const int kEventFlagsMask = ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | |
38 ui::EF_ALT_DOWN; | 38 ui::EF_ALT_DOWN; |
39 #endif | 39 #endif |
40 | 40 |
41 static inline int CalculateModifiers(const ui::KeyEvent& event) { | 41 static inline int CalculateModifiers(const ui::KeyEvent& event) { |
42 return event.flags() & kEventFlagsMask; | 42 return event.flags() & kEventFlagsMask; |
43 } | 43 } |
44 | 44 |
45 } // namespace | 45 } // namespace |
46 | 46 |
47 bool FocusManager::shortcut_handling_suspended_ = false; | |
48 bool FocusManager::arrow_key_traversal_enabled_ = false; | 47 bool FocusManager::arrow_key_traversal_enabled_ = false; |
49 | 48 |
50 FocusManager::FocusManager(Widget* widget, FocusManagerDelegate* delegate) | 49 FocusManager::FocusManager(Widget* widget, FocusManagerDelegate* delegate) |
51 : widget_(widget), | 50 : widget_(widget), |
52 delegate_(delegate), | 51 delegate_(delegate), |
53 focused_view_(NULL), | 52 focused_view_(NULL), |
54 accelerator_manager_(new ui::AcceleratorManager), | 53 accelerator_manager_(new ui::AcceleratorManager), |
54 shortcut_handling_suspended_callback_(nullptr), | |
55 focus_change_reason_(kReasonDirectFocusChange), | 55 focus_change_reason_(kReasonDirectFocusChange), |
56 is_changing_focus_(false) { | 56 is_changing_focus_(false) { |
57 DCHECK(widget_); | 57 DCHECK(widget_); |
58 stored_focused_view_storage_id_ = | 58 stored_focused_view_storage_id_ = |
59 ViewStorage::GetInstance()->CreateStorageID(); | 59 ViewStorage::GetInstance()->CreateStorageID(); |
60 } | 60 } |
61 | 61 |
62 FocusManager::~FocusManager() { | 62 FocusManager::~FocusManager() { |
63 } | 63 } |
64 | 64 |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 if (text_input_client && text_input_client->HasCompositionText()) { | 495 if (text_input_client && text_input_client->HasCompositionText()) { |
496 text_input_client->ConfirmCompositionText(); | 496 text_input_client->ConfirmCompositionText(); |
497 ui::InputMethod* input_method = widget_->GetHostInputMethod(); | 497 ui::InputMethod* input_method = widget_->GetHostInputMethod(); |
498 if (input_method && input_method->GetTextInputClient() == text_input_client) | 498 if (input_method && input_method->GetTextInputClient() == text_input_client) |
499 input_method->CancelComposition(text_input_client); | 499 input_method->CancelComposition(text_input_client); |
500 } | 500 } |
501 ui::TextInputFocusManager::GetInstance()-> | 501 ui::TextInputFocusManager::GetInstance()-> |
502 BlurTextInputClient(text_input_client); | 502 BlurTextInputClient(text_input_client); |
503 } | 503 } |
504 | 504 |
505 void FocusManager::set_shortcut_handling_suspended_callback( | |
506 ReturnBoolCallback* callback) { | |
507 shortcut_handling_suspended_callback_ = callback; | |
508 } | |
509 | |
510 bool FocusManager::shortcut_handling_suspended() const { | |
511 if (!shortcut_handling_suspended_callback_) | |
Devlin
2015/01/14 21:55:18
nit: if this stays, it can be simplified to
return
| |
512 return false; | |
513 return shortcut_handling_suspended_callback_->Run(); | |
514 } | |
515 | |
505 // Find the next (previous if reverse is true) focusable view for the specified | 516 // Find the next (previous if reverse is true) focusable view for the specified |
506 // FocusTraversable, starting at the specified view, traversing down the | 517 // FocusTraversable, starting at the specified view, traversing down the |
507 // FocusTraversable hierarchy. | 518 // FocusTraversable hierarchy. |
508 View* FocusManager::FindFocusableView(FocusTraversable* focus_traversable, | 519 View* FocusManager::FindFocusableView(FocusTraversable* focus_traversable, |
509 View* starting_view, | 520 View* starting_view, |
510 bool reverse) { | 521 bool reverse) { |
511 FocusTraversable* new_focus_traversable = NULL; | 522 FocusTraversable* new_focus_traversable = NULL; |
512 View* new_starting_view = NULL; | 523 View* new_starting_view = NULL; |
513 View* v = focus_traversable->GetFocusSearch()->FindNextFocusableView( | 524 View* v = focus_traversable->GetFocusSearch()->FindNextFocusableView( |
514 starting_view, | 525 starting_view, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
606 } | 617 } |
607 if (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN) { | 618 if (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN) { |
608 AdvanceFocus(false); | 619 AdvanceFocus(false); |
609 return true; | 620 return true; |
610 } | 621 } |
611 | 622 |
612 return false; | 623 return false; |
613 } | 624 } |
614 | 625 |
615 } // namespace views | 626 } // namespace views |
OLD | NEW |