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

Side by Side Diff: ui/views/accessibility/ax_view_obj_wrapper.cc

Issue 667713006: Implement automatic load of composed/embedded automation trees (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Get test to pass. Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/accessibility/ax_view_obj_wrapper.h" 5 #include "ui/views/accessibility/ax_view_obj_wrapper.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/accessibility/ax_node_data.h" 8 #include "ui/accessibility/ax_node_data.h"
9 #include "ui/accessibility/ax_view_state.h" 9 #include "ui/accessibility/ax_view_state.h"
10 #include "ui/views/accessibility/ax_aura_obj_cache.h" 10 #include "ui/views/accessibility/ax_aura_obj_cache.h"
(...skipping 24 matching lines...) Expand all
35 for (int i = 0; i < view_->child_count(); ++i) { 35 for (int i = 0; i < view_->child_count(); ++i) {
36 AXAuraObjWrapper* child = 36 AXAuraObjWrapper* child =
37 AXAuraObjCache::GetInstance()->GetOrCreate(view_->child_at(i)); 37 AXAuraObjCache::GetInstance()->GetOrCreate(view_->child_at(i));
38 out_children->push_back(child); 38 out_children->push_back(child);
39 } 39 }
40 } 40 }
41 41
42 void AXViewObjWrapper::Serialize(ui::AXNodeData* out_node_data) { 42 void AXViewObjWrapper::Serialize(ui::AXNodeData* out_node_data) {
43 ui::AXViewState view_data; 43 ui::AXViewState view_data;
44 view_->GetAccessibleState(&view_data); 44 view_->GetAccessibleState(&view_data);
45
45 out_node_data->id = GetID(); 46 out_node_data->id = GetID();
46 out_node_data->role = view_data.role; 47 out_node_data->role = view_data.role;
47 48
48 out_node_data->state = view_data.state(); 49 out_node_data->state = view_data.state();
49 if (view_->HasFocus()) 50 if (view_->HasFocus())
50 out_node_data->state |= 1 << ui::AX_STATE_FOCUSED; 51 out_node_data->state |= 1 << ui::AX_STATE_FOCUSED;
51 if (view_->IsFocusable()) 52 if (view_->IsFocusable())
52 out_node_data->state |= 1 << ui::AX_STATE_FOCUSABLE; 53 out_node_data->state |= 1 << ui::AX_STATE_FOCUSABLE;
53 54
54 out_node_data->location = view_->GetBoundsInScreen(); 55 out_node_data->location = view_->GetBoundsInScreen();
55 56
56 out_node_data->AddStringAttribute( 57 out_node_data->AddStringAttribute(
57 ui::AX_ATTR_NAME, base::UTF16ToUTF8(view_data.name)); 58 ui::AX_ATTR_NAME, base::UTF16ToUTF8(view_data.name));
58 out_node_data->AddStringAttribute( 59 out_node_data->AddStringAttribute(
59 ui::AX_ATTR_VALUE, base::UTF16ToUTF8(view_data.value)); 60 ui::AX_ATTR_VALUE, base::UTF16ToUTF8(view_data.value));
60 61
61 out_node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, 62 if (view_data.selection_start > -1 &&
62 view_data.selection_start); 63 view_data.selection_end > -1) {
63 out_node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, 64 out_node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START,
64 view_data.selection_end); 65 view_data.selection_start);
66
67 out_node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END,
68 view_data.selection_end);
69 }
65 } 70 }
66 71
67 int32 AXViewObjWrapper::GetID() { 72 int32 AXViewObjWrapper::GetID() {
68 return AXAuraObjCache::GetInstance()->GetID(view_); 73 return AXAuraObjCache::GetInstance()->GetID(view_);
69 } 74 }
70 75
71 void AXViewObjWrapper::DoDefault() { 76 void AXViewObjWrapper::DoDefault() {
72 gfx::Rect rect = view_->GetBoundsInScreen(); 77 gfx::Rect rect = view_->GetBoundsInScreen();
73 gfx::Point center = rect.CenterPoint(); 78 gfx::Point center = rect.CenterPoint();
74 view_->OnMousePressed(ui::MouseEvent(ui::ET_MOUSE_PRESSED, center, center, 79 view_->OnMousePressed(ui::MouseEvent(ui::ET_MOUSE_PRESSED, center, center,
75 ui::EF_LEFT_MOUSE_BUTTON, 80 ui::EF_LEFT_MOUSE_BUTTON,
76 ui::EF_LEFT_MOUSE_BUTTON)); 81 ui::EF_LEFT_MOUSE_BUTTON));
77 } 82 }
78 83
79 void AXViewObjWrapper::Focus() { 84 void AXViewObjWrapper::Focus() {
80 view_->RequestFocus(); 85 view_->RequestFocus();
81 } 86 }
82 87
83 void AXViewObjWrapper::MakeVisible() { 88 void AXViewObjWrapper::MakeVisible() {
84 // TODO(dtseng): Implement. 89 // TODO(dtseng): Implement.
85 } 90 }
86 91
87 void AXViewObjWrapper::SetSelection(int32 start, int32 end) { 92 void AXViewObjWrapper::SetSelection(int32 start, int32 end) {
88 // TODO(dtseng): Implement. 93 // TODO(dtseng): Implement.
89 } 94 }
90 95
91 } // namespace views 96 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698