| OLD | NEW |
| 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_node_data.h" |
| 10 #include "ui/events/event_utils.h" | 10 #include "ui/events/event_utils.h" |
| 11 #include "ui/views/accessibility/ax_aura_obj_cache.h" | 11 #include "ui/views/accessibility/ax_aura_obj_cache.h" |
| 12 #include "ui/views/view.h" | 12 #include "ui/views/view.h" |
| 13 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
| 14 | 14 |
| 15 namespace views { | 15 namespace views { |
| 16 | 16 |
| 17 AXViewObjWrapper::AXViewObjWrapper(View* view) : view_(view) { | 17 AXViewObjWrapper::AXViewObjWrapper(View* view) : view_(view) { |
| 18 if (view->GetWidget()) | 18 if (view->GetWidget()) |
| 19 AXAuraObjCache::GetInstance()->GetOrCreate(view->GetWidget()); | 19 AXAuraObjCache::GetInstance()->GetOrCreate(view->GetWidget()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 39 if (!view_->child_at(i)->visible()) | 39 if (!view_->child_at(i)->visible()) |
| 40 continue; | 40 continue; |
| 41 | 41 |
| 42 AXAuraObjWrapper* child = | 42 AXAuraObjWrapper* child = |
| 43 AXAuraObjCache::GetInstance()->GetOrCreate(view_->child_at(i)); | 43 AXAuraObjCache::GetInstance()->GetOrCreate(view_->child_at(i)); |
| 44 out_children->push_back(child); | 44 out_children->push_back(child); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 void AXViewObjWrapper::Serialize(ui::AXNodeData* out_node_data) { | 48 void AXViewObjWrapper::Serialize(ui::AXNodeData* out_node_data) { |
| 49 ui::AXViewState view_data; | 49 out_node_data->state = 0; |
| 50 view_->GetAccessibleState(&view_data); | 50 view_->GetAccessibleNodeData(out_node_data); |
| 51 | 51 |
| 52 out_node_data->id = GetID(); | 52 out_node_data->id = GetID(); |
| 53 out_node_data->role = view_data.role; | |
| 54 | 53 |
| 55 out_node_data->state = view_data.state(); | |
| 56 if (view_->IsFocusable()) | 54 if (view_->IsFocusable()) |
| 57 out_node_data->state |= 1 << ui::AX_STATE_FOCUSABLE; | 55 out_node_data->state |= 1 << ui::AX_STATE_FOCUSABLE; |
| 58 if (!view_->visible()) | 56 if (!view_->visible()) |
| 59 out_node_data->state |= 1 << ui::AX_STATE_INVISIBLE; | 57 out_node_data->state |= 1 << ui::AX_STATE_INVISIBLE; |
| 60 | 58 |
| 61 out_node_data->location = gfx::RectF(view_->GetBoundsInScreen()); | 59 out_node_data->location = gfx::RectF(view_->GetBoundsInScreen()); |
| 62 | |
| 63 out_node_data->AddStringAttribute( | |
| 64 ui::AX_ATTR_NAME, base::UTF16ToUTF8(view_data.name)); | |
| 65 out_node_data->AddStringAttribute( | |
| 66 ui::AX_ATTR_VALUE, base::UTF16ToUTF8(view_data.value)); | |
| 67 | |
| 68 if (view_data.selection_start > -1 && view_data.selection_end > -1) { | |
| 69 out_node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, | |
| 70 view_data.selection_start); | |
| 71 | |
| 72 out_node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, | |
| 73 view_data.selection_end); | |
| 74 } | |
| 75 } | 60 } |
| 76 | 61 |
| 77 int32_t AXViewObjWrapper::GetID() { | 62 int32_t AXViewObjWrapper::GetID() { |
| 78 return AXAuraObjCache::GetInstance()->GetID(view_); | 63 return AXAuraObjCache::GetInstance()->GetID(view_); |
| 79 } | 64 } |
| 80 | 65 |
| 81 void AXViewObjWrapper::DoDefault() { | 66 void AXViewObjWrapper::DoDefault() { |
| 82 gfx::Rect rect = view_->GetLocalBounds(); | 67 gfx::Rect rect = view_->GetLocalBounds(); |
| 83 gfx::Point center = rect.CenterPoint(); | 68 gfx::Point center = rect.CenterPoint(); |
| 84 view_->OnMousePressed(ui::MouseEvent( | 69 view_->OnMousePressed(ui::MouseEvent( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 100 void AXViewObjWrapper::SetSelection(int32_t start, int32_t end) { | 85 void AXViewObjWrapper::SetSelection(int32_t start, int32_t end) { |
| 101 // TODO(dtseng): Implement. | 86 // TODO(dtseng): Implement. |
| 102 } | 87 } |
| 103 | 88 |
| 104 void AXViewObjWrapper::ShowContextMenu() { | 89 void AXViewObjWrapper::ShowContextMenu() { |
| 105 view_->ShowContextMenu(view_->bounds().CenterPoint(), | 90 view_->ShowContextMenu(view_->bounds().CenterPoint(), |
| 106 ui::MENU_SOURCE_KEYBOARD); | 91 ui::MENU_SOURCE_KEYBOARD); |
| 107 } | 92 } |
| 108 | 93 |
| 109 } // namespace views | 94 } // namespace views |
| OLD | NEW |