Chromium Code Reviews| Index: ui/views/accessibility/native_view_accessibility.cc |
| diff --git a/ui/views/accessibility/native_view_accessibility.cc b/ui/views/accessibility/native_view_accessibility.cc |
| index 04a0fa5afb95126235feb7432fb72ff02c50bf93..4b51ef0a2ca644d4b1b6b1cfbe4f9873185aeb99 100644 |
| --- a/ui/views/accessibility/native_view_accessibility.cc |
| +++ b/ui/views/accessibility/native_view_accessibility.cc |
| @@ -5,9 +5,6 @@ |
| #include "ui/views/accessibility/native_view_accessibility.h" |
| #include "base/strings/utf_string_conversions.h" |
| -#include "build/build_config.h" |
| -#include "ui/accessibility/ax_action_data.h" |
| -#include "ui/accessibility/ax_node_data.h" |
| #include "ui/events/event_utils.h" |
| #include "ui/gfx/native_widget_types.h" |
| #include "ui/views/controls/native/native_view_host.h" |
| @@ -50,6 +47,17 @@ void NativeViewAccessibility::NotifyAccessibilityEvent(ui::AXEvent event_type) { |
| ax_node_->NotifyAccessibilityEvent(event_type); |
| } |
| +bool NativeViewAccessibility::SetFocused(bool focused) { |
| + if (!ui::AXNodeData::IsFlagSet(GetData().state, ui::AX_STATE_FOCUSABLE)) |
| + return false; |
| + |
| + if (focused) |
| + view_->RequestFocus(); |
| + else if (view_->HasFocus()) |
| + view_->GetFocusManager()->ClearFocus(); |
| + return true; |
| +} |
| + |
| // ui::AXPlatformNodeDelegate |
| const ui::AXNodeData& NativeViewAccessibility::GetData() { |
| @@ -184,6 +192,47 @@ NativeViewAccessibility::GetTargetForNativeAccessibilityEvent() { |
| return gfx::kNullAcceleratedWidget; |
| } |
| +bool NativeViewAccessibility::AccessibilityPerformAction( |
| + const ui::AXActionData& data) { |
| + switch (data.action) { |
| + // Handle accessible actions that apply to all Views here. |
| + case ui::AX_ACTION_DO_DEFAULT: |
| + DoDefaultAction(); |
| + return true; |
| + case ui::AX_ACTION_SET_FOCUS: |
| + return SetFocused(true); |
| + case ui::AX_ACTION_BLUR: |
| + return SetFocused(false); |
| + |
| + // Actions that only apply to specific Views should be dealt with by |
| + // HandleAccessibleAction(). |
| + case ui::AX_ACTION_REPLACE_SELECTED_TEXT: |
| + case ui::AX_ACTION_SET_VALUE: |
| + return view_->HandleAccessibleAction(data); |
| + break; |
| + |
| + // Not yet implemented accessibility actions. |
| + case ui::AX_ACTION_DECREMENT: |
| + case ui::AX_ACTION_HIT_TEST: |
| + case ui::AX_ACTION_INCREMENT: |
| + case ui::AX_ACTION_SCROLL_TO_MAKE_VISIBLE: |
| + case ui::AX_ACTION_SCROLL_TO_POINT: |
| + case ui::AX_ACTION_SET_ACCESSIBILITY_FOCUS: |
| + case ui::AX_ACTION_SET_SCROLL_OFFSET: |
| + case ui::AX_ACTION_SET_SELECTION: |
| + case ui::AX_ACTION_SHOW_CONTEXT_MENU: |
| + NOTIMPLEMENTED(); |
|
dmazzoni
2016/11/21 04:53:38
It might be better to just call view_->HandleAcces
Patti Lor
2016/11/21 23:24:39
Done.
|
| + break; |
| + |
| + // Actions that are only used for the web or not used for Views. |
| + case ui::AX_ACTION_SET_SEQUENTIAL_FOCUS_NAVIGATION_STARTING_POINT: |
| + case ui::AX_ACTION_NONE: |
|
dmazzoni
2016/11/21 04:53:38
nit: the comment above implies AX_ACTION_NONE is u
Patti Lor
2016/11/21 23:24:39
Deleted!
|
| + NOTREACHED(); |
| + break; |
| + } |
| + return false; |
| +} |
| + |
| void NativeViewAccessibility::DoDefaultAction() { |
| gfx::Point center = view_->GetLocalBounds().CenterPoint(); |
| view_->OnMousePressed(ui::MouseEvent(ui::ET_MOUSE_PRESSED, |
| @@ -200,34 +249,6 @@ void NativeViewAccessibility::DoDefaultAction() { |
| ui::EF_LEFT_MOUSE_BUTTON)); |
| } |
| -bool NativeViewAccessibility::SetStringValue(const base::string16& new_value, |
| - bool clear_first) { |
| - // Return an error if the view can't set the value. |
| - if (!CanSetStringValue()) |
| - return false; |
| - |
| - ui::AXActionData action_data; |
| - action_data.value = new_value; |
| - action_data.action = clear_first ? ui::AX_ACTION_SET_VALUE |
| - : ui::AX_ACTION_REPLACE_SELECTED_TEXT; |
| - return view_->HandleAccessibleAction(action_data); |
| -} |
| - |
| -bool NativeViewAccessibility::CanSetStringValue() { |
| - return !ui::AXNodeData::IsFlagSet(GetData().state, ui::AX_STATE_READ_ONLY); |
| -} |
| - |
| -bool NativeViewAccessibility::SetFocused(bool focused) { |
| - if (!ui::AXNodeData::IsFlagSet(GetData().state, ui::AX_STATE_FOCUSABLE)) |
| - return false; |
| - |
| - if (focused) |
| - view_->RequestFocus(); |
| - else if (view_->HasFocus()) |
| - view_->GetFocusManager()->ClearFocus(); |
| - return true; |
| -} |
| - |
| void NativeViewAccessibility::OnWidgetDestroying(Widget* widget) { |
| if (parent_widget_ == widget) { |
| parent_widget_->RemoveObserver(this); |