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

Side by Side 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, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 AXViewObjWrapper::AXViewObjWrapper(View* view) : view_(view) {
17 DCHECK(view->GetWidget());
18 if (view->GetWidget())
19 AXAuraObjCache::GetInstance()->GetOrCreate(view->GetWidget());
20 }
21
22 AXViewObjWrapper::~AXViewObjWrapper() {}
23
24 AXAuraObjWrapper* AXViewObjWrapper::GetParent() {
25 AXAuraObjCache* cache = AXAuraObjCache::GetInstance();
26 if (view_->parent())
27 return cache->GetOrCreate(view_->parent());
28
29 return cache->GetOrCreate(view_->GetWidget());
30 }
31
32 void AXViewObjWrapper::GetChildren(
33 std::vector<AXAuraObjWrapper*>* out_children) {
34 // TODO(dtseng): Need to handle |Widget| child of |View|.
35 for (int i = 0; i < view_->child_count(); ++i) {
36 AXAuraObjWrapper* child =
37 AXAuraObjCache::GetInstance()->GetOrCreate(view_->child_at(i));
38 out_children->push_back(child);
39 }
40 }
41
42 void AXViewObjWrapper::Serialize(ui::AXNodeData* out_node_data) {
43 ui::AXViewState view_data;
44 view_->GetAccessibleState(&view_data);
45 out_node_data->id = GetID();
46 out_node_data->role = view_data.role;
47 out_node_data->state = view_data.state();
48 out_node_data->location = view_->GetBoundsInScreen();
49
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 out_node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START,
56 view_data.selection_start);
57 out_node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END,
58 view_data.selection_end);
59 }
60
61 int32 AXViewObjWrapper::GetID() {
62 return AXAuraObjCache::GetInstance()->GetID(view_);
63 }
64
65 } // namespace views
OLDNEW
« 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