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

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

Issue 2474363002: MacViews/a11y: Accessibility actions use AXActionData in AXPlatformNodeDelegate. (Closed)
Patch Set: Fix Linux. 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 View* focused_view = 177 View* focused_view =
178 focus_manager ? focus_manager->GetFocusedView() : nullptr; 178 focus_manager ? focus_manager->GetFocusedView() : nullptr;
179 return focused_view ? focused_view->GetNativeViewAccessible() : nullptr; 179 return focused_view ? focused_view->GetNativeViewAccessible() : nullptr;
180 } 180 }
181 181
182 gfx::AcceleratedWidget 182 gfx::AcceleratedWidget
183 NativeViewAccessibility::GetTargetForNativeAccessibilityEvent() { 183 NativeViewAccessibility::GetTargetForNativeAccessibilityEvent() {
184 return gfx::kNullAcceleratedWidget; 184 return gfx::kNullAcceleratedWidget;
185 } 185 }
186 186
187 void NativeViewAccessibility::AccessibilityPerformAction(
188 const ui::AXActionData& data) {
189 switch (data.action) {
190 // Handle accessible actions that apply to all Views here.
191 case ui::AX_ACTION_DO_DEFAULT:
192 DoDefaultAction();
193 break;
194 case ui::AX_ACTION_SET_FOCUS:
195 SetFocused(true);
196 break;
197 case ui::AX_ACTION_BLUR:
198 SetFocused(false);
199 break;
200
201 // Actions that only apply to specific Views should be dealt with by
202 // HandleAccessibleAction().
203 case ui::AX_ACTION_REPLACE_SELECTED_TEXT:
204 // Fallthrough.
tapted 2016/11/18 04:45:40 nit: we don't normally need Fallthrough when the c
Patti Lor 2016/11/21 01:52:35 Done.
205 case ui::AX_ACTION_SET_VALUE:
206 view_->HandleAccessibleAction(data);
tapted 2016/11/18 04:45:40 This returns a bool - I think we should communicat
Patti Lor 2016/11/21 01:52:35 Done.
207 break;
208
209 // Not yet implemented accessibility actions.
210 case ui::AX_ACTION_DECREMENT:
211 case ui::AX_ACTION_HIT_TEST:
212 case ui::AX_ACTION_INCREMENT:
213 case ui::AX_ACTION_SET_ACCESSIBILITY_FOCUS:
214 case ui::AX_ACTION_SET_SELECTION:
215 case ui::AX_ACTION_SHOW_CONTEXT_MENU:
216 NOTIMPLEMENTED();
217 break;
218
219 // Actions that are only used for the web or not used for Views.
220 case ui::AX_ACTION_SCROLL_TO_MAKE_VISIBLE:
221 case ui::AX_ACTION_SCROLL_TO_POINT:
222 case ui::AX_ACTION_SET_SCROLL_OFFSET:
tapted 2016/11/18 04:45:40 Would these apply to views::ScrollView?
Patti Lor 2016/11/21 01:52:35 Yeah, I think so! Moved to the category above.
223 case ui::AX_ACTION_SET_SEQUENTIAL_FOCUS_NAVIGATION_STARTING_POINT:
224 case ui::AX_ACTION_NONE:
225 NOTREACHED();
226 break;
227 }
228 }
229
187 void NativeViewAccessibility::DoDefaultAction() { 230 void NativeViewAccessibility::DoDefaultAction() {
188 gfx::Point center = view_->GetLocalBounds().CenterPoint(); 231 gfx::Point center = view_->GetLocalBounds().CenterPoint();
189 view_->OnMousePressed(ui::MouseEvent(ui::ET_MOUSE_PRESSED, 232 view_->OnMousePressed(ui::MouseEvent(ui::ET_MOUSE_PRESSED,
190 center, 233 center,
191 center, 234 center,
192 ui::EventTimeForNow(), 235 ui::EventTimeForNow(),
193 ui::EF_LEFT_MOUSE_BUTTON, 236 ui::EF_LEFT_MOUSE_BUTTON,
194 ui::EF_LEFT_MOUSE_BUTTON)); 237 ui::EF_LEFT_MOUSE_BUTTON));
195 view_->OnMouseReleased(ui::MouseEvent(ui::ET_MOUSE_RELEASED, 238 view_->OnMouseReleased(ui::MouseEvent(ui::ET_MOUSE_RELEASED,
196 center, 239 center,
197 center, 240 center,
198 ui::EventTimeForNow(), 241 ui::EventTimeForNow(),
199 ui::EF_LEFT_MOUSE_BUTTON, 242 ui::EF_LEFT_MOUSE_BUTTON,
200 ui::EF_LEFT_MOUSE_BUTTON)); 243 ui::EF_LEFT_MOUSE_BUTTON));
201 } 244 }
202 245
203 bool NativeViewAccessibility::SetStringValue(const base::string16& new_value,
204 bool clear_first) {
205 // Return an error if the view can't set the value.
206 if (!CanSetStringValue())
207 return false;
208
209 ui::AXActionData action_data;
210 action_data.value = new_value;
211 action_data.action = clear_first ? ui::AX_ACTION_SET_VALUE
212 : ui::AX_ACTION_REPLACE_SELECTED_TEXT;
213 return view_->HandleAccessibleAction(action_data);
214 }
215
216 bool NativeViewAccessibility::CanSetStringValue() {
217 return !ui::AXNodeData::IsFlagSet(GetData().state, ui::AX_STATE_READ_ONLY);
218 }
219
220 bool NativeViewAccessibility::SetFocused(bool focused) { 246 bool NativeViewAccessibility::SetFocused(bool focused) {
221 if (!ui::AXNodeData::IsFlagSet(GetData().state, ui::AX_STATE_FOCUSABLE)) 247 if (!ui::AXNodeData::IsFlagSet(GetData().state, ui::AX_STATE_FOCUSABLE))
222 return false; 248 return false;
223 249
224 if (focused) 250 if (focused)
225 view_->RequestFocus(); 251 view_->RequestFocus();
226 else if (view_->HasFocus()) 252 else if (view_->HasFocus())
227 view_->GetFocusManager()->ClearFocus(); 253 view_->GetFocusManager()->ClearFocus();
228 return true; 254 return true;
229 } 255 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 child_widget_platform_node->GetDelegate()); 297 child_widget_platform_node->GetDelegate());
272 if (child_widget_view_accessibility->parent_widget() != widget) 298 if (child_widget_view_accessibility->parent_widget() != widget)
273 child_widget_view_accessibility->SetParentWidget(widget); 299 child_widget_view_accessibility->SetParentWidget(widget);
274 } 300 }
275 301
276 result_child_widgets->push_back(child_widget); 302 result_child_widgets->push_back(child_widget);
277 } 303 }
278 } 304 }
279 305
280 } // namespace views 306 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698