Chromium Code Reviews| Index: content/browser/accessibility/browser_accessibility_manager.cc |
| diff --git a/content/browser/accessibility/browser_accessibility_manager.cc b/content/browser/accessibility/browser_accessibility_manager.cc |
| index a99c782fc6bf1b4111f13d6ef45575869b7bd804..d722a99667d168d2995b8c91e608b7628917131a 100644 |
| --- a/content/browser/accessibility/browser_accessibility_manager.cc |
| +++ b/content/browser/accessibility/browser_accessibility_manager.cc |
| @@ -99,7 +99,10 @@ BrowserAccessibility* BrowserAccessibilityManager::GetFromRendererID( |
| void BrowserAccessibilityManager::Remove(int32 child_id, int32 renderer_id) { |
| child_id_map_.erase(child_id); |
| - renderer_id_to_child_id_map_.erase(renderer_id); |
| + // Make sure we don't overwrite a newer entry (see UpdateNode for a possible |
|
dmazzoni
2011/08/02 06:19:35
Good catch - would it be possible to write a unit
David Tseng
2011/08/02 21:30:57
Done.
|
| + // corner case). |
| + if (renderer_id_to_child_id_map_[renderer_id] == child_id) |
| + renderer_id_to_child_id_map_.erase(renderer_id); |
| } |
| void BrowserAccessibilityManager::OnAccessibilityNotifications( |
| @@ -184,9 +187,8 @@ void BrowserAccessibilityManager::OnAccessibilityObjectFocusChange( |
| void BrowserAccessibilityManager::OnAccessibilityObjectLoadComplete( |
| const WebAccessibility& acc_obj) { |
| SetFocus(NULL, false); |
| - root_->InternalReleaseReference(true); |
| - root_ = CreateAccessibilityTree(NULL, acc_obj, 0); |
| + root_ = UpdateNode(acc_obj, true); |
| if (!focus_) |
| SetFocus(root_, false); |
| @@ -247,11 +249,13 @@ BrowserAccessibility* BrowserAccessibilityManager::GetFocus( |
| void BrowserAccessibilityManager::SetFocus( |
| BrowserAccessibility* node, bool notify) { |
| - if (focus_) |
| - focus_->InternalReleaseReference(false); |
| - focus_ = node; |
| - if (focus_) |
| - focus_->InternalAddReference(); |
| + if (focus_ != node) { |
| + if (focus_) |
| + focus_->InternalReleaseReference(false); |
| + focus_ = node; |
| + if (focus_) |
| + focus_->InternalAddReference(); |
| + } |
| if (notify && node && delegate_) |
| delegate_->SetAccessibilityFocus(node->renderer_id()); |
| @@ -311,8 +315,7 @@ BrowserAccessibility* BrowserAccessibilityManager::UpdateNode( |
| for (int i = 0; i < static_cast<int>(old_tree_nodes.size()); i++) |
| old_tree_nodes[i]->InternalReleaseReference(false); |
| - DCHECK(focus_); |
| - if (!focus_->instance_active()) |
| + if (!focus_ || !focus_->instance_active()) |
| SetFocus(root_, false); |
| return current; |