Chromium Code Reviews| 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 #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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 return; | 137 return; |
| 136 default: | 138 default: |
| 137 LOG(WARNING) << "Unknown accessibility event: " << event_type; | 139 LOG(WARNING) << "Unknown accessibility event: " << event_type; |
| 138 return; | 140 return; |
| 139 } | 141 } |
| 140 BrowserAccessibilityCocoa* native_node = node->ToBrowserAccessibilityCocoa(); | 142 BrowserAccessibilityCocoa* native_node = node->ToBrowserAccessibilityCocoa(); |
| 141 DCHECK(native_node); | 143 DCHECK(native_node); |
| 142 NSAccessibilityPostNotification(native_node, event_id); | 144 NSAccessibilityPostNotification(native_node, event_id); |
| 143 } | 145 } |
| 144 | 146 |
| 147 void BrowserAccessibilityManagerMac::OnNodeCreationFinished(ui::AXNode* node) { | |
| 148 BrowserAccessibility* obj = GetFromAXNode(node); | |
| 149 if (obj && obj->HasStringAttribute(ui::AX_ATTR_LIVE_STATUS)) | |
| 150 created_live_region_ = true; | |
| 151 } | |
| 152 | |
| 153 void BrowserAccessibilityManagerMac::OnUpdateFinished() { | |
| 154 if (!created_live_region_) | |
| 155 return; | |
| 156 | |
| 157 // This code is to work around a bug in VoiceOver, where a new live | |
| 158 // region that gets added is ignored. (Live regions that are there from | |
| 159 // the initial page load work fine.) By recreating the NSAccessibility | |
|
David Tseng
2014/05/08 17:07:02
Doesn't this code get triggered on initial load as
dmazzoni
2014/05/08 21:02:05
True. I updated the comment.
| |
| 160 // object for the root of the tree, we force VoiceOver to clear out its | |
| 161 // internal state and find newly-added live regions this time. | |
| 162 BrowserAccessibilityMac* root = | |
| 163 static_cast<BrowserAccessibilityMac*>(GetRoot()); | |
| 164 root->RecreateNativeObject(); | |
| 165 NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, root); | |
| 166 | |
| 167 created_live_region_ = false; | |
| 168 } | |
| 169 | |
| 145 } // namespace content | 170 } // namespace content |
| OLD | NEW |