| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/native_view_accessibility.h" | 5 #include "ui/views/accessibility/native_view_accessibility.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "ui/accessibility/ax_view_state.h" | 9 #include "ui/accessibility/ax_view_state.h" |
| 10 #include "ui/events/event_utils.h" | 10 #include "ui/events/event_utils.h" |
| 11 #include "ui/gfx/native_widget_types.h" |
| 11 #include "ui/views/controls/native/native_view_host.h" | 12 #include "ui/views/controls/native/native_view_host.h" |
| 12 #include "ui/views/view.h" | 13 #include "ui/views/view.h" |
| 13 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
| 14 | 15 |
| 15 namespace views { | 16 namespace views { |
| 16 | 17 |
| 17 #if !defined(PLATFORM_HAS_NATIVE_VIEW_ACCESSIBILITY_IMPL) | 18 #if !defined(PLATFORM_HAS_NATIVE_VIEW_ACCESSIBILITY_IMPL) |
| 18 // static | 19 // static |
| 19 NativeViewAccessibility* NativeViewAccessibility::Create(View* view) { | 20 NativeViewAccessibility* NativeViewAccessibility::Create(View* view) { |
| 20 return new NativeViewAccessibility(view); | 21 return new NativeViewAccessibility(view); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 data_.state = state.state(); | 59 data_.state = state.state(); |
| 59 data_.location = gfx::RectF(view_->GetBoundsInScreen()); | 60 data_.location = gfx::RectF(view_->GetBoundsInScreen()); |
| 60 data_.AddStringAttribute(ui::AX_ATTR_NAME, base::UTF16ToUTF8(state.name)); | 61 data_.AddStringAttribute(ui::AX_ATTR_NAME, base::UTF16ToUTF8(state.name)); |
| 61 data_.AddStringAttribute(ui::AX_ATTR_VALUE, base::UTF16ToUTF8(state.value)); | 62 data_.AddStringAttribute(ui::AX_ATTR_VALUE, base::UTF16ToUTF8(state.value)); |
| 62 data_.AddStringAttribute(ui::AX_ATTR_ACTION, | 63 data_.AddStringAttribute(ui::AX_ATTR_ACTION, |
| 63 base::UTF16ToUTF8(state.default_action)); | 64 base::UTF16ToUTF8(state.default_action)); |
| 64 data_.AddStringAttribute(ui::AX_ATTR_SHORTCUT, | 65 data_.AddStringAttribute(ui::AX_ATTR_SHORTCUT, |
| 65 base::UTF16ToUTF8(state.keyboard_shortcut)); | 66 base::UTF16ToUTF8(state.keyboard_shortcut)); |
| 66 data_.AddStringAttribute(ui::AX_ATTR_PLACEHOLDER, | 67 data_.AddStringAttribute(ui::AX_ATTR_PLACEHOLDER, |
| 67 base::UTF16ToUTF8(state.placeholder)); | 68 base::UTF16ToUTF8(state.placeholder)); |
| 69 |
| 70 if (state.description.empty() && |
| 71 view_->GetTooltipText(gfx::Point(), &state.description)) |
| 72 data_.AddStringAttribute(ui::AX_ATTR_DESCRIPTION, |
| 73 base::UTF16ToUTF8(state.description)); |
| 74 |
| 68 data_.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, state.selection_start); | 75 data_.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, state.selection_start); |
| 69 data_.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, state.selection_end); | 76 data_.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, state.selection_end); |
| 70 | 77 |
| 71 data_.state |= (1 << ui::AX_STATE_FOCUSABLE); | 78 data_.state |= (1 << ui::AX_STATE_FOCUSABLE); |
| 72 | 79 |
| 73 if (!view_->enabled()) | 80 if (!view_->enabled()) |
| 74 data_.state |= (1 << ui::AX_STATE_DISABLED); | 81 data_.state |= (1 << ui::AX_STATE_DISABLED); |
| 75 | 82 |
| 76 if (!view_->visible()) | 83 if (!view_->visible()) |
| 77 data_.state |= (1 << ui::AX_STATE_INVISIBLE); | 84 data_.state |= (1 << ui::AX_STATE_INVISIBLE); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 98 if (index < view_->child_count()) { | 105 if (index < view_->child_count()) { |
| 99 return view_->child_at(index)->GetNativeViewAccessible(); | 106 return view_->child_at(index)->GetNativeViewAccessible(); |
| 100 } else if (index < view_->child_count() + child_widget_count) { | 107 } else if (index < view_->child_count() + child_widget_count) { |
| 101 Widget* child_widget = child_widgets[index - view_->child_count()]; | 108 Widget* child_widget = child_widgets[index - view_->child_count()]; |
| 102 return child_widget->GetRootView()->GetNativeViewAccessible(); | 109 return child_widget->GetRootView()->GetNativeViewAccessible(); |
| 103 } | 110 } |
| 104 | 111 |
| 105 return nullptr; | 112 return nullptr; |
| 106 } | 113 } |
| 107 | 114 |
| 115 gfx::NativeWindow NativeViewAccessibility::GetTopLevelWidget() { |
| 116 if (view_->GetWidget()) |
| 117 return view_->GetWidget()->GetTopLevelWidget()->GetNativeWindow(); |
| 118 return nullptr; |
| 119 } |
| 120 |
| 108 gfx::NativeViewAccessible NativeViewAccessibility::GetParent() { | 121 gfx::NativeViewAccessible NativeViewAccessibility::GetParent() { |
| 109 if (view_->parent()) | 122 if (view_->parent()) |
| 110 return view_->parent()->GetNativeViewAccessible(); | 123 return view_->parent()->GetNativeViewAccessible(); |
| 111 | 124 |
| 112 // TODO: move this to NativeViewAccessibilityMac. | 125 // TODO: move this to NativeViewAccessibilityMac. |
| 113 #if defined(OS_MACOSX) | 126 #if defined(OS_MACOSX) |
| 114 if (view_->GetWidget()) | 127 if (view_->GetWidget()) |
| 115 return view_->GetWidget()->GetNativeView(); | 128 return view_->GetWidget()->GetNativeView(); |
| 116 #endif | 129 #endif |
| 117 | 130 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 child_widget_platform_node->GetDelegate()); | 258 child_widget_platform_node->GetDelegate()); |
| 246 if (child_widget_view_accessibility->parent_widget() != widget) | 259 if (child_widget_view_accessibility->parent_widget() != widget) |
| 247 child_widget_view_accessibility->SetParentWidget(widget); | 260 child_widget_view_accessibility->SetParentWidget(widget); |
| 248 } | 261 } |
| 249 | 262 |
| 250 result_child_widgets->push_back(child_widget); | 263 result_child_widgets->push_back(child_widget); |
| 251 } | 264 } |
| 252 } | 265 } |
| 253 | 266 |
| 254 } // namespace views | 267 } // namespace views |
| OLD | NEW |