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

Unified Diff: ui/accessibility/ax_tree_serializer.h

Issue 967583002: Improve AXTree unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ui/accessibility/ax_tree_serializer.h
diff --git a/ui/accessibility/ax_tree_serializer.h b/ui/accessibility/ax_tree_serializer.h
index f1cbfcea1053760d218d8686fe310273c6a0f7e5..8576433c2406e2d200db3f13f8b0974e2adb515b 100644
--- a/ui/accessibility/ax_tree_serializer.h
+++ b/ui/accessibility/ax_tree_serializer.h
@@ -292,36 +292,44 @@ void AXTreeSerializer<AXSourceNode>::SerializeChanges(
// with the LCA.
AXSourceNode lca = LeastCommonAncestor(node);
- if (client_root_) {
- bool need_delete = false;
- if (tree_->IsValid(lca)) {
- // Check for any reparenting within this subtree - if there is
- // any, we need to delete and reserialize the whole subtree
- // that contains the old and new parents of the reparented node.
- if (AnyDescendantWasReparented(lca, &lca))
- need_delete = true;
- }
+ bool need_delete;
+ do {
+ need_delete = false;
+ if (client_root_) {
+ if (tree_->IsValid(lca)) {
+ // Check for any reparenting within this subtree - if there is
+ // any, we need to delete and reserialize the whole subtree
+ // that contains the old and new parents of the reparented node.
+ if (AnyDescendantWasReparented(lca, &lca))
+ need_delete = true;
+ }
- if (!tree_->IsValid(lca)) {
- // If there's no LCA, just tell the client to destroy the whole
- // tree and then we'll serialize everything from the new root.
- out_update->node_id_to_clear = client_root_->id;
- Reset();
- } else if (need_delete) {
- // Otherwise, if we need to reserialize a subtree, first we need
- // to delete those nodes in our client tree so that
- // SerializeChangedNodes() will be sure to send them again.
- out_update->node_id_to_clear = tree_->GetId(lca);
- ClientTreeNode* client_lca = ClientTreeNodeById(tree_->GetId(lca));
- CHECK(client_lca);
- for (size_t i = 0; i < client_lca->children.size(); ++i) {
- client_id_map_.erase(client_lca->children[i]->id);
- DeleteClientSubtree(client_lca->children[i]);
- delete client_lca->children[i];
+ if (!tree_->IsValid(lca)) {
+ // If there's no LCA, just tell the client to destroy the whole
+ // tree and then we'll serialize everything from the new root.
+ out_update->node_id_to_clear = client_root_->id;
+ Reset();
+ } else if (need_delete) {
+ // Otherwise, if we need to reserialize a subtree, first we need
+ // to delete those nodes in our client tree so that
+ // SerializeChangedNodes() will be sure to send them again.
+ out_update->node_id_to_clear = tree_->GetId(lca);
+ ClientTreeNode* client_lca = ClientTreeNodeById(tree_->GetId(lca));
+ CHECK(client_lca);
+
+ for (size_t i = 0; i < client_lca->children.size(); ++i) {
+ client_id_map_.erase(client_lca->children[i]->id);
+ DeleteClientSubtree(client_lca->children[i]);
+ delete client_lca->children[i];
+ }
+ client_lca->children.clear();
}
- client_lca->children.clear();
}
- }
+
+ // If we deleted a client subtree, we have to call
+ // AnyDescendantWasReparented again because the computed LCA may be
+ // different now.
David Tseng 2015/03/11 21:19:27 Please rebase.
dmazzoni 2015/03/17 17:47:32 Done.
+ } while (need_delete);
// Serialize from the LCA, or from the root if there isn't one.
if (!tree_->IsValid(lca))

Powered by Google App Engine
This is Rietveld 408576698