Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(503)

Side by Side Diff: content/browser/accessibility/browser_accessibility_manager_mac.mm

Issue 830943004: Improve the notifications sent from AXTree updates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback, add missing call to parent class Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 11
12 namespace content { 12 namespace content {
13 13
14 // static 14 // static
15 BrowserAccessibilityManager* BrowserAccessibilityManager::Create( 15 BrowserAccessibilityManager* BrowserAccessibilityManager::Create(
16 const ui::AXTreeUpdate& initial_tree, 16 const ui::AXTreeUpdate& initial_tree,
17 BrowserAccessibilityDelegate* delegate, 17 BrowserAccessibilityDelegate* delegate,
18 BrowserAccessibilityFactory* factory) { 18 BrowserAccessibilityFactory* factory) {
19 return new BrowserAccessibilityManagerMac( 19 return new BrowserAccessibilityManagerMac(
20 NULL, initial_tree, delegate, factory); 20 NULL, initial_tree, delegate, factory);
21 } 21 }
22 22
23 BrowserAccessibilityManagerMac::BrowserAccessibilityManagerMac( 23 BrowserAccessibilityManagerMac::BrowserAccessibilityManagerMac(
24 NSView* parent_view, 24 NSView* parent_view,
25 const ui::AXTreeUpdate& initial_tree, 25 const ui::AXTreeUpdate& initial_tree,
26 BrowserAccessibilityDelegate* delegate, 26 BrowserAccessibilityDelegate* delegate,
27 BrowserAccessibilityFactory* factory) 27 BrowserAccessibilityFactory* factory)
28 : BrowserAccessibilityManager(delegate, factory), 28 : BrowserAccessibilityManager(delegate, factory),
29 parent_view_(parent_view), 29 parent_view_(parent_view) {
30 created_live_region_(false) {
31 Initialize(initial_tree); 30 Initialize(initial_tree);
32 } 31 }
33 32
34 // static 33 // static
35 ui::AXTreeUpdate BrowserAccessibilityManagerMac::GetEmptyDocument() { 34 ui::AXTreeUpdate BrowserAccessibilityManagerMac::GetEmptyDocument() {
36 ui::AXNodeData empty_document; 35 ui::AXNodeData empty_document;
37 empty_document.id = 0; 36 empty_document.id = 0;
38 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; 37 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA;
39 empty_document.state = 38 empty_document.state =
40 1 << ui::AX_STATE_READ_ONLY; 39 1 << ui::AX_STATE_READ_ONLY;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 return; 137 return;
139 default: 138 default:
140 LOG(WARNING) << "Unknown accessibility event: " << event_type; 139 LOG(WARNING) << "Unknown accessibility event: " << event_type;
141 return; 140 return;
142 } 141 }
143 BrowserAccessibilityCocoa* native_node = node->ToBrowserAccessibilityCocoa(); 142 BrowserAccessibilityCocoa* native_node = node->ToBrowserAccessibilityCocoa();
144 DCHECK(native_node); 143 DCHECK(native_node);
145 NSAccessibilityPostNotification(native_node, event_id); 144 NSAccessibilityPostNotification(native_node, event_id);
146 } 145 }
147 146
148 void BrowserAccessibilityManagerMac::OnNodeCreationFinished(ui::AXNode* node) { 147 void BrowserAccessibilityManagerMac::OnAtomicUpdateFinished(
149 BrowserAccessibility* obj = GetFromAXNode(node); 148 bool root_changed, const std::vector<ui::AXTreeDelegate::Change>& changes) {
150 if (obj && obj->HasStringAttribute(ui::AX_ATTR_LIVE_STATUS)) 149 BrowserAccessibilityManager::OnAtomicUpdateFinished(root_changed, changes);
151 created_live_region_ = true;
152 }
153 150
154 void BrowserAccessibilityManagerMac::OnTreeUpdateFinished() { 151 bool created_live_region = false;
155 if (!created_live_region_) 152 for (size_t i = 0; i < changes.size(); ++i) {
153 BrowserAccessibility* obj = GetFromAXNode(changes[i].node);
154 if (obj && obj->HasStringAttribute(ui::AX_ATTR_LIVE_STATUS)) {
155 created_live_region = true;
156 break;
157 }
158 }
159
160 if (!created_live_region)
156 return; 161 return;
157 162
158 // This code is to work around a bug in VoiceOver, where a new live 163 // This code is to work around a bug in VoiceOver, where a new live
159 // region that gets added is ignored. VoiceOver seems to only scan the 164 // region that gets added is ignored. VoiceOver seems to only scan the
160 // page for live regions once. By recreating the NSAccessibility 165 // page for live regions once. By recreating the NSAccessibility
161 // object for the root of the tree, we force VoiceOver to clear out its 166 // object for the root of the tree, we force VoiceOver to clear out its
162 // internal state and find newly-added live regions this time. 167 // internal state and find newly-added live regions this time.
163 BrowserAccessibilityMac* root = 168 BrowserAccessibilityMac* root =
164 static_cast<BrowserAccessibilityMac*>(GetRoot()); 169 static_cast<BrowserAccessibilityMac*>(GetRoot());
165 root->RecreateNativeObject(); 170 root->RecreateNativeObject();
166 NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, root); 171 NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, root);
167
168 created_live_region_ = false;
169 } 172 }
170 173
171 } // namespace content 174 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698