Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 "ui/views/accessibility/ax_view_obj_wrapper.h" | |
| 6 | |
| 7 #include "base/strings/utf_string_conversions.h" | |
| 8 #include "ui/accessibility/ax_node_data.h" | |
| 9 #include "ui/accessibility/ax_view_state.h" | |
| 10 #include "ui/views/accessibility/ax_aura_obj_cache.h" | |
| 11 #include "ui/views/view.h" | |
| 12 #include "ui/views/widget/widget.h" | |
| 13 | |
| 14 namespace views { | |
| 15 | |
| 16 AXAuraObjWrapper* AXViewObjWrapper::GetParent() { | |
| 17 AXAuraObjCache* cache = AXAuraObjCache::GetInstance(); | |
| 18 if (view_->parent()) | |
| 19 return cache->GetOrCreate(view_->parent()); | |
| 20 | |
| 21 return cache->GetOrCreate(view_->GetWidget()); | |
| 22 } | |
| 23 | |
| 24 void AXViewObjWrapper::GetChildren( | |
| 25 std::vector<AXAuraObjWrapper*>* out_children) { | |
| 26 // TODO(dtseng): Need to handle |Widget| child of |View|. | |
| 27 for (int i = 0; i < view_->child_count(); ++i) { | |
| 28 AXAuraObjWrapper* child = | |
| 29 AXAuraObjCache::GetInstance()->GetOrCreate(view_->child_at(i)); | |
| 30 out_children->push_back(child); | |
| 31 } | |
| 32 } | |
| 33 | |
| 34 void AXViewObjWrapper::Serialize(ui::AXNodeData* out_node_data) { | |
| 35 ui::AXViewState view_data; | |
| 36 const_cast<View*>(view_)->GetAccessibleState(&view_data); | |
| 37 out_node_data->id = GetID(); | |
| 38 out_node_data->role = view_data.role; | |
| 39 | |
| 40 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.
| |
| 41 for (int32 state = ui::AX_STATE_NONE; | |
| 42 state <= ui::AX_STATE_LAST; | |
| 43 ++state) { | |
| 44 ui::AXState state_flag = static_cast<ui::AXState>(state); | |
| 45 if (view_data.HasStateFlag(state_flag)) | |
| 46 out_node_data->state |= 1 << state; | |
| 47 } | |
| 48 | |
| 49 out_node_data->location = view_->GetBoundsInScreen(); | |
| 50 out_node_data->AddStringAttribute( | |
| 51 ui::AX_ATTR_NAME, base::UTF16ToUTF8(view_data.name)); | |
| 52 out_node_data->AddStringAttribute( | |
| 53 ui::AX_ATTR_VALUE, base::UTF16ToUTF8(view_data.value)); | |
| 54 } | |
| 55 | |
| 56 int32 AXViewObjWrapper::GetID() { | |
| 57 return AXAuraObjCache::GetInstance()->GetID(view_); | |
| 58 } | |
| 59 | |
| 60 } // namespace views | |
| OLD | NEW |