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

Side by Side Diff: ui/accessibility/ax_tree.cc

Issue 1251723003: Revert of Re-land: Reimplement automation API on top of C++-backed AXTree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « extensions/renderer/script_context.cc ('k') | ui/accessibility/ax_tree_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/accessibility/ax_tree.h" 5 #include "ui/accessibility/ax_tree.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // Now build a new children vector, reusing nodes when possible, 197 // Now build a new children vector, reusing nodes when possible,
198 // and swap it in. 198 // and swap it in.
199 std::vector<AXNode*> new_children; 199 std::vector<AXNode*> new_children;
200 bool success = CreateNewChildVector( 200 bool success = CreateNewChildVector(
201 node, src.child_ids, &new_children, update_state); 201 node, src.child_ids, &new_children, update_state);
202 node->SwapChildren(new_children); 202 node->SwapChildren(new_children);
203 203
204 // Update the root of the tree if needed. 204 // Update the root of the tree if needed.
205 if ((src.role == AX_ROLE_ROOT_WEB_AREA || src.role == AX_ROLE_DESKTOP) && 205 if ((src.role == AX_ROLE_ROOT_WEB_AREA || src.role == AX_ROLE_DESKTOP) &&
206 (!root_ || root_->id() != src.id)) { 206 (!root_ || root_->id() != src.id)) {
207 // Make sure root_ always points to something valid, even inside 207 if (root_)
208 // DestroySubtree. 208 DestroySubtree(root_, update_state);
209 AXNode* old_root = root_;
210 root_ = node; 209 root_ = node;
211 if (old_root)
212 DestroySubtree(old_root, update_state);
213 } 210 }
214 211
215 return success; 212 return success;
216 } 213 }
217 214
218 void AXTree::DestroySubtree(AXNode* node, 215 void AXTree::DestroySubtree(AXNode* node,
219 AXTreeUpdateState* update_state) { 216 AXTreeUpdateState* update_state) {
220 if (delegate_) 217 if (delegate_)
221 delegate_->OnSubtreeWillBeDeleted(this, node); 218 delegate_->OnSubtreeWillBeDeleted(this, node);
222 DestroyNodeAndSubtree(node, update_state); 219 DestroyNodeAndSubtree(node, update_state);
223 } 220 }
224 221
225 void AXTree::DestroyNodeAndSubtree(AXNode* node, 222 void AXTree::DestroyNodeAndSubtree(AXNode* node,
226 AXTreeUpdateState* update_state) { 223 AXTreeUpdateState* update_state) {
227 if (delegate_)
228 delegate_->OnNodeWillBeDeleted(this, node);
229 id_map_.erase(node->id()); 224 id_map_.erase(node->id());
230 for (int i = 0; i < node->child_count(); ++i) 225 for (int i = 0; i < node->child_count(); ++i)
231 DestroyNodeAndSubtree(node->ChildAtIndex(i), update_state); 226 DestroyNodeAndSubtree(node->ChildAtIndex(i), update_state);
227 if (delegate_)
228 delegate_->OnNodeWillBeDeleted(this, node);
232 if (update_state) { 229 if (update_state) {
233 update_state->pending_nodes.erase(node); 230 update_state->pending_nodes.erase(node);
234 } 231 }
235 node->Destroy(); 232 node->Destroy();
236 } 233 }
237 234
238 bool AXTree::DeleteOldChildren(AXNode* node, 235 bool AXTree::DeleteOldChildren(AXNode* node,
239 const std::vector<int32>& new_child_ids, 236 const std::vector<int32>& new_child_ids,
240 AXTreeUpdateState* update_state) { 237 AXTreeUpdateState* update_state) {
241 // Create a set of child ids in |src| for fast lookup, and return false 238 // Create a set of child ids in |src| for fast lookup, and return false
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 update_state->pending_nodes.insert(child); 286 update_state->pending_nodes.insert(child);
290 update_state->new_nodes.insert(child); 287 update_state->new_nodes.insert(child);
291 } 288 }
292 new_children->push_back(child); 289 new_children->push_back(child);
293 } 290 }
294 291
295 return success; 292 return success;
296 } 293 }
297 294
298 } // namespace ui 295 } // namespace ui
OLDNEW
« no previous file with comments | « extensions/renderer/script_context.cc ('k') | ui/accessibility/ax_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698