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_obj_cache.h" | |
| 11 #include "ui/views/view.h" | |
| 12 #include "ui/views/widget/widget.h" | |
| 13 | |
| 14 namespace views { | |
| 15 | |
| 16 AXNodeSourceObjWrapper* AXViewObjWrapper::GetParent() { | |
| 17 AXObjCache* cache = AXObjCache::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<AXNodeSourceObjWrapper*>* out_children) { | |
| 26 // 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
| |
| 27 for (int i = 0; i < view_->child_count(); ++i) { | |
| 28 AXNodeSourceObjWrapper* child = | |
| 29 AXObjCache::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 = AXObjCache::GetInstance()->GetID(view_); | |
| 38 out_node_data->role = view_data.role; | |
| 39 | |
| 40 out_node_data->state = 0; | |
| 41 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
| |
| 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 } // namespace views | |
| OLD | NEW |