Chromium Code Reviews| Index: ui/accessibility/ax_tree_serializer.h |
| diff --git a/ui/accessibility/ax_tree_serializer.h b/ui/accessibility/ax_tree_serializer.h |
| index 5435bbe2bae702eb274fcfc18b160a2fee67fe49..79ece2fcf43e797347376a594e860034817d92ea 100644 |
| --- a/ui/accessibility/ax_tree_serializer.h |
| +++ b/ui/accessibility/ax_tree_serializer.h |
| @@ -137,6 +137,9 @@ class AXTreeSerializer { |
| void SerializeChangedNodes(AXSourceNode node, |
| AXTreeUpdate* out_update); |
| + // Visit all of the descendants of |node| once. |
| + void WalkAllDescendants(AXSourceNode node); |
| + |
| // The tree source. |
| AXTreeSource<AXSourceNode>* tree_; |
| @@ -329,6 +332,11 @@ void AXTreeSerializer<AXSourceNode>::SerializeChanges( |
| // Serialize from the LCA, or from the root if there isn't one. |
| if (!tree_->IsValid(lca)) |
| lca = tree_->GetRoot(); |
| + |
| + // Work around flaky source trees where nodes don't figure out their |
|
David Tseng
2015/06/22 20:58:29
Is there a specific source tree with this issue? P
dmazzoni
2015/06/22 21:11:26
The test I added exposes this bug. I added a speci
|
| + // correct parent/child relationships until you walk the whole tree once. |
| + WalkAllDescendants(lca); |
| + |
| SerializeChangedNodes(lca, out_update); |
| } |
| @@ -472,6 +480,15 @@ void AXTreeSerializer<AXSourceNode>::SerializeChangedNodes( |
| actual_serialized_node_child_ids); |
| } |
| +template<typename AXSourceNode> |
| +void AXTreeSerializer<AXSourceNode>::WalkAllDescendants( |
| + AXSourceNode node) { |
| + std::vector<AXSourceNode> children; |
| + tree_->GetChildren(node, &children); |
| + for (size_t i = 0; i < children.size(); ++i) |
| + WalkAllDescendants(children[i]); |
| +} |
| + |
| } // namespace ui |
| #endif // UI_ACCESSIBILITY_AX_TREE_SERIALIZER_H_ |