Commit a7ee1d4d authored by nektar's avatar nektar Committed by Commit bot

Newly created live regions should fire a private notification on the Mac.

BUG=590341
TESTED=Voiceover
R=dmazzoni@chromium.org

Review-Url: https://codereview.chromium.org/2173563005
Cr-Commit-Position: refs/heads/master@{#416317}
parent 8da820db
...@@ -65,6 +65,8 @@ NSString* const NSAccessibilityLoadCompleteNotification = ...@@ -65,6 +65,8 @@ NSString* const NSAccessibilityLoadCompleteNotification =
@"AXLoadComplete"; @"AXLoadComplete";
NSString* const NSAccessibilityInvalidStatusChangedNotification = NSString* const NSAccessibilityInvalidStatusChangedNotification =
@"AXInvalidStatusChanged"; @"AXInvalidStatusChanged";
NSString* const NSAccessibilityLiveRegionCreatedNotification =
@"AXLiveRegionCreated";
NSString* const NSAccessibilityLiveRegionChangedNotification = NSString* const NSAccessibilityLiveRegionChangedNotification =
@"AXLiveRegionChanged"; @"AXLiveRegionChanged";
NSString* const NSAccessibilityExpandedChanged = NSString* const NSAccessibilityExpandedChanged =
...@@ -268,7 +270,9 @@ void BrowserAccessibilityManagerMac::NotifyAccessibilityEvent( ...@@ -268,7 +270,9 @@ void BrowserAccessibilityManagerMac::NotifyAccessibilityEvent(
return; return;
} }
break; break;
// TODO(nektar): Need to add an event for live region created. case ui::AX_EVENT_ALERT:
mac_notification = NSAccessibilityLiveRegionCreatedNotification;
break;
case ui::AX_EVENT_LIVE_REGION_CHANGED: case ui::AX_EVENT_LIVE_REGION_CHANGED:
mac_notification = NSAccessibilityLiveRegionChangedNotification; mac_notification = NSAccessibilityLiveRegionChangedNotification;
break; break;
...@@ -291,7 +295,6 @@ void BrowserAccessibilityManagerMac::NotifyAccessibilityEvent( ...@@ -291,7 +295,6 @@ void BrowserAccessibilityManagerMac::NotifyAccessibilityEvent(
break; break;
// These events are not used on Mac for now. // These events are not used on Mac for now.
case ui::AX_EVENT_ALERT:
case ui::AX_EVENT_TEXT_CHANGED: case ui::AX_EVENT_TEXT_CHANGED:
case ui::AX_EVENT_CHILDREN_CHANGED: case ui::AX_EVENT_CHILDREN_CHANGED:
case ui::AX_EVENT_MENU_LIST_VALUE_CHANGED: case ui::AX_EVENT_MENU_LIST_VALUE_CHANGED:
...@@ -380,7 +383,6 @@ void BrowserAccessibilityManagerMac::OnAtomicUpdateFinished( ...@@ -380,7 +383,6 @@ void BrowserAccessibilityManagerMac::OnAtomicUpdateFinished(
BrowserAccessibilityManager::OnAtomicUpdateFinished( BrowserAccessibilityManager::OnAtomicUpdateFinished(
tree, root_changed, changes); tree, root_changed, changes);
bool created_live_region = false;
for (size_t i = 0; i < changes.size(); ++i) { for (size_t i = 0; i < changes.size(); ++i) {
if (changes[i].type != NODE_CREATED && changes[i].type != SUBTREE_CREATED) if (changes[i].type != NODE_CREATED && changes[i].type != SUBTREE_CREATED)
continue; continue;
...@@ -389,28 +391,10 @@ void BrowserAccessibilityManagerMac::OnAtomicUpdateFinished( ...@@ -389,28 +391,10 @@ void BrowserAccessibilityManagerMac::OnAtomicUpdateFinished(
DCHECK(changed_node); DCHECK(changed_node);
BrowserAccessibility* obj = GetFromAXNode(changed_node); BrowserAccessibility* obj = GetFromAXNode(changed_node);
if (obj && obj->HasStringAttribute(ui::AX_ATTR_LIVE_STATUS)) { if (obj && obj->HasStringAttribute(ui::AX_ATTR_LIVE_STATUS)) {
created_live_region = true; NotifyAccessibilityEvent(BrowserAccessibilityEvent::FromTreeChange,
break; ui::AX_EVENT_ALERT, obj);
} }
} }
if (!created_live_region)
return;
// This code is to work around a bug in VoiceOver, where a new live
// region that gets added is ignored. VoiceOver seems to only scan the
// page for live regions once. By recreating the NSAccessibility
// object for the root of the tree, we force VoiceOver to clear out its
// internal state and find newly-added live regions this time.
BrowserAccessibilityMac* root =
static_cast<BrowserAccessibilityMac*>(GetRoot());
if (root) {
root->RecreateNativeObject();
NotifyAccessibilityEvent(
BrowserAccessibilityEvent::FromTreeChange,
ui::AX_EVENT_CHILDREN_CHANGED,
root);
}
} }
NSDictionary* BrowserAccessibilityManagerMac:: NSDictionary* BrowserAccessibilityManagerMac::
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment