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 "content/browser/accessibility/browser_accessibility_manager_win.h" | 5 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 | 129 |
130 void BrowserAccessibilityManagerWin::OnIAccessible2Used() { | 130 void BrowserAccessibilityManagerWin::OnIAccessible2Used() { |
131 BrowserAccessibilityStateImpl::GetInstance()->OnScreenReaderDetected(); | 131 BrowserAccessibilityStateImpl::GetInstance()->OnScreenReaderDetected(); |
132 } | 132 } |
133 | 133 |
134 void BrowserAccessibilityManagerWin::UserIsReloading() { | 134 void BrowserAccessibilityManagerWin::UserIsReloading() { |
135 if (GetRoot()) | 135 if (GetRoot()) |
136 MaybeCallNotifyWinEvent(IA2_EVENT_DOCUMENT_RELOAD, GetRoot()); | 136 MaybeCallNotifyWinEvent(IA2_EVENT_DOCUMENT_RELOAD, GetRoot()); |
137 } | 137 } |
138 | 138 |
139 BrowserAccessibility* BrowserAccessibilityManagerWin::GetFocus() { | |
140 BrowserAccessibility* node = BrowserAccessibilityManager::GetFocus(); | |
141 | |
142 // Combo boxes have an invisible list inside them which tracks the active list | |
dmazzoni
2016/04/29 20:55:54
Isn't the combo box itself supposed to have active
| |
143 // item. | |
144 if (node && node->GetRole() == ui::AX_ROLE_COMBO_BOX) { | |
dmazzoni
2016/04/29 20:55:54
Same here, only if combo box is editable?
| |
145 BrowserAccessibility* child = node->InternalGetChild(0); | |
146 if (child && child->GetRole() == ui::AX_ROLE_LIST) { | |
147 BrowserAccessibility* active_list_item = GetActiveDescendantFocus(child); | |
148 if (active_list_item != child) | |
149 return active_list_item; | |
150 } | |
151 } | |
152 | |
153 return GetActiveDescendantFocus(node); | |
154 } | |
155 | |
139 void BrowserAccessibilityManagerWin::NotifyAccessibilityEvent( | 156 void BrowserAccessibilityManagerWin::NotifyAccessibilityEvent( |
140 ui::AXEvent event_type, | 157 ui::AXEvent event_type, |
141 BrowserAccessibility* node) { | 158 BrowserAccessibility* node) { |
159 DCHECK(node); | |
142 BrowserAccessibilityDelegate* root_delegate = GetDelegateFromRootManager(); | 160 BrowserAccessibilityDelegate* root_delegate = GetDelegateFromRootManager(); |
143 if (!root_delegate || !root_delegate->AccessibilityGetAcceleratedWidget()) { | 161 if (!root_delegate || !root_delegate->AccessibilityGetAcceleratedWidget()) { |
144 DLOG(WARNING) << "Not firing AX event because of no root_delegate or hwnd"; | 162 DLOG(WARNING) << "Not firing AX event because of no root_delegate or hwnd"; |
145 return; | 163 return; |
146 } | 164 } |
147 | 165 |
148 // Don't fire events when this document might be stale as the user has | 166 // Don't fire events when this document might be stale as the user has |
149 // started navigating to a new document. | 167 // started navigating to a new document. |
150 if (user_is_navigating_away_) | 168 if (user_is_navigating_away_) |
151 return; | 169 return; |
152 | 170 |
153 // Inline text boxes are an internal implementation detail, we don't | 171 // Inline text boxes are an internal implementation detail, we don't |
154 // expose them to Windows. | 172 // expose them to Windows. |
155 if (node->GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX) | 173 if (node->GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX) |
156 return; | 174 return; |
157 | 175 |
158 LONG event_id = EVENT_MIN; | 176 LONG event_id = EVENT_MIN; |
159 switch (event_type) { | 177 switch (event_type) { |
160 case ui::AX_EVENT_ACTIVEDESCENDANTCHANGED: | 178 case ui::AX_EVENT_ACTIVEDESCENDANTCHANGED: { |
161 event_id = IA2_EVENT_ACTIVE_DESCENDANT_CHANGED; | 179 event_id = IA2_EVENT_ACTIVE_DESCENDANT_CHANGED; |
162 break; | 180 break; |
181 } | |
163 case ui::AX_EVENT_ALERT: | 182 case ui::AX_EVENT_ALERT: |
164 event_id = EVENT_SYSTEM_ALERT; | 183 event_id = EVENT_SYSTEM_ALERT; |
165 break; | 184 break; |
166 case ui::AX_EVENT_AUTOCORRECTION_OCCURED: | 185 case ui::AX_EVENT_AUTOCORRECTION_OCCURED: |
167 event_id = IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED; | 186 event_id = IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED; |
168 break; | 187 break; |
169 case ui::AX_EVENT_BLUR: | 188 case ui::AX_EVENT_BLUR: |
170 // Equivalent to focus on the root. | 189 // Equivalent to focus on the root. |
171 event_id = EVENT_OBJECT_FOCUS; | 190 event_id = EVENT_OBJECT_FOCUS; |
172 node = GetRoot(); | 191 node = GetRoot(); |
(...skipping 29 matching lines...) Expand all Loading... | |
202 node = focus_object; | 221 node = focus_object; |
203 event_id = IA2_EVENT_TEXT_CARET_MOVED; | 222 event_id = IA2_EVENT_TEXT_CARET_MOVED; |
204 break; | 223 break; |
205 } | 224 } |
206 default: | 225 default: |
207 // Not all WebKit accessibility events result in a Windows | 226 // Not all WebKit accessibility events result in a Windows |
208 // accessibility notification. | 227 // accessibility notification. |
209 break; | 228 break; |
210 } | 229 } |
211 | 230 |
212 if (!node) | |
213 return; | |
214 | |
215 if (event_id != EVENT_MIN) | 231 if (event_id != EVENT_MIN) |
216 MaybeCallNotifyWinEvent(event_id, node); | 232 MaybeCallNotifyWinEvent(event_id, node); |
217 | 233 |
218 // If this is a layout complete notification (sent when a container scrolls) | 234 // If this is a layout complete notification (sent when a container scrolls) |
219 // and there is a descendant tracked object, send a notification on it. | 235 // and there is a descendant tracked object, send a notification on it. |
220 // TODO(dmazzoni): remove once http://crbug.com/113483 is fixed. | 236 // TODO(dmazzoni): remove once http://crbug.com/113483 is fixed. |
221 if (event_type == ui::AX_EVENT_LAYOUT_COMPLETE && | 237 if (event_type == ui::AX_EVENT_LAYOUT_COMPLETE && |
222 tracked_scroll_object_ && | 238 tracked_scroll_object_ && |
223 tracked_scroll_object_->IsDescendantOf(node)) { | 239 tracked_scroll_object_->IsDescendantOf(node)) { |
224 MaybeCallNotifyWinEvent( | 240 MaybeCallNotifyWinEvent( |
225 IA2_EVENT_VISIBLE_DATA_CHANGED, tracked_scroll_object_); | 241 IA2_EVENT_VISIBLE_DATA_CHANGED, tracked_scroll_object_); |
226 tracked_scroll_object_->Release(); | 242 tracked_scroll_object_->Release(); |
227 tracked_scroll_object_ = NULL; | 243 tracked_scroll_object_ = NULL; |
228 } | 244 } |
229 } | 245 } |
230 | 246 |
231 bool BrowserAccessibilityManagerWin::CanFireEvents() { | 247 bool BrowserAccessibilityManagerWin::CanFireEvents() { |
232 BrowserAccessibilityDelegate* root_delegate = GetDelegateFromRootManager(); | 248 BrowserAccessibilityDelegate* root_delegate = GetDelegateFromRootManager(); |
233 if (!root_delegate) | 249 if (!root_delegate) |
234 return false; | 250 return false; |
235 HWND hwnd = root_delegate->AccessibilityGetAcceleratedWidget(); | 251 HWND hwnd = root_delegate->AccessibilityGetAcceleratedWidget(); |
236 return hwnd != nullptr; | 252 return hwnd != nullptr; |
237 } | 253 } |
238 | 254 |
239 void BrowserAccessibilityManagerWin::FireFocusEvent( | 255 void BrowserAccessibilityManagerWin::FireFocusEvent( |
240 BrowserAccessibility* node) { | 256 BrowserAccessibility* node) { |
257 DCHECK(node); | |
241 // On Windows, we always fire a FOCUS event on the root of a frame before | 258 // On Windows, we always fire a FOCUS event on the root of a frame before |
242 // firing a focus event within that frame. | 259 // firing a focus event within that frame. |
243 if (node->manager() != last_focused_manager_ && | 260 if (node->manager() != last_focused_manager_ && |
244 node != node->manager()->GetRoot()) { | 261 node != node->manager()->GetRoot()) { |
245 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, node->manager()->GetRoot()); | 262 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, node->manager()->GetRoot()); |
246 } | 263 } |
247 | 264 |
248 BrowserAccessibilityManager::FireFocusEvent(node); | 265 BrowserAccessibilityManager::FireFocusEvent(node); |
249 } | 266 } |
250 | 267 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
326 | 343 |
327 void BrowserAccessibilityManagerWin::TrackScrollingObject( | 344 void BrowserAccessibilityManagerWin::TrackScrollingObject( |
328 BrowserAccessibilityWin* node) { | 345 BrowserAccessibilityWin* node) { |
329 if (tracked_scroll_object_) | 346 if (tracked_scroll_object_) |
330 tracked_scroll_object_->Release(); | 347 tracked_scroll_object_->Release(); |
331 tracked_scroll_object_ = node; | 348 tracked_scroll_object_ = node; |
332 tracked_scroll_object_->AddRef(); | 349 tracked_scroll_object_->AddRef(); |
333 } | 350 } |
334 | 351 |
335 } // namespace content | 352 } // namespace content |
OLD | NEW |