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_mac.h" | 5 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" |
6 | 6 |
7 #import "base/logging.h" | 7 #import "base/logging.h" |
8 #import "content/browser/accessibility/browser_accessibility_cocoa.h" | 8 #import "content/browser/accessibility/browser_accessibility_cocoa.h" |
9 #import "content/browser/accessibility/browser_accessibility_mac.h" | 9 #import "content/browser/accessibility/browser_accessibility_mac.h" |
10 #include "content/common/accessibility_messages.h" | 10 #include "content/common/accessibility_messages.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 DCHECK(native_node); | 143 DCHECK(native_node); |
144 NSAccessibilityPostNotification(native_node, event_id); | 144 NSAccessibilityPostNotification(native_node, event_id); |
145 } | 145 } |
146 | 146 |
147 void BrowserAccessibilityManagerMac::OnAtomicUpdateFinished( | 147 void BrowserAccessibilityManagerMac::OnAtomicUpdateFinished( |
148 bool root_changed, const std::vector<ui::AXTreeDelegate::Change>& changes) { | 148 bool root_changed, const std::vector<ui::AXTreeDelegate::Change>& changes) { |
149 BrowserAccessibilityManager::OnAtomicUpdateFinished(root_changed, changes); | 149 BrowserAccessibilityManager::OnAtomicUpdateFinished(root_changed, changes); |
150 | 150 |
151 bool created_live_region = false; | 151 bool created_live_region = false; |
152 for (size_t i = 0; i < changes.size(); ++i) { | 152 for (size_t i = 0; i < changes.size(); ++i) { |
| 153 if (changes[i].type != NODE_CREATED && changes[i].type != SUBTREE_CREATED) |
| 154 continue; |
153 BrowserAccessibility* obj = GetFromAXNode(changes[i].node); | 155 BrowserAccessibility* obj = GetFromAXNode(changes[i].node); |
154 if (obj && obj->HasStringAttribute(ui::AX_ATTR_LIVE_STATUS)) { | 156 if (obj && obj->HasStringAttribute(ui::AX_ATTR_LIVE_STATUS)) { |
155 created_live_region = true; | 157 created_live_region = true; |
156 break; | 158 break; |
157 } | 159 } |
158 } | 160 } |
159 | 161 |
160 if (!created_live_region) | 162 if (!created_live_region) |
161 return; | 163 return; |
162 | 164 |
163 // This code is to work around a bug in VoiceOver, where a new live | 165 // This code is to work around a bug in VoiceOver, where a new live |
164 // region that gets added is ignored. VoiceOver seems to only scan the | 166 // region that gets added is ignored. VoiceOver seems to only scan the |
165 // page for live regions once. By recreating the NSAccessibility | 167 // page for live regions once. By recreating the NSAccessibility |
166 // object for the root of the tree, we force VoiceOver to clear out its | 168 // object for the root of the tree, we force VoiceOver to clear out its |
167 // internal state and find newly-added live regions this time. | 169 // internal state and find newly-added live regions this time. |
168 BrowserAccessibilityMac* root = | 170 BrowserAccessibilityMac* root = |
169 static_cast<BrowserAccessibilityMac*>(GetRoot()); | 171 static_cast<BrowserAccessibilityMac*>(GetRoot()); |
170 root->RecreateNativeObject(); | 172 root->RecreateNativeObject(); |
171 NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, root); | 173 NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, root); |
172 } | 174 } |
173 | 175 |
174 } // namespace content | 176 } // namespace content |
OLD | NEW |