OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/browser_accessibility_manager.h" | 5 #include "chrome/browser/browser_accessibility_manager.h" |
6 | 6 |
7 #include "base/scoped_comptr_win.h" | 7 #include "base/scoped_comptr_win.h" |
8 #include "chrome/browser/browser_accessibility.h" | 8 #include "chrome/browser/browser_accessibility.h" |
9 #include "chrome/browser/renderer_host/render_process_host.h" | 9 #include "chrome/browser/renderer_host/render_process_host.h" |
10 #include "chrome/browser/renderer_host/render_view_host.h" | 10 #include "chrome/browser/renderer_host/render_view_host.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // static | 23 // static |
24 // Start child IDs at -1 and decrement each time, because clients use | 24 // Start child IDs at -1 and decrement each time, because clients use |
25 // child IDs of 1, 2, 3, ... to access the children of an object by | 25 // child IDs of 1, 2, 3, ... to access the children of an object by |
26 // index, so we use negative IDs to clearly distinguish between indices | 26 // index, so we use negative IDs to clearly distinguish between indices |
27 // and unique IDs. | 27 // and unique IDs. |
28 LONG BrowserAccessibilityManager::next_child_id_ = -1; | 28 LONG BrowserAccessibilityManager::next_child_id_ = -1; |
29 | 29 |
30 BrowserAccessibilityManager::BrowserAccessibilityManager( | 30 BrowserAccessibilityManager::BrowserAccessibilityManager( |
31 HWND parent_hwnd, | 31 HWND parent_hwnd, |
32 const webkit_glue::WebAccessibility& src, | 32 const webkit_glue::WebAccessibility& src, |
| 33 BrowserAccessibilityDelegate* delegate, |
33 BrowserAccessibilityFactory* factory) | 34 BrowserAccessibilityFactory* factory) |
34 : parent_hwnd_(parent_hwnd), | 35 : parent_hwnd_(parent_hwnd), |
35 factory_(factory) { | 36 delegate_(delegate), |
| 37 factory_(factory), |
| 38 focus_(NULL) { |
36 HRESULT hr = ::CreateStdAccessibleObject( | 39 HRESULT hr = ::CreateStdAccessibleObject( |
37 parent_hwnd_, OBJID_WINDOW, IID_IAccessible, | 40 parent_hwnd_, OBJID_WINDOW, IID_IAccessible, |
38 reinterpret_cast<void **>(&window_iaccessible_)); | 41 reinterpret_cast<void **>(&window_iaccessible_)); |
39 DCHECK(SUCCEEDED(hr)); | 42 DCHECK(SUCCEEDED(hr)); |
40 root_ = CreateAccessibilityTree(NULL, src, 0); | 43 root_ = CreateAccessibilityTree(NULL, src, 0); |
41 if (!focus_) | 44 if (!focus_) |
42 focus_ = root_; | 45 focus_ = root_; |
43 } | 46 } |
44 | 47 |
45 BrowserAccessibilityManager::~BrowserAccessibilityManager() { | 48 BrowserAccessibilityManager::~BrowserAccessibilityManager() { |
(...skipping 29 matching lines...) Expand all Loading... |
75 } | 78 } |
76 | 79 |
77 BrowserAccessibility* BrowserAccessibilityManager::GetFocus( | 80 BrowserAccessibility* BrowserAccessibilityManager::GetFocus( |
78 BrowserAccessibility* root) { | 81 BrowserAccessibility* root) { |
79 if (focus_ && (!root || focus_->IsDescendantOf(root))) | 82 if (focus_ && (!root || focus_->IsDescendantOf(root))) |
80 return focus_; | 83 return focus_; |
81 | 84 |
82 return NULL; | 85 return NULL; |
83 } | 86 } |
84 | 87 |
| 88 void BrowserAccessibilityManager::SetFocus(const BrowserAccessibility& node) { |
| 89 if (delegate_) |
| 90 delegate_->SetAccessibilityFocus(node.renderer_id()); |
| 91 } |
| 92 |
| 93 void BrowserAccessibilityManager::DoDefaultAction( |
| 94 const BrowserAccessibility& node) { |
| 95 if (delegate_) |
| 96 delegate_->AccessibilityDoDefaultAction(node.renderer_id()); |
| 97 } |
| 98 |
85 void BrowserAccessibilityManager::OnAccessibilityFocusChange(int renderer_id) { | 99 void BrowserAccessibilityManager::OnAccessibilityFocusChange(int renderer_id) { |
86 base::hash_map<int, LONG>::iterator iter = | 100 base::hash_map<int, LONG>::iterator iter = |
87 renderer_id_to_child_id_map_.find(renderer_id); | 101 renderer_id_to_child_id_map_.find(renderer_id); |
88 if (iter == renderer_id_to_child_id_map_.end()) | 102 if (iter == renderer_id_to_child_id_map_.end()) |
89 return; | 103 return; |
90 | 104 |
91 LONG child_id = iter->second; | 105 LONG child_id = iter->second; |
92 base::hash_map<LONG, BrowserAccessibility*>::iterator uniq_iter = | 106 base::hash_map<LONG, BrowserAccessibility*>::iterator uniq_iter = |
93 child_id_map_.find(child_id); | 107 child_id_map_.find(child_id); |
94 if (uniq_iter != child_id_map_.end()) | 108 if (uniq_iter != child_id_map_.end()) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 if ((src.state >> WebAccessibility::STATE_FOCUSED) & 1) | 142 if ((src.state >> WebAccessibility::STATE_FOCUSED) & 1) |
129 focus_ = instance; | 143 focus_ = instance; |
130 for (int i = 0; i < static_cast<int>(src.children.size()); ++i) { | 144 for (int i = 0; i < static_cast<int>(src.children.size()); ++i) { |
131 BrowserAccessibility* child = CreateAccessibilityTree( | 145 BrowserAccessibility* child = CreateAccessibilityTree( |
132 instance, src.children[i], i); | 146 instance, src.children[i], i); |
133 instance->AddChild(child); | 147 instance->AddChild(child); |
134 } | 148 } |
135 | 149 |
136 return instance; | 150 return instance; |
137 } | 151 } |
OLD | NEW |