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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/win/scoped_comptr.h" | 10 #include "base/win/scoped_comptr.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return delegate_->AccessibilityGetNativeViewAccessible(); | 77 return delegate_->AccessibilityGetNativeViewAccessible(); |
78 } | 78 } |
79 | 79 |
80 void BrowserAccessibilityManagerWin::MaybeCallNotifyWinEvent( | 80 void BrowserAccessibilityManagerWin::MaybeCallNotifyWinEvent( |
81 DWORD event, BrowserAccessibility* node) { | 81 DWORD event, BrowserAccessibility* node) { |
82 BrowserAccessibilityDelegate* delegate = GetDelegateFromRootManager(); | 82 BrowserAccessibilityDelegate* delegate = GetDelegateFromRootManager(); |
83 if (!delegate) { | 83 if (!delegate) { |
84 // This line and other LOG(WARNING) lines are temporary, to debug | 84 // This line and other LOG(WARNING) lines are temporary, to debug |
85 // flaky failures in DumpAccessibilityEvent* tests. | 85 // flaky failures in DumpAccessibilityEvent* tests. |
86 // http://crbug.com/440579 | 86 // http://crbug.com/440579 |
87 LOG(WARNING) << "Not firing AX event because of no delegate"; | 87 DLOG(WARNING) << "Not firing AX event because of no delegate"; |
88 return; | 88 return; |
89 } | 89 } |
90 | 90 |
91 if (!node->IsNative()) | 91 if (!node->IsNative()) |
92 return; | 92 return; |
93 | 93 |
94 HWND hwnd = delegate->AccessibilityGetAcceleratedWidget(); | 94 HWND hwnd = delegate->AccessibilityGetAcceleratedWidget(); |
95 if (!hwnd) { | 95 if (!hwnd) { |
96 LOG(WARNING) << "Not firing AX event because of no hwnd"; | 96 DLOG(WARNING) << "Not firing AX event because of no hwnd"; |
97 return; | 97 return; |
98 } | 98 } |
99 | 99 |
100 // Inline text boxes are an internal implementation detail, we don't | 100 // Inline text boxes are an internal implementation detail, we don't |
101 // expose them to Windows. | 101 // expose them to Windows. |
102 if (node->GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX) | 102 if (node->GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX) |
103 return; | 103 return; |
104 | 104 |
105 // It doesn't make sense to fire a REORDER event on a leaf node; that | 105 // It doesn't make sense to fire a REORDER event on a leaf node; that |
106 // happens when the node has internal children line inline text boxes. | 106 // happens when the node has internal children line inline text boxes. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 void BrowserAccessibilityManagerWin::UserIsReloading() { | 168 void BrowserAccessibilityManagerWin::UserIsReloading() { |
169 if (GetRoot()) | 169 if (GetRoot()) |
170 MaybeCallNotifyWinEvent(IA2_EVENT_DOCUMENT_RELOAD, GetRoot()); | 170 MaybeCallNotifyWinEvent(IA2_EVENT_DOCUMENT_RELOAD, GetRoot()); |
171 } | 171 } |
172 | 172 |
173 void BrowserAccessibilityManagerWin::NotifyAccessibilityEvent( | 173 void BrowserAccessibilityManagerWin::NotifyAccessibilityEvent( |
174 ui::AXEvent event_type, | 174 ui::AXEvent event_type, |
175 BrowserAccessibility* node) { | 175 BrowserAccessibility* node) { |
176 BrowserAccessibilityDelegate* root_delegate = GetDelegateFromRootManager(); | 176 BrowserAccessibilityDelegate* root_delegate = GetDelegateFromRootManager(); |
177 if (!root_delegate || !root_delegate->AccessibilityGetAcceleratedWidget()) { | 177 if (!root_delegate || !root_delegate->AccessibilityGetAcceleratedWidget()) { |
178 LOG(WARNING) << "Not firing AX event because of no root_delegate or hwnd"; | 178 DLOG(WARNING) << "Not firing AX event because of no root_delegate or hwnd"; |
179 return; | 179 return; |
180 } | 180 } |
181 | 181 |
182 // Don't fire events when this document might be stale as the user has | 182 // Don't fire events when this document might be stale as the user has |
183 // started navigating to a new document. | 183 // started navigating to a new document. |
184 if (user_is_navigating_away_) | 184 if (user_is_navigating_away_) |
185 return; | 185 return; |
186 | 186 |
187 // Inline text boxes are an internal implementation detail, we don't | 187 // Inline text boxes are an internal implementation detail, we don't |
188 // expose them to Windows. | 188 // expose them to Windows. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 break; | 248 break; |
249 case ui::AX_EVENT_SCROLL_POSITION_CHANGED: | 249 case ui::AX_EVENT_SCROLL_POSITION_CHANGED: |
250 event_id = EVENT_SYSTEM_SCROLLINGEND; | 250 event_id = EVENT_SYSTEM_SCROLLINGEND; |
251 break; | 251 break; |
252 case ui::AX_EVENT_SCROLLED_TO_ANCHOR: | 252 case ui::AX_EVENT_SCROLLED_TO_ANCHOR: |
253 event_id = EVENT_SYSTEM_SCROLLINGSTART; | 253 event_id = EVENT_SYSTEM_SCROLLINGSTART; |
254 break; | 254 break; |
255 case ui::AX_EVENT_SELECTED_CHILDREN_CHANGED: | 255 case ui::AX_EVENT_SELECTED_CHILDREN_CHANGED: |
256 event_id = EVENT_OBJECT_SELECTIONWITHIN; | 256 event_id = EVENT_OBJECT_SELECTIONWITHIN; |
257 break; | 257 break; |
258 case ui::AX_EVENT_TEXT_SELECTION_CHANGED: | 258 case ui::AX_EVENT_DOCUMENT_SELECTION_CHANGED: { |
| 259 // Fire the event on the object where the focus of the selection is. |
| 260 int32 focus_id = GetTreeData().sel_focus_object_id; |
| 261 BrowserAccessibility* focus_object = GetFromID(focus_id); |
| 262 if (focus_object) |
| 263 node = focus_object; |
259 event_id = IA2_EVENT_TEXT_CARET_MOVED; | 264 event_id = IA2_EVENT_TEXT_CARET_MOVED; |
260 break; | 265 break; |
| 266 } |
261 default: | 267 default: |
262 // Not all WebKit accessibility events result in a Windows | 268 // Not all WebKit accessibility events result in a Windows |
263 // accessibility notification. | 269 // accessibility notification. |
264 break; | 270 break; |
265 } | 271 } |
266 | 272 |
267 if (!node) | 273 if (!node) |
268 return; | 274 return; |
269 | 275 |
270 if (event_id != EVENT_MIN) { | 276 if (event_id != EVENT_MIN) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 return nullptr; | 413 return nullptr; |
408 | 414 |
409 BrowserAccessibility* result = GetFromID(iter->second); | 415 BrowserAccessibility* result = GetFromID(iter->second); |
410 if (result && result->IsNative()) | 416 if (result && result->IsNative()) |
411 return result->ToBrowserAccessibilityWin(); | 417 return result->ToBrowserAccessibilityWin(); |
412 | 418 |
413 return nullptr; | 419 return nullptr; |
414 } | 420 } |
415 | 421 |
416 } // namespace content | 422 } // namespace content |
OLD | NEW |