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

Unified Diff: ui/views/accessibility/ax_view_obj_wrapper.cc

Issue 246433012: Extend AXTreeSourceViews to handle aura::Window and views::Widget. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move files from c/b/u/views/accessibility to c/b/u/ash/accessibility 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
« no previous file with comments | « ui/views/accessibility/ax_view_obj_wrapper.h ('k') | ui/views/accessibility/ax_widget_obj_wrapper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/accessibility/ax_view_obj_wrapper.cc
diff --git a/ui/views/accessibility/ax_view_obj_wrapper.cc b/ui/views/accessibility/ax_view_obj_wrapper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..56b254076627239c9faf3ef25203566ccba98811
--- /dev/null
+++ b/ui/views/accessibility/ax_view_obj_wrapper.cc
@@ -0,0 +1,65 @@
+// 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 "ui/views/accessibility/ax_view_obj_wrapper.h"
+
+#include "base/strings/utf_string_conversions.h"
+#include "ui/accessibility/ax_node_data.h"
+#include "ui/accessibility/ax_view_state.h"
+#include "ui/views/accessibility/ax_aura_obj_cache.h"
+#include "ui/views/view.h"
+#include "ui/views/widget/widget.h"
+
+namespace views {
+
+AXViewObjWrapper::AXViewObjWrapper(View* view) : view_(view) {
+ DCHECK(view->GetWidget());
+ if (view->GetWidget())
+ AXAuraObjCache::GetInstance()->GetOrCreate(view->GetWidget());
+}
+
+AXViewObjWrapper::~AXViewObjWrapper() {}
+
+AXAuraObjWrapper* AXViewObjWrapper::GetParent() {
+ AXAuraObjCache* cache = AXAuraObjCache::GetInstance();
+ if (view_->parent())
+ return cache->GetOrCreate(view_->parent());
+
+ return cache->GetOrCreate(view_->GetWidget());
+}
+
+void AXViewObjWrapper::GetChildren(
+ std::vector<AXAuraObjWrapper*>* out_children) {
+ // TODO(dtseng): Need to handle |Widget| child of |View|.
+ for (int i = 0; i < view_->child_count(); ++i) {
+ AXAuraObjWrapper* child =
+ AXAuraObjCache::GetInstance()->GetOrCreate(view_->child_at(i));
+ out_children->push_back(child);
+ }
+}
+
+void AXViewObjWrapper::Serialize(ui::AXNodeData* out_node_data) {
+ ui::AXViewState view_data;
+ view_->GetAccessibleState(&view_data);
+ out_node_data->id = GetID();
+ out_node_data->role = view_data.role;
+ out_node_data->state = view_data.state();
+ out_node_data->location = view_->GetBoundsInScreen();
+
+ out_node_data->AddStringAttribute(
+ ui::AX_ATTR_NAME, base::UTF16ToUTF8(view_data.name));
+ out_node_data->AddStringAttribute(
+ ui::AX_ATTR_VALUE, base::UTF16ToUTF8(view_data.value));
+
+ out_node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START,
+ view_data.selection_start);
+ out_node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END,
+ view_data.selection_end);
+}
+
+int32 AXViewObjWrapper::GetID() {
+ return AXAuraObjCache::GetInstance()->GetID(view_);
+}
+
+} // namespace views
« no previous file with comments | « ui/views/accessibility/ax_view_obj_wrapper.h ('k') | ui/views/accessibility/ax_widget_obj_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698