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

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

Issue 2141013004: Mac a11y: Add Help, TopLevelUIElement, and Window accessibility attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test views without tooltips set. Created 4 years, 5 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
OLDNEW
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
58 data_.state = state.state(); 59 data_.state = state.state();
59 data_.location = view_->GetBoundsInScreen(); 60 data_.location = 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 (view_->GetTooltipText(gfx::Point(), &state.help_text))
tapted 2016/07/18 03:38:48 passing gfx::Point() might not work for the bookma
Patti Lor 2016/07/19 01:14:10 Have double checked this and you are right - both
tapted 2016/07/19 03:22:50 Acknowledged. Yeah I only had a skim of the bookma
Patti Lor 2016/07/19 05:29:24 I checked this using the XCode Accessibility Inspe
71 data_.AddStringAttribute(ui::AX_ATTR_HELP_TEXT,
72 base::UTF16ToUTF8(state.help_text));
73
68 data_.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, state.selection_start); 74 data_.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, state.selection_start);
69 data_.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, state.selection_end); 75 data_.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, state.selection_end);
70 76
71 data_.state |= (1 << ui::AX_STATE_FOCUSABLE); 77 data_.state |= (1 << ui::AX_STATE_FOCUSABLE);
72 78
73 if (!view_->enabled()) 79 if (!view_->enabled())
74 data_.state |= (1 << ui::AX_STATE_DISABLED); 80 data_.state |= (1 << ui::AX_STATE_DISABLED);
75 81
76 if (!view_->visible()) 82 if (!view_->visible())
77 data_.state |= (1 << ui::AX_STATE_INVISIBLE); 83 data_.state |= (1 << ui::AX_STATE_INVISIBLE);
(...skipping 20 matching lines...) Expand all
98 if (index < view_->child_count()) { 104 if (index < view_->child_count()) {
99 return view_->child_at(index)->GetNativeViewAccessible(); 105 return view_->child_at(index)->GetNativeViewAccessible();
100 } else if (index < view_->child_count() + child_widget_count) { 106 } else if (index < view_->child_count() + child_widget_count) {
101 Widget* child_widget = child_widgets[index - view_->child_count()]; 107 Widget* child_widget = child_widgets[index - view_->child_count()];
102 return child_widget->GetRootView()->GetNativeViewAccessible(); 108 return child_widget->GetRootView()->GetNativeViewAccessible();
103 } 109 }
104 110
105 return nullptr; 111 return nullptr;
106 } 112 }
107 113
114 gfx::NativeWindow NativeViewAccessibility::GetTopLevelWidget() {
115 return view_->GetWidget()->GetTopLevelWidget()->GetNativeWindow();
tapted 2016/07/19 03:22:50 oops - I thought I'd written a comment here but I
Patti Lor 2016/07/19 05:29:24 Done, thank you.
116 }
117
108 gfx::NativeViewAccessible NativeViewAccessibility::GetParent() { 118 gfx::NativeViewAccessible NativeViewAccessibility::GetParent() {
109 if (view_->parent()) 119 if (view_->parent())
110 return view_->parent()->GetNativeViewAccessible(); 120 return view_->parent()->GetNativeViewAccessible();
111 121
112 // TODO: move this to NativeViewAccessibilityMac. 122 // TODO: move this to NativeViewAccessibilityMac.
tapted 2016/07/18 03:38:48 do we need to do something with this? (or is there
Patti Lor 2016/07/19 01:14:10 NativeViewAccessibilityMac doesn't exist yet, so I
tapted 2016/07/19 03:22:50 Acknowledged.
113 #if defined(OS_MACOSX) 123 #if defined(OS_MACOSX)
114 if (view_->GetWidget()) 124 if (view_->GetWidget())
115 return view_->GetWidget()->GetNativeView(); 125 return view_->GetWidget()->GetNativeView();
116 #endif 126 #endif
117 127
118 if (parent_widget_) 128 if (parent_widget_)
119 return parent_widget_->GetRootView()->GetNativeViewAccessible(); 129 return parent_widget_->GetRootView()->GetNativeViewAccessible();
120 130
121 return nullptr; 131 return nullptr;
122 } 132 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 child_widget_platform_node->GetDelegate()); 255 child_widget_platform_node->GetDelegate());
246 if (child_widget_view_accessibility->parent_widget() != widget) 256 if (child_widget_view_accessibility->parent_widget() != widget)
247 child_widget_view_accessibility->SetParentWidget(widget); 257 child_widget_view_accessibility->SetParentWidget(widget);
248 } 258 }
249 259
250 result_child_widgets->push_back(child_widget); 260 result_child_widgets->push_back(child_widget);
251 } 261 }
252 } 262 }
253 263
254 } // namespace views 264 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698