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

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: Fix test. 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 action_data.value = new_value; 210 action_data.value = new_value;
211 action_data.action = clear_first ? ui::AX_ACTION_SET_VALUE 211 action_data.action = clear_first ? ui::AX_ACTION_SET_VALUE
212 : ui::AX_ACTION_REPLACE_SELECTED_TEXT; 212 : ui::AX_ACTION_REPLACE_SELECTED_TEXT;
213 return view_->HandleAccessibleAction(action_data); 213 return view_->HandleAccessibleAction(action_data);
214 } 214 }
215 215
216 bool NativeViewAccessibility::CanSetStringValue() { 216 bool NativeViewAccessibility::CanSetStringValue() {
217 return !ui::AXNodeData::IsFlagSet(GetData().state, ui::AX_STATE_READ_ONLY); 217 return !ui::AXNodeData::IsFlagSet(GetData().state, ui::AX_STATE_READ_ONLY);
218 } 218 }
219 219
220 bool NativeViewAccessibility::SetFocused(bool focused) {
221 if (!ui::AXNodeData::IsFlagSet(GetData().state, ui::AX_STATE_FOCUSABLE))
222 return false;
223
224 if (focused)
225 view_->RequestFocus();
226 else if (view_->HasFocus())
227 view_->GetFocusManager()->ClearFocus();
228 return true;
229 }
230
220 void NativeViewAccessibility::OnWidgetDestroying(Widget* widget) { 231 void NativeViewAccessibility::OnWidgetDestroying(Widget* widget) {
221 if (parent_widget_ == widget) { 232 if (parent_widget_ == widget) {
222 parent_widget_->RemoveObserver(this); 233 parent_widget_->RemoveObserver(this);
223 parent_widget_ = nullptr; 234 parent_widget_ = nullptr;
224 } 235 }
225 } 236 }
226 237
227 void NativeViewAccessibility::SetParentWidget(Widget* parent_widget) { 238 void NativeViewAccessibility::SetParentWidget(Widget* parent_widget) {
228 if (parent_widget_) 239 if (parent_widget_)
229 parent_widget_->RemoveObserver(this); 240 parent_widget_->RemoveObserver(this);
(...skipping 30 matching lines...) Expand all
260 child_widget_platform_node->GetDelegate()); 271 child_widget_platform_node->GetDelegate());
261 if (child_widget_view_accessibility->parent_widget() != widget) 272 if (child_widget_view_accessibility->parent_widget() != widget)
262 child_widget_view_accessibility->SetParentWidget(widget); 273 child_widget_view_accessibility->SetParentWidget(widget);
263 } 274 }
264 275
265 result_child_widgets->push_back(child_widget); 276 result_child_widgets->push_back(child_widget);
266 } 277 }
267 } 278 }
268 279
269 } // namespace views 280 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/accessibility/native_view_accessibility.h ('k') | ui/views/accessibility/native_view_accessibility_auralinux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698