| OLD | NEW |
| 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_serializable_tree.h" | 5 #include "ui/accessibility/ax_serializable_tree.h" |
| 6 | 6 |
| 7 #include "ui/accessibility/ax_node.h" | 7 #include "ui/accessibility/ax_node.h" |
| 8 | 8 |
| 9 namespace ui { | 9 namespace ui { |
| 10 | 10 |
| 11 // This class is an implementation of the AXTreeSource interface with | 11 // This class is an implementation of the AXTreeSource interface with |
| 12 // AXNode as the node type, that just delegates to an AXTree. The purpose | 12 // AXNode as the node type, that just delegates to an AXTree. The purpose |
| 13 // of this is so that AXTreeSerializer only needs to work with the | 13 // of this is so that AXTreeSerializer only needs to work with the |
| 14 // AXTreeSource abstraction and doesn't need to actually know about | 14 // AXTreeSource abstraction and doesn't need to actually know about |
| 15 // AXTree directly. Another AXTreeSource is used to abstract the Blink | 15 // AXTree directly. Another AXTreeSource is used to abstract the Blink |
| 16 // accessibility tree. | 16 // accessibility tree. |
| 17 class AX_EXPORT AXTreeSourceAdapter | 17 class AX_EXPORT AXTreeSourceAdapter |
| 18 : public AXTreeSource<const AXNode*, AXNodeData> { | 18 : public AXTreeSource<const AXNode*, AXNodeData, AXTreeData> { |
| 19 public: | 19 public: |
| 20 AXTreeSourceAdapter(AXTree* tree) : tree_(tree) {} | 20 AXTreeSourceAdapter(AXTree* tree) : tree_(tree) {} |
| 21 ~AXTreeSourceAdapter() override {} | 21 ~AXTreeSourceAdapter() override {} |
| 22 | 22 |
| 23 // AXTreeSource implementation. | 23 // AXTreeSource implementation. |
| 24 AXTreeData GetTreeData() const override { return tree_->data(); } |
| 25 |
| 24 AXNode* GetRoot() const override { return tree_->root(); } | 26 AXNode* GetRoot() const override { return tree_->root(); } |
| 25 | 27 |
| 26 AXNode* GetFromId(int32 id) const override { return tree_->GetFromId(id); } | 28 AXNode* GetFromId(int32 id) const override { return tree_->GetFromId(id); } |
| 27 | 29 |
| 28 int32 GetId(const AXNode* node) const override { return node->id(); } | 30 int32 GetId(const AXNode* node) const override { return node->id(); } |
| 29 | 31 |
| 30 void GetChildren(const AXNode* node, | 32 void GetChildren(const AXNode* node, |
| 31 std::vector<const AXNode*>* out_children) const override { | 33 std::vector<const AXNode*>* out_children) const override { |
| 32 for (int i = 0; i < node->child_count(); ++i) | 34 for (int i = 0; i < node->child_count(); ++i) |
| 33 out_children->push_back(node->ChildAtIndex(i)); | 35 out_children->push_back(node->ChildAtIndex(i)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 50 } | 52 } |
| 51 | 53 |
| 52 private: | 54 private: |
| 53 AXTree* tree_; | 55 AXTree* tree_; |
| 54 }; | 56 }; |
| 55 | 57 |
| 56 AXSerializableTree::AXSerializableTree() | 58 AXSerializableTree::AXSerializableTree() |
| 57 : AXTree() {} | 59 : AXTree() {} |
| 58 | 60 |
| 59 AXSerializableTree::AXSerializableTree( | 61 AXSerializableTree::AXSerializableTree( |
| 60 const AXTreeUpdate<AXNodeData>& initial_state) | 62 const AXTreeUpdate& initial_state) |
| 61 : AXTree(initial_state) { | 63 : AXTree(initial_state) { |
| 62 } | 64 } |
| 63 | 65 |
| 64 AXSerializableTree::~AXSerializableTree() { | 66 AXSerializableTree::~AXSerializableTree() { |
| 65 } | 67 } |
| 66 | 68 |
| 67 AXTreeSource<const AXNode*, AXNodeData>* | 69 AXTreeSource<const AXNode*, AXNodeData, AXTreeData>* |
| 68 AXSerializableTree::CreateTreeSource() { | 70 AXSerializableTree::CreateTreeSource() { |
| 69 return new AXTreeSourceAdapter(this); | 71 return new AXTreeSourceAdapter(this); |
| 70 } | 72 } |
| 71 | 73 |
| 72 } // namespace ui | 74 } // namespace ui |
| OLD | NEW |