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

Side by Side Diff: chrome/browser/browser_accessibility_win.cc

Issue 3117036: Update browser cache of accessibility tree on renderer sub-tree changes.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Updating from comments. Created 10 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/browser_accessibility_win.h" 5 #include "chrome/browser/browser_accessibility_win.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/browser_accessibility_manager_win.h" 8 #include "chrome/browser/browser_accessibility_manager_win.h"
9 9
10 using webkit_glue::WebAccessibility; 10 using webkit_glue::WebAccessibility;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 instance_active_ = true; 50 instance_active_ = true;
51 } 51 }
52 52
53 void BrowserAccessibility::AddChild(BrowserAccessibility* child) { 53 void BrowserAccessibility::AddChild(BrowserAccessibility* child) {
54 children_.push_back(child); 54 children_.push_back(child);
55 } 55 }
56 56
57 void BrowserAccessibility::InactivateTree() { 57 void BrowserAccessibility::InactivateTree() {
58 if (!instance_active_)
59 return;
60
58 // Mark this object as inactive, so calls to all COM methods will return 61 // Mark this object as inactive, so calls to all COM methods will return
59 // failure. 62 // failure.
60 instance_active_ = false; 63 instance_active_ = false;
61 64
62 // Now we can safely call InactivateTree on our children and remove 65 // Now we can safely call InactivateTree on our children and remove
63 // references to them, so that as much of the tree as possible will be 66 // references to them, so that as much of the tree as possible will be
64 // destroyed now - however, nodes that still have references to them 67 // destroyed now - however, nodes that still have references to them
65 // might stick around a while until all clients have released them. 68 // might stick around a while until all clients have released them.
66 for (std::vector<BrowserAccessibility*>::iterator iter = 69 for (std::vector<BrowserAccessibility*>::iterator iter =
67 children_.begin(); 70 children_.begin();
68 iter != children_.end(); ++iter) { 71 iter != children_.end(); ++iter) {
69 (*iter)->InactivateTree(); 72 (*iter)->InactivateTree();
70 (*iter)->Release(); 73 (*iter)->Release();
71 } 74 }
72 children_.clear(); 75 children_.clear();
76 manager_->Remove(child_id_);
73 } 77 }
74 78
75 bool BrowserAccessibility::IsDescendantOf(BrowserAccessibility* ancestor) { 79 bool BrowserAccessibility::IsDescendantOf(BrowserAccessibility* ancestor) {
76 if (this == ancestor) { 80 if (this == ancestor) {
77 return true; 81 return true;
78 } else if (parent_) { 82 } else if (parent_) {
79 return parent_->IsDescendantOf(ancestor); 83 return parent_->IsDescendantOf(ancestor);
80 } 84 }
81 85
82 return false; 86 return false;
83 } 87 }
84 88
89 BrowserAccessibility* BrowserAccessibility::GetParent() {
90 return parent_;
91 }
92
85 BrowserAccessibility* BrowserAccessibility::GetPreviousSibling() { 93 BrowserAccessibility* BrowserAccessibility::GetPreviousSibling() {
86 if (parent_ && index_in_parent_ > 0) 94 if (parent_ && index_in_parent_ > 0)
87 return parent_->children_[index_in_parent_ - 1]; 95 return parent_->children_[index_in_parent_ - 1];
88 96
89 return NULL; 97 return NULL;
90 } 98 }
91 99
92 BrowserAccessibility* BrowserAccessibility::GetNextSibling() { 100 BrowserAccessibility* BrowserAccessibility::GetNextSibling() {
93 if (parent_ && 101 if (parent_ &&
94 index_in_parent_ < static_cast<int>(parent_->children_.size() - 1)) { 102 index_in_parent_ < static_cast<int>(parent_->children_.size() - 1)) {
95 return parent_->children_[index_in_parent_ + 1]; 103 return parent_->children_[index_in_parent_ + 1];
96 } 104 }
97 105
98 return NULL; 106 return NULL;
99 } 107 }
100 108
109 void BrowserAccessibility::ReplaceChild(
110 const BrowserAccessibility* old_acc, BrowserAccessibility* new_acc) {
111 DCHECK_EQ(children_[old_acc->index_in_parent_], old_acc);
112
113 old_acc = children_[old_acc->index_in_parent_];
114 children_[old_acc->index_in_parent_] = new_acc;
115 }
116
101 BrowserAccessibility* BrowserAccessibility::NewReference() { 117 BrowserAccessibility* BrowserAccessibility::NewReference() {
102 AddRef(); 118 AddRef();
103 return this; 119 return this;
104 } 120 }
105 121
106 // 122 //
107 // IAccessible methods. 123 // IAccessible methods.
108 // 124 //
109 // Conventions: 125 // Conventions:
110 // * Always test for instance_active_ first and return E_FAIL if it's false. 126 // * Always test for instance_active_ first and return E_FAIL if it's false.
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 } 1020 }
1005 1021
1006 // The role should always be set. 1022 // The role should always be set.
1007 DCHECK(!role_name_.empty() || role_); 1023 DCHECK(!role_name_.empty() || role_);
1008 1024
1009 // If we didn't explicitly set the IAccessible2 role, make it the same 1025 // If we didn't explicitly set the IAccessible2 role, make it the same
1010 // as the MSAA role. 1026 // as the MSAA role.
1011 if (!ia2_role_) 1027 if (!ia2_role_)
1012 ia2_role_ = role_; 1028 ia2_role_ = role_;
1013 } 1029 }
OLDNEW
« no previous file with comments | « chrome/browser/browser_accessibility_win.h ('k') | chrome/browser/browser_accessibility_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698