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

Unified Diff: content/browser/accessibility/browser_accessibility_manager.cc

Issue 7745035: Add a big grab bag of missing web accessibility functionality... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/accessibility/browser_accessibility_manager.cc
===================================================================
--- content/browser/accessibility/browser_accessibility_manager.cc (revision 98225)
+++ content/browser/accessibility/browser_accessibility_manager.cc (working copy)
@@ -61,7 +61,7 @@
delegate_(delegate),
factory_(factory),
focus_(NULL) {
- root_ = CreateAccessibilityTree(NULL, src, 0);
+ root_ = CreateAccessibilityTree(NULL, src, 0, false);
if (!focus_)
SetFocus(root_, false);
}
@@ -107,8 +107,9 @@
int32 renderer_id) {
base::hash_map<int32, int32>::iterator iter =
renderer_id_to_child_id_map_.find(renderer_id);
- if (iter == renderer_id_to_child_id_map_.end())
+ if (iter == renderer_id_to_child_id_map_.end()) {
David Tseng 2011/08/26 16:14:37 nit: Do we need the braces?
dmazzoni 2011/08/29 18:08:51 Done.
return NULL;
+ }
int32 child_id = iter->second;
return GetFromChildID(child_id);
@@ -132,12 +133,12 @@
switch (param.notification_type) {
case ViewHostMsg_AccessibilityNotification_Type::
- NOTIFICATION_TYPE_CHECK_STATE_CHANGED:
- OnAccessibilityObjectStateChange(param.acc_obj);
- break;
+ NOTIFICATION_TYPE_LIVE_REGION_CHANGED:
David Tseng 2011/08/26 16:14:37 nit: sort alphabetically.
dmazzoni 2011/08/29 18:08:51 Done.
case ViewHostMsg_AccessibilityNotification_Type::
NOTIFICATION_TYPE_CHILDREN_CHANGED:
- OnAccessibilityObjectChildrenChange(param.acc_obj);
+ // Notifications where children are included.
+ OnSimpleAccessibilityNotification(
+ param.acc_obj, param.notification_type, true);
break;
case ViewHostMsg_AccessibilityNotification_Type::
NOTIFICATION_TYPE_FOCUS_CHANGED:
@@ -147,45 +148,27 @@
NOTIFICATION_TYPE_LOAD_COMPLETE:
OnAccessibilityObjectLoadComplete(param.acc_obj);
break;
- case ViewHostMsg_AccessibilityNotification_Type::
- NOTIFICATION_TYPE_VALUE_CHANGED:
- OnAccessibilityObjectValueChange(param.acc_obj);
- break;
- case ViewHostMsg_AccessibilityNotification_Type::
- NOTIFICATION_TYPE_SELECTED_TEXT_CHANGED:
- OnAccessibilityObjectTextChange(param.acc_obj);
- break;
default:
- DCHECK(0);
+ // For all other notifications, children are not included.
David Tseng 2011/08/26 16:14:37 Either remove the DCHECK above or explicitly list
dmazzoni 2011/08/29 18:08:51 Done.
+ OnSimpleAccessibilityNotification(
+ param.acc_obj, param.notification_type, false);
break;
}
}
}
-void BrowserAccessibilityManager::OnAccessibilityObjectStateChange(
- const WebAccessibility& acc_obj) {
- BrowserAccessibility* new_browser_acc = UpdateNode(acc_obj, false);
+void BrowserAccessibilityManager::OnSimpleAccessibilityNotification(
+ const WebAccessibility& acc_obj,
+ int notification_type,
+ bool include_children) {
+ BrowserAccessibility* new_browser_acc =
+ UpdateNode(acc_obj, include_children);
if (!new_browser_acc)
return;
- NotifyAccessibilityEvent(
- ViewHostMsg_AccessibilityNotification_Type::
- NOTIFICATION_TYPE_CHECK_STATE_CHANGED,
- new_browser_acc);
+ NotifyAccessibilityEvent(notification_type, new_browser_acc);
}
-void BrowserAccessibilityManager::OnAccessibilityObjectChildrenChange(
- const WebAccessibility& acc_obj) {
- BrowserAccessibility* new_browser_acc = UpdateNode(acc_obj, true);
- if (!new_browser_acc)
- return;
-
- NotifyAccessibilityEvent(
- ViewHostMsg_AccessibilityNotification_Type::
- NOTIFICATION_TYPE_CHILDREN_CHANGED,
- new_browser_acc);
-}
-
void BrowserAccessibilityManager::OnAccessibilityObjectFocusChange(
const WebAccessibility& acc_obj) {
BrowserAccessibility* new_browser_acc = UpdateNode(acc_obj, false);
@@ -220,30 +203,6 @@
GotFocus();
}
-void BrowserAccessibilityManager::OnAccessibilityObjectValueChange(
- const WebAccessibility& acc_obj) {
- BrowserAccessibility* new_browser_acc = UpdateNode(acc_obj, false);
- if (!new_browser_acc)
- return;
-
- NotifyAccessibilityEvent(
- ViewHostMsg_AccessibilityNotification_Type::
- NOTIFICATION_TYPE_VALUE_CHANGED,
- new_browser_acc);
-}
-
-void BrowserAccessibilityManager::OnAccessibilityObjectTextChange(
- const WebAccessibility& acc_obj) {
- BrowserAccessibility* new_browser_acc = UpdateNode(acc_obj, false);
- if (!new_browser_acc)
- return;
-
- NotifyAccessibilityEvent(
- ViewHostMsg_AccessibilityNotification_Type::
- NOTIFICATION_TYPE_SELECTED_TEXT_CHANGED,
- new_browser_acc);
-}
-
void BrowserAccessibilityManager::GotFocus() {
// TODO(ctguil): Remove when tree update logic handles focus changes.
if (!focus_)
@@ -314,6 +273,7 @@
current->child_id(),
current->index_in_parent(),
src);
+ current->SendNodeUpdateEvents();
return current;
}
@@ -327,13 +287,14 @@
// Build a new tree, reusing old nodes if possible. Each node that's
// reused will have its reference count incremented by one.
- current =
- CreateAccessibilityTree(current_parent, src, current_index_in_parent);
+ current = CreateAccessibilityTree(
+ current_parent, src, current_index_in_parent, true);
// Decrement the reference count of all nodes in the old tree, which will
// delete any nodes no longer needed.
- for (int i = 0; i < static_cast<int>(old_tree_nodes.size()); i++)
+ for (int i = 0; i < static_cast<int>(old_tree_nodes.size()); i++) {
David Tseng 2011/08/26 16:14:37 nit: braces necessary?
dmazzoni 2011/08/29 18:08:51 Done.
old_tree_nodes[i]->InternalReleaseReference(false);
+ }
if (!focus_ || !focus_->instance_active())
SetFocus(root_, false);
@@ -344,9 +305,11 @@
BrowserAccessibility* BrowserAccessibilityManager::CreateAccessibilityTree(
BrowserAccessibility* parent,
const WebAccessibility& src,
- int index_in_parent) {
+ int index_in_parent,
+ bool send_show_events) {
BrowserAccessibility* instance = NULL;
int32 child_id = 0;
+ bool children_can_send_show_events = send_show_events;
base::hash_map<int32, int32>::iterator iter =
renderer_id_to_child_id_map_.find(src.id);
@@ -375,10 +338,12 @@
// reference count.
instance->UpdateParent(parent, index_in_parent);
instance->InternalAddReference();
+ send_show_events = false;
} else {
// Otherwise, create a new instance.
instance = factory_->Create();
child_id = GetNextChildID();
+ children_can_send_show_events = false;
}
instance->Initialize(this, parent, child_id, index_in_parent, src);
@@ -388,9 +353,16 @@
SetFocus(instance, false);
for (int i = 0; i < static_cast<int>(src.children.size()); ++i) {
BrowserAccessibility* child = CreateAccessibilityTree(
- instance, src.children[i], i);
+ instance, src.children[i], i, children_can_send_show_events);
instance->AddChild(child);
}
+ if (send_show_events) {
David Tseng 2011/08/26 16:14:37 Any chance we could move this up to UpdateNode?
dmazzoni 2011/08/29 18:08:51 It'd be pretty hard, we need to update children_ca
+ NotifyAccessibilityEvent(
+ ViewHostMsg_AccessibilityNotification_Type::
+ NOTIFICATION_TYPE_OBJECT_SHOW,
+ instance);
David Tseng 2011/08/26 16:14:37 nit: align with "ViewHostMsg_AccessibilityNotifica
dmazzoni 2011/08/29 18:08:51 Done.
+ }
+ instance->SendNodeUpdateEvents();
return instance;
}

Powered by Google App Engine
This is Rietveld 408576698