Views Omnibox: tolerate minor click-to-select-all dragging.
[chromium-blink-merge.git] / ui / accessibility / ax_serializable_tree.cc
blobca52ab39a23944731e8f5af4a4997ecc3b6b23fd
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
3 // found in the LICENSE file.
5 #include "ui/accessibility/ax_serializable_tree.h"
7 #include "ui/accessibility/ax_node.h"
9 namespace ui {
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
13 // of this is so that AXTreeSerializer only needs to work with the
14 // AXTreeSource abstraction and doesn't need to actually know about
15 // AXTree directly. Another AXTreeSource is used to abstract the Blink
16 // accessibility tree.
17 class AX_EXPORT AXTreeSourceAdapter : public AXTreeSource<AXNode> {
18 public:
19 AXTreeSourceAdapter(AXTree* tree) : tree_(tree) {}
20 virtual ~AXTreeSourceAdapter() {}
22 // AXTreeSource implementation.
23 virtual AXNode* GetRoot() const OVERRIDE {
24 return tree_->GetRoot();
27 virtual AXNode* GetFromId(int32 id) const OVERRIDE {
28 return tree_->GetFromId(id);
31 virtual int32 GetId(const AXNode* node) const OVERRIDE {
32 return node->id();
35 virtual int GetChildCount(const AXNode* node) const OVERRIDE {
36 return node->child_count();
39 virtual AXNode* GetChildAtIndex(const AXNode* node, int index)
40 const OVERRIDE {
41 return node->ChildAtIndex(index);
44 virtual AXNode* GetParent(const AXNode* node) const OVERRIDE {
45 return node->parent();
48 virtual void SerializeNode(
49 const AXNode* node, AXNodeData* out_data) const OVERRIDE {
50 *out_data = node->data();
53 private:
54 AXTree* tree_;
57 AXSerializableTree::AXSerializableTree()
58 : AXTree() {}
60 AXSerializableTree::AXSerializableTree(const AXTreeUpdate& initial_state)
61 : AXTree(initial_state) {
64 AXSerializableTree::~AXSerializableTree() {
67 AXTreeSource<AXNode>* AXSerializableTree::CreateTreeSource() {
68 return new AXTreeSourceAdapter(this);
71 } // namespace ui