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..1c9f79e207a58426bba93a86176a58caf9df44e7 |
--- /dev/null |
+++ b/ui/views/accessibility/ax_view_obj_wrapper.cc |
@@ -0,0 +1,56 @@ |
+// 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_obj_cache.h" |
+#include "ui/views/view.h" |
+#include "ui/views/widget/widget.h" |
+ |
+namespace views { |
+ |
+AXNodeSourceObjWrapper* AXViewObjWrapper::GetParent() { |
+ AXObjCache* cache = AXObjCache::GetInstance(); |
+ if (view_->parent()) |
+ return cache->GetOrCreate(view_->parent()); |
+ |
+ return cache->GetOrCreate(view_->GetWidget()); |
+} |
+ |
+void AXViewObjWrapper::GetChildren( |
+ std::vector<AXNodeSourceObjWrapper*>* out_children) { |
+ // TODO(dtseng): Need to handle |Widget| child of |View|. |
dmazzoni
2014/04/23 05:06:44
Note that NativeViewHost has GetNativeViewAccessib
David Tseng
2014/04/23 18:20:01
I think that could work. So, to reiterate, NativeV
David Tseng
2014/04/23 21:32:55
N/m; didn't check to see that GetNativeViewAccessi
|
+ for (int i = 0; i < view_->child_count(); ++i) { |
+ AXNodeSourceObjWrapper* child = |
+ AXObjCache::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 = AXObjCache::GetInstance()->GetID(view_); |
+ out_node_data->role = view_data.role; |
+ |
+ out_node_data->state = 0; |
+ for (int32 state = ui::AX_STATE_NONE; |
dmazzoni
2014/04/23 05:06:44
Why can't you copy it directly? I think AXViewStat
David Tseng
2014/04/23 18:20:01
I could if I added an accesser...but AXViewState d
|
+ 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)); |
+} |
+ |
+} // namespace views |