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

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

Issue 2490073002: MacViews/a11y: Allow accessibility clients to focus and unfocus focusable Views. (Closed)
Patch Set: Show the widget before test start. Created 4 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 (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_action_data.h" 9 #include "ui/accessibility/ax_action_data.h"
10 #include "ui/accessibility/ax_node_data.h" 10 #include "ui/accessibility/ax_node_data.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 return data_; 64 return data_;
65 } 65 }
66 66
67 view_->GetAccessibleNodeData(&data_); 67 view_->GetAccessibleNodeData(&data_);
68 data_.location = gfx::RectF(view_->GetBoundsInScreen()); 68 data_.location = gfx::RectF(view_->GetBoundsInScreen());
69 base::string16 description; 69 base::string16 description;
70 view_->GetTooltipText(gfx::Point(), &description); 70 view_->GetTooltipText(gfx::Point(), &description);
71 data_.AddStringAttribute(ui::AX_ATTR_DESCRIPTION, 71 data_.AddStringAttribute(ui::AX_ATTR_DESCRIPTION,
72 base::UTF16ToUTF8(description)); 72 base::UTF16ToUTF8(description));
73 73
74 data_.state |= (1 << ui::AX_STATE_FOCUSABLE); 74 if (view_->IsAccessibilityFocusable())
dmazzoni 2016/11/14 23:13:37 This is probably a good change, but just a warning
Patti Lor 2016/11/15 04:13:35 That sounds OK to me - either way it will be an im
75 data_.state |= (1 << ui::AX_STATE_FOCUSABLE);
75 76
76 if (!view_->enabled()) 77 if (!view_->enabled())
77 data_.state |= (1 << ui::AX_STATE_DISABLED); 78 data_.state |= (1 << ui::AX_STATE_DISABLED);
78 79
79 if (!view_->visible()) 80 if (!view_->visible())
80 data_.state |= (1 << ui::AX_STATE_INVISIBLE); 81 data_.state |= (1 << ui::AX_STATE_INVISIBLE);
81 82
82 return data_; 83 return data_;
83 } 84 }
84 85
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 action_data.value = new_value; 211 action_data.value = new_value;
211 action_data.action = clear_first ? ui::AX_ACTION_SET_VALUE 212 action_data.action = clear_first ? ui::AX_ACTION_SET_VALUE
212 : ui::AX_ACTION_REPLACE_SELECTED_TEXT; 213 : ui::AX_ACTION_REPLACE_SELECTED_TEXT;
213 return view_->HandleAccessibleAction(action_data); 214 return view_->HandleAccessibleAction(action_data);
214 } 215 }
215 216
216 bool NativeViewAccessibility::CanSetStringValue() { 217 bool NativeViewAccessibility::CanSetStringValue() {
217 return !ui::AXNodeData::IsFlagSet(GetData().state, ui::AX_STATE_READ_ONLY); 218 return !ui::AXNodeData::IsFlagSet(GetData().state, ui::AX_STATE_READ_ONLY);
218 } 219 }
219 220
221 bool NativeViewAccessibility::SetFocused(bool focused) {
222 if (!ui::AXNodeData::IsFlagSet(GetData().state, ui::AX_STATE_FOCUSABLE))
223 return false;
224
225 if (focused)
226 view_->RequestFocus();
227 else if (view_->HasFocus())
228 view_->GetFocusManager()->ClearFocus();
229 return true;
230 }
231
220 void NativeViewAccessibility::OnWidgetDestroying(Widget* widget) { 232 void NativeViewAccessibility::OnWidgetDestroying(Widget* widget) {
221 if (parent_widget_ == widget) { 233 if (parent_widget_ == widget) {
222 parent_widget_->RemoveObserver(this); 234 parent_widget_->RemoveObserver(this);
223 parent_widget_ = nullptr; 235 parent_widget_ = nullptr;
224 } 236 }
225 } 237 }
226 238
227 void NativeViewAccessibility::SetParentWidget(Widget* parent_widget) { 239 void NativeViewAccessibility::SetParentWidget(Widget* parent_widget) {
228 if (parent_widget_) 240 if (parent_widget_)
229 parent_widget_->RemoveObserver(this); 241 parent_widget_->RemoveObserver(this);
(...skipping 30 matching lines...) Expand all
260 child_widget_platform_node->GetDelegate()); 272 child_widget_platform_node->GetDelegate());
261 if (child_widget_view_accessibility->parent_widget() != widget) 273 if (child_widget_view_accessibility->parent_widget() != widget)
262 child_widget_view_accessibility->SetParentWidget(widget); 274 child_widget_view_accessibility->SetParentWidget(widget);
263 } 275 }
264 276
265 result_child_widgets->push_back(child_widget); 277 result_child_widgets->push_back(child_widget);
266 } 278 }
267 } 279 }
268 280
269 } // namespace views 281 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698