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

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: With tests. 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: 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..3356e19eb97255bafb884d7a94d873c789dac968
--- /dev/null
+++ b/ui/views/accessibility/ax_view_obj_wrapper.cc
@@ -0,0 +1,60 @@
+// 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 {
+
+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;
+ const_cast<View*>(view_)->GetAccessibleState(&view_data);
+ out_node_data->id = GetID();
+ out_node_data->role = view_data.role;
+
+ out_node_data->state = 0;
dmazzoni 2014/04/25 06:13:59 Please just add an accessor so you can copy it dir
David Tseng 2014/04/25 22:47:29 Done.
+ for (int32 state = ui::AX_STATE_NONE;
+ state <= ui::AX_STATE_LAST;
+ ++state) {
+ ui::AXState state_flag = static_cast<ui::AXState>(state);
+ if (view_data.HasStateFlag(state_flag))
+ out_node_data->state |= 1 << 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));
+}
+
+int32 AXViewObjWrapper::GetID() {
+ return AXAuraObjCache::GetInstance()->GetID(view_);
+}
+
+} // namespace views

Powered by Google App Engine
This is Rietveld 408576698