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