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

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: Use CreateParams and MakeUnique. 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_->IsFocusable())
tapted 2016/11/11 00:36:25 would IsAccessibilityFocusable be more appropriate
Patti Lor 2016/11/14 03:51:21 Oh, I hadn't thought about that, thanks for pointi
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(const bool focused) {
222 if (!ui::AXNodeData::IsFlagSet(GetData().state, ui::AX_STATE_FOCUSABLE))
223 return false;
224
225 if (focused == view_->HasFocus())
226 return true;
227 if (focused)
228 view_->RequestFocus();
229 else
tapted 2016/11/11 00:36:25 optional: I'd maybe make this `else if view->HasFo
Patti Lor 2016/11/14 03:51:21 Done, thanks!
230 view_->GetFocusManager()->ClearFocus();
231 return true;
232 }
233
220 void NativeViewAccessibility::OnWidgetDestroying(Widget* widget) { 234 void NativeViewAccessibility::OnWidgetDestroying(Widget* widget) {
221 if (parent_widget_ == widget) { 235 if (parent_widget_ == widget) {
222 parent_widget_->RemoveObserver(this); 236 parent_widget_->RemoveObserver(this);
223 parent_widget_ = nullptr; 237 parent_widget_ = nullptr;
224 } 238 }
225 } 239 }
226 240
227 void NativeViewAccessibility::SetParentWidget(Widget* parent_widget) { 241 void NativeViewAccessibility::SetParentWidget(Widget* parent_widget) {
228 if (parent_widget_) 242 if (parent_widget_)
229 parent_widget_->RemoveObserver(this); 243 parent_widget_->RemoveObserver(this);
(...skipping 30 matching lines...) Expand all
260 child_widget_platform_node->GetDelegate()); 274 child_widget_platform_node->GetDelegate());
261 if (child_widget_view_accessibility->parent_widget() != widget) 275 if (child_widget_view_accessibility->parent_widget() != widget)
262 child_widget_view_accessibility->SetParentWidget(widget); 276 child_widget_view_accessibility->SetParentWidget(widget);
263 } 277 }
264 278
265 result_child_widgets->push_back(child_widget); 279 result_child_widgets->push_back(child_widget);
266 } 280 }
267 } 281 }
268 282
269 } // namespace views 283 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698