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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/accessibility/ax_tree_source_views.cc
diff --git a/chrome/browser/ui/views/accessibility/ax_tree_source_views.cc b/chrome/browser/ui/views/accessibility/ax_tree_source_views.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0ee8c565e032ccb031b9ab2d7384cf704e2e1c60
--- /dev/null
+++ b/chrome/browser/ui/views/accessibility/ax_tree_source_views.cc
@@ -0,0 +1,83 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/views/accessibility/ax_tree_source_views.h"
+
+#include <vector>
+
+#include "ui/views/accessibility/ax_aura_obj_cache.h"
+#include "ui/views/accessibility/ax_aura_obj_wrapper.h"
+
+AXTreeSourceViews::AXTreeSourceViews() {
+ root_.reset(
+ new AXRootObjWrapper(views::AXAuraObjCache::GetInstance()->GetNextID()));
+}
+
+AXTreeSourceViews::~AXTreeSourceViews() {
+ root_.reset();
+}
+
+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.
+ return root_.get();
+}
+
+views::AXAuraObjWrapper* AXTreeSourceViews::GetFromId(int32 id) const {
+ 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
+ return root_.get();
+ return views::AXAuraObjCache::GetInstance()->Get(id);
+}
+
+int32 AXTreeSourceViews::GetId(views::AXAuraObjWrapper* node) const {
+ return node->GetID();
+}
+
+void AXTreeSourceViews::GetChildren(views::AXAuraObjWrapper* node,
+ std::vector<views::AXAuraObjWrapper*>* out_children) const {
+ node->GetChildren(out_children);
+}
+
+views::AXAuraObjWrapper* AXTreeSourceViews::GetParent(
+ views::AXAuraObjWrapper* node) const {
+ views::AXAuraObjWrapper* parent = node->GetParent();
+ 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
+ parent = root_.get();
+ return parent;
+}
+
+bool AXTreeSourceViews::IsValid(views::AXAuraObjWrapper* node) const {
+ return node && node->GetID() != -1;
+}
+
+bool AXTreeSourceViews::IsEqual(views::AXAuraObjWrapper* node1,
+ views::AXAuraObjWrapper* node2) const {
+ 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.
+ return false;
+
+ return node1->GetID() == node2->GetID() && node1->GetID() != -1;
+}
+
+views::AXAuraObjWrapper* AXTreeSourceViews::GetNull() const {
+ return NULL;
+}
+
+void AXTreeSourceViews::SerializeNode(
+ views::AXAuraObjWrapper* node, ui::AXNodeData* out_data) const {
+ node->Serialize(out_data);
+}
+
+std::string AXTreeSourceViews::ToString(
+ views::AXAuraObjWrapper* root, std::string prefix) {
+ ui::AXNodeData out_data;
+ 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.
+ std::string output = prefix + out_data.ToString() + '\n';
+
+ std::vector<views::AXAuraObjWrapper*> out_children;
+ root->GetChildren(&out_children);
+
+ prefix += prefix[0];
+ for (size_t i = 0; i < out_children.size(); ++i)
+ output += ToString(out_children[i], prefix);
+
+ return output;
+}

Powered by Google App Engine
This is Rietveld 408576698