Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: chrome/browser/ui/views/accessibility/ax_tree_source_views.cc

Issue 246433012: Extend AXTreeSourceViews to handle aura::Window and views::Widget. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reset serializer on enable. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 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.
4
5 #include "chrome/browser/ui/views/accessibility/ax_tree_source_views.h"
6
7 #include <vector>
8
9 #include "ui/views/accessibility/ax_aura_obj_cache.h"
10 #include "ui/views/accessibility/ax_aura_obj_wrapper.h"
11
12 AXTreeSourceViews::AXTreeSourceViews() {
13 root_.reset(
14 new AXRootObjWrapper(views::AXAuraObjCache::GetInstance()->GetNextID()));
15 }
16
17 AXTreeSourceViews::~AXTreeSourceViews() {
18 root_.reset();
19 }
20
21 views::AXAuraObjWrapper* AXTreeSourceViews::GetRoot() const {
aboxhall 2014/04/28 19:50:38 We could use a using-directive for views::AXAuraOb
David Tseng 2014/04/29 01:35:03 Done.
22 return root_.get();
23 }
24
25 views::AXAuraObjWrapper* AXTreeSourceViews::GetFromId(int32 id) const {
26 if (id == root_->GetID())
aboxhall 2014/04/28 19:50:38 Why special-case this? Is it not in the cache?
David Tseng 2014/04/29 01:35:03 The root itself isn't stored in the AXAuraObjCache
27 return root_.get();
28 return views::AXAuraObjCache::GetInstance()->Get(id);
29 }
30
31 int32 AXTreeSourceViews::GetId(views::AXAuraObjWrapper* node) const {
32 return node->GetID();
33 }
34
35 void AXTreeSourceViews::GetChildren(views::AXAuraObjWrapper* node,
36 std::vector<views::AXAuraObjWrapper*>* out_children) const {
37 node->GetChildren(out_children);
38 }
39
40 views::AXAuraObjWrapper* AXTreeSourceViews::GetParent(
41 views::AXAuraObjWrapper* node) const {
42 views::AXAuraObjWrapper* parent = node->GetParent();
43 if (!parent && root_->HasChild(node))
aboxhall 2014/04/28 19:50:38 Why would this happen? Does the root not get added
David Tseng 2014/04/29 01:35:03 There is no "root" hooking up all aura::Window obj
44 parent = root_.get();
45 return parent;
46 }
47
48 bool AXTreeSourceViews::IsValid(views::AXAuraObjWrapper* node) const {
49 return node && node->GetID() != -1;
50 }
51
52 bool AXTreeSourceViews::IsEqual(views::AXAuraObjWrapper* node1,
53 views::AXAuraObjWrapper* node2) const {
54 if (!node1 || !node2)
aboxhall 2014/04/28 19:50:38 I assume we don't want to return true in the case
David Tseng 2014/04/29 01:35:03 Yes, that's correct.
55 return false;
56
57 return node1->GetID() == node2->GetID() && node1->GetID() != -1;
58 }
59
60 views::AXAuraObjWrapper* AXTreeSourceViews::GetNull() const {
61 return NULL;
62 }
63
64 void AXTreeSourceViews::SerializeNode(
65 views::AXAuraObjWrapper* node, ui::AXNodeData* out_data) const {
66 node->Serialize(out_data);
67 }
68
69 std::string AXTreeSourceViews::ToString(
70 views::AXAuraObjWrapper* root, std::string prefix) {
71 ui::AXNodeData out_data;
72 root->Serialize(&out_data);
aboxhall 2014/04/28 19:50:38 Similarly, why is this called out_data, when it ne
David Tseng 2014/04/29 01:35:03 Same as above.
73 std::string output = prefix + out_data.ToString() + '\n';
74
75 std::vector<views::AXAuraObjWrapper*> out_children;
76 root->GetChildren(&out_children);
77
78 prefix += prefix[0];
79 for (size_t i = 0; i < out_children.size(); ++i)
80 output += ToString(out_children[i], prefix);
81
82 return output;
83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698