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

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

Issue 272573003: Add hack so VoiceOver speaks updates to injected live regions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Only recreate if it already exists Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/accessibility/browser_accessibility_manager_mac.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/common/accessibility_messages.h" 10 #include "content/common/accessibility_messages.h"
10 11
11 namespace content { 12 namespace content {
12 13
13 // static 14 // static
14 BrowserAccessibilityManager* BrowserAccessibilityManager::Create( 15 BrowserAccessibilityManager* BrowserAccessibilityManager::Create(
15 const ui::AXTreeUpdate& initial_tree, 16 const ui::AXTreeUpdate& initial_tree,
16 BrowserAccessibilityDelegate* delegate, 17 BrowserAccessibilityDelegate* delegate,
17 BrowserAccessibilityFactory* factory) { 18 BrowserAccessibilityFactory* factory) {
18 return new BrowserAccessibilityManagerMac( 19 return new BrowserAccessibilityManagerMac(
19 NULL, initial_tree, delegate, factory); 20 NULL, initial_tree, delegate, factory);
20 } 21 }
21 22
22 BrowserAccessibilityManagerMac::BrowserAccessibilityManagerMac( 23 BrowserAccessibilityManagerMac::BrowserAccessibilityManagerMac(
23 NSView* parent_view, 24 NSView* parent_view,
24 const ui::AXTreeUpdate& initial_tree, 25 const ui::AXTreeUpdate& initial_tree,
25 BrowserAccessibilityDelegate* delegate, 26 BrowserAccessibilityDelegate* delegate,
26 BrowserAccessibilityFactory* factory) 27 BrowserAccessibilityFactory* factory)
27 : BrowserAccessibilityManager(initial_tree, delegate, factory), 28 : BrowserAccessibilityManager(initial_tree, delegate, factory),
28 parent_view_(parent_view) { 29 parent_view_(parent_view),
30 created_live_region_(false) {
29 } 31 }
30 32
31 // static 33 // static
32 ui::AXTreeUpdate BrowserAccessibilityManagerMac::GetEmptyDocument() { 34 ui::AXTreeUpdate BrowserAccessibilityManagerMac::GetEmptyDocument() {
33 ui::AXNodeData empty_document; 35 ui::AXNodeData empty_document;
34 empty_document.id = 0; 36 empty_document.id = 0;
35 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; 37 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA;
36 empty_document.state = 38 empty_document.state =
37 1 << ui::AX_STATE_READ_ONLY; 39 1 << ui::AX_STATE_READ_ONLY;
38 ui::AXTreeUpdate update; 40 ui::AXTreeUpdate update;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return; 149 return;
148 default: 150 default:
149 LOG(WARNING) << "Unknown accessibility event: " << event_type; 151 LOG(WARNING) << "Unknown accessibility event: " << event_type;
150 return; 152 return;
151 } 153 }
152 BrowserAccessibilityCocoa* native_node = node->ToBrowserAccessibilityCocoa(); 154 BrowserAccessibilityCocoa* native_node = node->ToBrowserAccessibilityCocoa();
153 DCHECK(native_node); 155 DCHECK(native_node);
154 NSAccessibilityPostNotification(native_node, event_id); 156 NSAccessibilityPostNotification(native_node, event_id);
155 } 157 }
156 158
159 void BrowserAccessibilityManagerMac::OnNodeCreationFinished(ui::AXNode* node) {
160 BrowserAccessibility* obj = GetFromAXNode(node);
161 if (obj && obj->HasStringAttribute(ui::AX_ATTR_LIVE_STATUS))
162 created_live_region_ = true;
163 }
164
165 void BrowserAccessibilityManagerMac::OnTreeUpdateFinished() {
166 if (!created_live_region_)
167 return;
168
169 // This code is to work around a bug in VoiceOver, where a new live
170 // region that gets added is ignored. VoiceOver seems to only scan the
171 // page for live regions once. By recreating the NSAccessibility
172 // object for the root of the tree, we force VoiceOver to clear out its
173 // internal state and find newly-added live regions this time.
174 BrowserAccessibilityMac* root =
175 static_cast<BrowserAccessibilityMac*>(GetRoot());
176 root->RecreateNativeObject();
177 NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, root);
178
179 created_live_region_ = false;
180 }
181
157 } // namespace content 182 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/accessibility/browser_accessibility_manager_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698