OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "views/focus/focus_manager.h" | 5 #include "views/focus/focus_manager.h" |
6 | 6 |
7 #include "views/view.h" | 7 #include "views/view.h" |
8 #include "views/widget/widget_win.h" | 8 #include "views/widget/widget_win.h" |
9 | 9 |
10 namespace views { | 10 namespace views { |
11 | 11 |
12 void FocusManager::ClearNativeFocus() { | 12 void FocusManager::ClearNativeFocus() { |
13 // Keep the top root window focused so we get keyboard events. | 13 // Keep the top root window focused so we get keyboard events. |
14 ::SetFocus(widget_->GetNativeView()); | 14 ::SetFocus(widget_->GetNativeView()); |
15 | |
16 // We need to let assistive technologies know which child view got focus so | |
17 // they can obtain the proper accessibility object for that child view. | |
18 if (focused_view_) { | |
19 focused_view_->NotifyAccessibilityEvent(AccessibilityTypes::EVENT_FOCUS); | |
20 } | |
21 } | 15 } |
22 | 16 |
23 void FocusManager::FocusNativeView(gfx::NativeView native_view) { | 17 void FocusManager::FocusNativeView(gfx::NativeView native_view) { |
24 // Only reset focus if hwnd is not already focused. | 18 // Only reset focus if hwnd is not already focused. |
25 if (native_view && ::GetFocus() != native_view) | 19 if (native_view && ::GetFocus() != native_view) |
26 ::SetFocus(native_view); | 20 ::SetFocus(native_view); |
27 } | 21 } |
28 | 22 |
29 // static | 23 // static |
30 FocusManager* FocusManager::GetFocusManagerForNativeView( | 24 FocusManager* FocusManager::GetFocusManagerForNativeView( |
31 gfx::NativeView native_view) { | 25 gfx::NativeView native_view) { |
32 WidgetWin* widget = WidgetWin::GetRootWidget(native_view); | 26 WidgetWin* widget = WidgetWin::GetRootWidget(native_view); |
33 return widget ? widget->GetFocusManager() : NULL; | 27 return widget ? widget->GetFocusManager() : NULL; |
34 } | 28 } |
35 | 29 |
36 // static | 30 // static |
37 FocusManager* FocusManager::GetFocusManagerForNativeWindow( | 31 FocusManager* FocusManager::GetFocusManagerForNativeWindow( |
38 gfx::NativeWindow native_window) { | 32 gfx::NativeWindow native_window) { |
39 return GetFocusManagerForNativeView(native_window); | 33 return GetFocusManagerForNativeView(native_window); |
40 } | 34 } |
41 | 35 |
42 } // namespace views | 36 } // namespace views |
OLD | NEW |