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

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

Issue 3250014: Update browser accessibility tree on a renderer accessibility object state ch... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fix lint errors 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_manager_win.h" 5 #include "chrome/browser/browser_accessibility_manager_win.h"
6 6
7 #include "chrome/browser/browser_accessibility_win.h" 7 #include "chrome/browser/browser_accessibility_win.h"
8 #include "chrome/browser/renderer_host/render_process_host.h" 8 #include "chrome/browser/renderer_host/render_process_host.h"
9 #include "chrome/browser/renderer_host/render_view_host.h" 9 #include "chrome/browser/renderer_host/render_view_host.h"
10 #include "chrome/common/render_messages.h" 10 #include "chrome/common/render_messages.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 LONG child_id = iter->second; 108 LONG child_id = iter->second;
109 base::hash_map<LONG, BrowserAccessibility*>::iterator uniq_iter = 109 base::hash_map<LONG, BrowserAccessibility*>::iterator uniq_iter =
110 child_id_map_.find(child_id); 110 child_id_map_.find(child_id);
111 if (uniq_iter != child_id_map_.end()) 111 if (uniq_iter != child_id_map_.end())
112 focus_ = uniq_iter->second; 112 focus_ = uniq_iter->second;
113 ::NotifyWinEvent(EVENT_OBJECT_FOCUS, parent_hwnd_, OBJID_CLIENT, child_id); 113 ::NotifyWinEvent(EVENT_OBJECT_FOCUS, parent_hwnd_, OBJID_CLIENT, child_id);
114 } 114 }
115 115
116 void BrowserAccessibilityManager::OnAccessibilityObjectStateChange( 116 void BrowserAccessibilityManager::OnAccessibilityObjectStateChange(
117 int renderer_id) { 117 const webkit_glue::WebAccessibility& acc_obj) {
118 base::hash_map<int, LONG>::iterator iter = 118 BrowserAccessibility* new_browser_acc = UpdateTree(acc_obj);
119 renderer_id_to_child_id_map_.find(renderer_id);
120 if (iter == renderer_id_to_child_id_map_.end())
121 return;
122 119
123 LONG child_id = iter->second; 120 NotifyWinEvent(
124 ::NotifyWinEvent(
125 EVENT_OBJECT_STATECHANGE, 121 EVENT_OBJECT_STATECHANGE,
126 parent_hwnd_, 122 parent_hwnd_,
127 OBJID_CLIENT, 123 OBJID_CLIENT,
128 child_id); 124 new_browser_acc->child_id());
129 } 125 }
130 126
131 void BrowserAccessibilityManager::OnAccessibilityObjectChildrenChange( 127 void BrowserAccessibilityManager::OnAccessibilityObjectChildrenChange(
132 const std::vector<webkit_glue::WebAccessibility>& acc_changes) { 128 const std::vector<webkit_glue::WebAccessibility>& acc_changes) {
133 if (delegate_) 129 if (delegate_)
134 delegate_->AccessibilityObjectChildrenChangeAck(); 130 delegate_->AccessibilityObjectChildrenChangeAck();
135 131
136 // For each accessibility object child change. 132 // For each accessibility object child change.
137 for (unsigned int index = 0; index < acc_changes.size(); index++) { 133 for (unsigned int index = 0; index < acc_changes.size(); index++) {
138 const webkit_glue::WebAccessibility& acc_obj = acc_changes[index]; 134 const webkit_glue::WebAccessibility& acc_obj = acc_changes[index];
139 base::hash_map<int, LONG>::iterator iter = 135 BrowserAccessibility* new_browser_acc = UpdateTree(acc_obj);
140 renderer_id_to_child_id_map_.find(acc_obj.id);
141 if (iter == renderer_id_to_child_id_map_.end())
142 continue;
143 136
144 LONG child_id = iter->second; 137 LONG child_id;
145 BrowserAccessibility* old_browser_acc = GetFromChildID(child_id); 138 if (root_ != new_browser_acc) {
139 child_id = new_browser_acc->GetParent()->child_id();
140 } else {
141 child_id = CHILDID_SELF;
142 }
143
144 NotifyWinEvent(EVENT_OBJECT_REORDER, parent_hwnd_, OBJID_CLIENT, child_id);
145 }
146 }
147
148 BrowserAccessibility* BrowserAccessibilityManager::UpdateTree(
149 const webkit_glue::WebAccessibility& acc_obj) {
150 base::hash_map<int, LONG>::iterator iter =
151 renderer_id_to_child_id_map_.find(acc_obj.id);
152 if (iter == renderer_id_to_child_id_map_.end())
153 return NULL;
154
155 LONG child_id = iter->second;
156 BrowserAccessibility* old_browser_acc = GetFromChildID(child_id);
157
158 if (old_browser_acc->GetChildCount() == 0 && acc_obj.children.size() == 0) {
159 // Reinitialize the BrowserAccessibility if there are no children to update.
160 old_browser_acc->Initialize(
161 this,
dmazzoni 2010/09/01 15:10:52 nit: Indent 4 spaces
Chris Guillory 2010/09/01 15:35:27 Done.
162 old_browser_acc->GetParent(),
163 child_id,
164 old_browser_acc->index_in_parent(),
165 acc_obj);
166
167 return old_browser_acc;
168 } else {
169 BrowserAccessibility* old_focus = focus_;
146 170
147 BrowserAccessibility* new_browser_acc = CreateAccessibilityTree( 171 BrowserAccessibility* new_browser_acc = CreateAccessibilityTree(
148 old_browser_acc->GetParent(), 172 old_browser_acc->GetParent(),
149 child_id, 173 child_id,
150 acc_obj, 174 acc_obj,
151 old_browser_acc->index_in_parent()); 175 old_browser_acc->index_in_parent());
152 176
153 if (focus_->IsDescendantOf(old_browser_acc)) 177 if (focus_->IsDescendantOf(old_browser_acc)) {
dmazzoni 2010/09/01 15:10:52 We definitely need to fix the focus (it can't poin
Chris Guillory 2010/09/01 15:35:27 That's a good thought. I remove this for now as th
154 focus_ = new_browser_acc; 178 focus_ = new_browser_acc;
155 179
180 if (delegate_)
181 delegate_->SetAccessibilityFocus(focus_->renderer_id());
182 }
183
156 if (old_browser_acc->GetParent()) { 184 if (old_browser_acc->GetParent()) {
157 old_browser_acc->GetParent()->ReplaceChild( 185 old_browser_acc->GetParent()->ReplaceChild(
158 old_browser_acc, 186 old_browser_acc,
159 new_browser_acc); 187 new_browser_acc);
160 } else { 188 } else {
161 DCHECK_EQ(old_browser_acc, root_); 189 DCHECK_EQ(old_browser_acc, root_);
162 root_ = new_browser_acc; 190 root_ = new_browser_acc;
163 } 191 }
164 old_browser_acc->InactivateTree(); 192 old_browser_acc->InactivateTree();
165 old_browser_acc->Release(); 193 old_browser_acc->Release();
166 child_id_map_[child_id] = new_browser_acc; 194 child_id_map_[child_id] = new_browser_acc;
167 195
168 if (root_ != new_browser_acc) { 196 if (focus_ != old_focus) {
169 NotifyWinEvent( 197 NotifyWinEvent(
170 EVENT_OBJECT_REORDER, parent_hwnd_, OBJID_CLIENT, child_id); 198 EVENT_OBJECT_FOCUS, parent_hwnd_, OBJID_CLIENT, focus_->child_id());
171 } else {
172 NotifyWinEvent(
173 EVENT_OBJECT_REORDER, parent_hwnd_, OBJID_CLIENT, CHILDID_SELF);
174 } 199 }
200
201 return new_browser_acc;
175 } 202 }
176 } 203 }
177 204
178 LONG BrowserAccessibilityManager::GetNextChildID() { 205 LONG BrowserAccessibilityManager::GetNextChildID() {
179 // Get the next child ID, and wrap around when we get near the end 206 // Get the next child ID, and wrap around when we get near the end
180 // of a 32-bit integer range. It's okay to wrap around; we just want 207 // of a 32-bit integer range. It's okay to wrap around; we just want
181 // to avoid it as long as possible because clients may cache the ID of 208 // to avoid it as long as possible because clients may cache the ID of
182 // an object for a while to determine if they've seen it before. 209 // an object for a while to determine if they've seen it before.
183 next_child_id_--; 210 next_child_id_--;
184 if (next_child_id_ == -2000000000) 211 if (next_child_id_ == -2000000000)
(...skipping 15 matching lines...) Expand all
200 if ((src.state >> WebAccessibility::STATE_FOCUSED) & 1) 227 if ((src.state >> WebAccessibility::STATE_FOCUSED) & 1)
201 focus_ = instance; 228 focus_ = instance;
202 for (int i = 0; i < static_cast<int>(src.children.size()); ++i) { 229 for (int i = 0; i < static_cast<int>(src.children.size()); ++i) {
203 BrowserAccessibility* child = CreateAccessibilityTree( 230 BrowserAccessibility* child = CreateAccessibilityTree(
204 instance, GetNextChildID(), src.children[i], i); 231 instance, GetNextChildID(), src.children[i], i);
205 instance->AddChild(child); 232 instance->AddChild(child);
206 } 233 }
207 234
208 return instance; 235 return instance;
209 } 236 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698