| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 143 |
| 144 // Set this flag so that we'll keep trying to fire these focus events | 144 // Set this flag so that we'll keep trying to fire these focus events |
| 145 // if they're not successful this time. | 145 // if they're not successful this time. |
| 146 focus_event_on_root_needed_ = true; | 146 focus_event_on_root_needed_ = true; |
| 147 | 147 |
| 148 if (!delegate_ || !delegate_->AccessibilityViewHasFocus()) | 148 if (!delegate_ || !delegate_->AccessibilityViewHasFocus()) |
| 149 return; | 149 return; |
| 150 | 150 |
| 151 // Try to fire a focus event on the root first and then the focused node. | 151 // Try to fire a focus event on the root first and then the focused node. |
| 152 // This will clear focus_event_on_root_needed_ if successful. | 152 // This will clear focus_event_on_root_needed_ if successful. |
| 153 if (focus_ != tree_->root()) | 153 if (focus_ != tree_->root() && GetRoot()) |
| 154 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, GetRoot()); | 154 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, GetRoot()); |
| 155 BrowserAccessibilityManager::OnWindowFocused(); | 155 BrowserAccessibilityManager::OnWindowFocused(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void BrowserAccessibilityManagerWin::UserIsReloading() { | 158 void BrowserAccessibilityManagerWin::UserIsReloading() { |
| 159 MaybeCallNotifyWinEvent(IA2_EVENT_DOCUMENT_RELOAD, GetRoot()); | 159 if (GetRoot()) |
| 160 MaybeCallNotifyWinEvent(IA2_EVENT_DOCUMENT_RELOAD, GetRoot()); |
| 160 } | 161 } |
| 161 | 162 |
| 162 void BrowserAccessibilityManagerWin::NotifyAccessibilityEvent( | 163 void BrowserAccessibilityManagerWin::NotifyAccessibilityEvent( |
| 163 ui::AXEvent event_type, | 164 ui::AXEvent event_type, |
| 164 BrowserAccessibility* node) { | 165 BrowserAccessibility* node) { |
| 165 BrowserAccessibilityDelegate* root_delegate = GetDelegateFromRootManager(); | 166 BrowserAccessibilityDelegate* root_delegate = GetDelegateFromRootManager(); |
| 166 if (!root_delegate || !root_delegate->AccessibilityGetAcceleratedWidget()) { | 167 if (!root_delegate || !root_delegate->AccessibilityGetAcceleratedWidget()) { |
| 167 LOG(WARNING) << "Not firing AX event because of no root_delegate or hwnd"; | 168 LOG(WARNING) << "Not firing AX event because of no root_delegate or hwnd"; |
| 168 return; | 169 return; |
| 169 } | 170 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 break; | 247 break; |
| 247 case ui::AX_EVENT_TEXT_SELECTION_CHANGED: | 248 case ui::AX_EVENT_TEXT_SELECTION_CHANGED: |
| 248 event_id = IA2_EVENT_TEXT_CARET_MOVED; | 249 event_id = IA2_EVENT_TEXT_CARET_MOVED; |
| 249 break; | 250 break; |
| 250 default: | 251 default: |
| 251 // Not all WebKit accessibility events result in a Windows | 252 // Not all WebKit accessibility events result in a Windows |
| 252 // accessibility notification. | 253 // accessibility notification. |
| 253 break; | 254 break; |
| 254 } | 255 } |
| 255 | 256 |
| 257 if (!node) |
| 258 return; |
| 259 |
| 256 if (event_id != EVENT_MIN) { | 260 if (event_id != EVENT_MIN) { |
| 257 // Pass the node's unique id in the |child_id| argument to NotifyWinEvent; | 261 // Pass the node's unique id in the |child_id| argument to NotifyWinEvent; |
| 258 // the AT client will then call get_accChild on the HWND's accessibility | 262 // the AT client will then call get_accChild on the HWND's accessibility |
| 259 // object and pass it that same id, which we can use to retrieve the | 263 // object and pass it that same id, which we can use to retrieve the |
| 260 // IAccessible for this node. | 264 // IAccessible for this node. |
| 261 MaybeCallNotifyWinEvent(event_id, node); | 265 MaybeCallNotifyWinEvent(event_id, node); |
| 262 } | 266 } |
| 263 | 267 |
| 264 // If this is a layout complete notification (sent when a container scrolls) | 268 // If this is a layout complete notification (sent when a container scrolls) |
| 265 // and there is a descendant tracked object, send a notification on it. | 269 // and there is a descendant tracked object, send a notification on it. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 child_manager->GetFromUniqueIdWin(unique_id_win); | 385 child_manager->GetFromUniqueIdWin(unique_id_win); |
| 382 if (result) | 386 if (result) |
| 383 return result; | 387 return result; |
| 384 } | 388 } |
| 385 } | 389 } |
| 386 | 390 |
| 387 return NULL; | 391 return NULL; |
| 388 } | 392 } |
| 389 | 393 |
| 390 } // namespace content | 394 } // namespace content |
| OLD | NEW |