| 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 : public AXTreeSource<const AXNode*> { | 17 class AX_EXPORT AXTreeSourceAdapter : public AXTreeSource<const AXNode*> { |
| 18 public: | 18 public: |
| 19 AXTreeSourceAdapter(AXTree* tree) : tree_(tree) {} | 19 AXTreeSourceAdapter(AXTree* tree) : tree_(tree) {} |
| 20 ~AXTreeSourceAdapter() override {} | 20 ~AXTreeSourceAdapter() override {} |
| 21 | 21 |
| 22 // AXTreeSource implementation. | 22 // AXTreeSource implementation. |
| 23 AXNode* GetRoot() const override { return tree_->GetRoot(); } | 23 AXNode* GetRoot() const override { return tree_->root(); } |
| 24 | 24 |
| 25 AXNode* GetFromId(int32 id) const override { return tree_->GetFromId(id); } | 25 AXNode* GetFromId(int32 id) const override { return tree_->GetFromId(id); } |
| 26 | 26 |
| 27 int32 GetId(const AXNode* node) const override { return node->id(); } | 27 int32 GetId(const AXNode* node) const override { return node->id(); } |
| 28 | 28 |
| 29 void GetChildren(const AXNode* node, | 29 void GetChildren(const AXNode* node, |
| 30 std::vector<const AXNode*>* out_children) const override { | 30 std::vector<const AXNode*>* out_children) const override { |
| 31 for (int i = 0; i < node->child_count(); ++i) | 31 for (int i = 0; i < node->child_count(); ++i) |
| 32 out_children->push_back(node->ChildAtIndex(i)); | 32 out_children->push_back(node->ChildAtIndex(i)); |
| 33 } | 33 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 60 } | 60 } |
| 61 | 61 |
| 62 AXSerializableTree::~AXSerializableTree() { | 62 AXSerializableTree::~AXSerializableTree() { |
| 63 } | 63 } |
| 64 | 64 |
| 65 AXTreeSource<const AXNode*>* AXSerializableTree::CreateTreeSource() { | 65 AXTreeSource<const AXNode*>* AXSerializableTree::CreateTreeSource() { |
| 66 return new AXTreeSourceAdapter(this); | 66 return new AXTreeSourceAdapter(this); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace ui | 69 } // namespace ui |
| OLD | NEW |