diff options
author | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-03 15:25:30 +0000 |
---|---|---|
committer | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-03 15:25:30 +0000 |
commit | 949df1cc65904954edcd9ade824f65b4d7c7c237 (patch) | |
tree | e54c310397095b669fc505e9ab2f5ad54e1a52b0 /ui/accessibility | |
parent | 87b9bf1be7bb6492a7fac62ff09ba2d43f49f0dd (diff) | |
download | chromium_src-949df1cc65904954edcd9ade824f65b4d7c7c237.zip chromium_src-949df1cc65904954edcd9ade824f65b4d7c7c237.tar.gz chromium_src-949df1cc65904954edcd9ade824f65b4d7c7c237.tar.bz2 |
Refactor content/renderer/accessibility to use AXTreeSerializer (re-land).
This removes the confusing code in content/renderer/accessibility that
serializes updates from Blink's accessibility tree, and replaces it with
calls to the new cleaner and fully-unit-tested AXTreeSerializer class.
BUG=316726
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=261099
Review URL: https://codereview.chromium.org/125763003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261408 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/accessibility')
-rw-r--r-- | ui/accessibility/ax_tree_serializer.h | 23 | ||||
-rw-r--r-- | ui/accessibility/ax_tree_source.h | 2 |
2 files changed, 13 insertions, 12 deletions
diff --git a/ui/accessibility/ax_tree_serializer.h b/ui/accessibility/ax_tree_serializer.h index c5f2c0d..9c735e0 100644 --- a/ui/accessibility/ax_tree_serializer.h +++ b/ui/accessibility/ax_tree_serializer.h @@ -172,10 +172,13 @@ AXTreeSerializer<AXSourceNode>::~AXTreeSerializer() { template<typename AXSourceNode> void AXTreeSerializer<AXSourceNode>::Reset() { - if (client_root_) { - DeleteClientSubtree(client_root_); - client_root_ = NULL; - } + if (!client_root_) + return; + + DeleteClientSubtree(client_root_); + client_id_map_.erase(client_root_->id); + delete client_root_; + client_root_ = NULL; } template<typename AXSourceNode> @@ -305,9 +308,7 @@ void AXTreeSerializer<AXSourceNode>::SerializeChanges( // 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; - DeleteClientSubtree(client_root_); - client_id_map_.erase(client_root_->id); - client_root_ = NULL; + 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 @@ -318,6 +319,7 @@ void AXTreeSerializer<AXSourceNode>::SerializeChanges( 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(); } @@ -342,6 +344,7 @@ void AXTreeSerializer<AXSourceNode>::DeleteClientSubtree( for (size_t i = 0; i < client_node->children.size(); ++i) { client_id_map_.erase(client_node->children[i]->id); DeleteClientSubtree(client_node->children[i]); + delete client_node->children[i]; } client_node->children.clear(); } @@ -365,10 +368,7 @@ void AXTreeSerializer<AXSourceNode>::SerializeChangedNodes( int id = tree_->GetId(node); ClientTreeNode* client_node = ClientTreeNodeById(id); if (!client_node) { - if (client_root_) { - client_id_map_.erase(client_root_->id); - DeleteClientSubtree(client_root_); - } + Reset(); client_root_ = new ClientTreeNode(); client_node = client_root_; client_node->id = id; @@ -408,6 +408,7 @@ void AXTreeSerializer<AXSourceNode>::SerializeChangedNodes( if (new_child_ids.find(old_child_id) == new_child_ids.end()) { client_id_map_.erase(old_child_id); DeleteClientSubtree(old_child); + delete old_child; } else { client_child_id_map[old_child_id] = old_child; } diff --git a/ui/accessibility/ax_tree_source.h b/ui/accessibility/ax_tree_source.h index 0c99c83..1f13d8f 100644 --- a/ui/accessibility/ax_tree_source.h +++ b/ui/accessibility/ax_tree_source.h @@ -20,7 +20,7 @@ namespace ui { // an accessibility tree will be sent over an IPC before being // consumed. template<typename AXNodeSource> -class AX_EXPORT AXTreeSource { +class AXTreeSource { public: virtual ~AXTreeSource() {} |