Chromium Code Reviews| Index: content/browser/accessibility/browser_accessibility_manager.cc |
| =================================================================== |
| --- content/browser/accessibility/browser_accessibility_manager.cc (revision 98804) |
| +++ 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); |
| } |
| @@ -131,61 +131,60 @@ |
| const ViewHostMsg_AccessibilityNotification_Params& param = params[index]; |
| switch (param.notification_type) { |
| - case ViewHostMsg_AccessibilityNotification_Type:: |
| - NOTIFICATION_TYPE_CHECK_STATE_CHANGED: |
| - OnAccessibilityObjectStateChange(param.acc_obj); |
| + // Notifications where children are included. |
| + case ViewHostMsg_AccEvent::CHILDREN_CHANGED: |
| + case ViewHostMsg_AccEvent::LIVE_REGION_CHANGED: |
| + OnSimpleAccessibilityNotification( |
| + param.acc_obj, param.notification_type, true); |
| break; |
| - case ViewHostMsg_AccessibilityNotification_Type:: |
| - NOTIFICATION_TYPE_CHILDREN_CHANGED: |
| - OnAccessibilityObjectChildrenChange(param.acc_obj); |
| - break; |
| - case ViewHostMsg_AccessibilityNotification_Type:: |
| - NOTIFICATION_TYPE_FOCUS_CHANGED: |
| + |
| + case ViewHostMsg_AccEvent::FOCUS_CHANGED: |
| OnAccessibilityObjectFocusChange(param.acc_obj); |
| break; |
| - case ViewHostMsg_AccessibilityNotification_Type:: |
| - NOTIFICATION_TYPE_LOAD_COMPLETE: |
| + |
| + case ViewHostMsg_AccEvent::LOAD_COMPLETE: |
| OnAccessibilityObjectLoadComplete(param.acc_obj); |
| break; |
| - case ViewHostMsg_AccessibilityNotification_Type:: |
| - NOTIFICATION_TYPE_VALUE_CHANGED: |
| - OnAccessibilityObjectValueChange(param.acc_obj); |
| + |
| + // All other notifications |
|
Chris Guillory
2011/08/31 02:14:53
Optional: Mention in comment that children are not
dmazzoni
2011/08/31 22:02:54
Done.
|
| + case ViewHostMsg_AccEvent::ACTIVE_DESCENDANT_CHANGED: |
| + case ViewHostMsg_AccEvent::ALERT: |
| + case ViewHostMsg_AccEvent::CHECK_STATE_CHANGED: |
| + case ViewHostMsg_AccEvent::LAYOUT_COMPLETE: |
| + case ViewHostMsg_AccEvent::MENU_LIST_VALUE_CHANGED: |
| + case ViewHostMsg_AccEvent::OBJECT_HIDE: |
| + case ViewHostMsg_AccEvent::OBJECT_SHOW: |
| + case ViewHostMsg_AccEvent::ROW_COLLAPSED: |
| + case ViewHostMsg_AccEvent::ROW_COUNT_CHANGED: |
| + case ViewHostMsg_AccEvent::ROW_EXPANDED: |
| + case ViewHostMsg_AccEvent::SCROLLED_TO_ANCHOR: |
| + case ViewHostMsg_AccEvent::SELECTED_CHILDREN_CHANGED: |
| + case ViewHostMsg_AccEvent::SELECTED_TEXT_CHANGED: |
| + case ViewHostMsg_AccEvent::TEXT_INSERTED: |
| + case ViewHostMsg_AccEvent::TEXT_REMOVED: |
| + case ViewHostMsg_AccEvent::VALUE_CHANGED: |
| + OnSimpleAccessibilityNotification( |
| + param.acc_obj, param.notification_type, false); |
| break; |
| - case ViewHostMsg_AccessibilityNotification_Type:: |
| - NOTIFICATION_TYPE_SELECTED_TEXT_CHANGED: |
| - OnAccessibilityObjectTextChange(param.acc_obj); |
| - break; |
| + |
| default: |
| DCHECK(0); |
| - 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); |
| @@ -197,10 +196,7 @@ |
| GotFocus(); |
| } else if (!delegate_) { |
| // Mac currently does not have a BrowserAccessibilityDelegate. |
| - NotifyAccessibilityEvent( |
| - ViewHostMsg_AccessibilityNotification_Type:: |
| - NOTIFICATION_TYPE_FOCUS_CHANGED, |
| - focus_); |
| + NotifyAccessibilityEvent(ViewHostMsg_AccEvent::FOCUS_CHANGED, focus_); |
| } |
| } |
| @@ -212,47 +208,17 @@ |
| if (!focus_) |
| SetFocus(root_, false); |
| - NotifyAccessibilityEvent( |
| - ViewHostMsg_AccessibilityNotification_Type:: |
| - NOTIFICATION_TYPE_LOAD_COMPLETE, |
| - root_); |
| + NotifyAccessibilityEvent(ViewHostMsg_AccEvent::LOAD_COMPLETE, root_); |
| if (delegate_ && delegate_->HasFocus()) |
| 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_) |
| return; |
| - NotifyAccessibilityEvent( |
| - ViewHostMsg_AccessibilityNotification_Type:: |
| - NOTIFICATION_TYPE_FOCUS_CHANGED, |
| - focus_); |
| + NotifyAccessibilityEvent(ViewHostMsg_AccEvent::FOCUS_CHANGED, focus_); |
| } |
| gfx::NativeView BrowserAccessibilityManager::GetParentView() { |
| @@ -314,6 +280,7 @@ |
| current->child_id(), |
| current->index_in_parent(), |
| src); |
| + current->SendNodeUpdateEvents(); |
| return current; |
| } |
| @@ -327,8 +294,8 @@ |
| // 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. |
| @@ -344,9 +311,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 +344,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 +359,18 @@ |
| 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); |
| } |
| + // Note: the purpose of send_show_events and children_can_send_show_events |
| + // is so that we send a single OBJECT_SHOW event for the root of a subtree |
| + // that just appeared for the first time, but not on any descendant of |
| + // that subtree. |
| + if (send_show_events) |
| + NotifyAccessibilityEvent(ViewHostMsg_AccEvent::OBJECT_SHOW, instance); |
| + |
| + instance->SendNodeUpdateEvents(); |
| + |
| return instance; |
| } |