Commit 30397ab8 authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

mac: make disabled elements visible to VoiceOver

Before this change, an element with the "disabled" restriction would
disallow every accessibility selector - crucially including selectors
like "isAccessibilityElement" or "accessibilityParent", which are
required for conforming accessibility elements. This caused disabled
elements to be completely skipped by VoiceOver, which hampers uses of
them as markers of functionality that exists but is disabled and
as menu headings.

Bug: 1067760
Change-Id: If64a02223930f3e5c404415798a56738a7faed88
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536088
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828226}
parent 87625133
...@@ -351,6 +351,12 @@ bool AlsoUseShowMenuActionForDefaultAction(const ui::AXNodeData& data) { ...@@ -351,6 +351,12 @@ bool AlsoUseShowMenuActionForDefaultAction(const ui::AXNodeData& data) {
data.role == ax::mojom::Role::kPopUpButton; data.role == ax::mojom::Role::kPopUpButton;
} }
// Check whether |selector| is an accessibility setter. This is a heuristic but
// seems to be a pretty good one.
bool IsAXSetter(SEL selector) {
return [NSStringFromSelector(selector) hasPrefix:@"setAccessibility"];
}
} // namespace } // namespace
@interface AXPlatformNodeCocoa (Private) @interface AXPlatformNodeCocoa (Private)
...@@ -995,33 +1001,26 @@ bool AlsoUseShowMenuActionForDefaultAction(const ui::AXNodeData& data) { ...@@ -995,33 +1001,26 @@ bool AlsoUseShowMenuActionForDefaultAction(const ui::AXNodeData& data) {
if (!_node) if (!_node)
return NO; return NO;
const ax::mojom::Restriction restriction = _node->GetData().GetRestriction(); if (selector == @selector(setAccessibilityFocused:))
if (restriction == ax::mojom::Restriction::kDisabled) return _node->GetData().HasState(ax::mojom::State::kFocusable);
return NO;
if (selector == @selector(setAccessibilityValue:)) { if (selector == @selector(setAccessibilityValue:) &&
_node->GetData().role == ax::mojom::Role::kTab) {
// Tabs use the radio button role on Mac, so they are selected by calling // Tabs use the radio button role on Mac, so they are selected by calling
// setSelected on an individual tab, rather than by setting the selected // setSelected on an individual tab, rather than by setting the selected
// element on the tabstrip as a whole. // element on the tabstrip as a whole.
if (_node->GetData().role == ax::mojom::Role::kTab) { return !_node->GetData().GetBoolAttribute(
return !_node->GetData().GetBoolAttribute( ax::mojom::BoolAttribute::kSelected);
ax::mojom::BoolAttribute::kSelected);
}
return restriction != ax::mojom::Restriction::kReadOnly;
} }
// Don't allow calling AX setters on disabled elements.
// TODO(https://crbug.com/692362): Once the underlying bug in // TODO(https://crbug.com/692362): Once the underlying bug in
// views::Textfield::SetSelectionRange() described in that bug is fixed, // views::Textfield::SetSelectionRange() described in that bug is fixed,
// remove the check here; right now, this check serves to prevent // remove the check here when the selector is setAccessibilitySelectedText*;
// accessibility clients from trying to set the selection range, which won't // right now, this check serves to prevent accessibility clients from trying
// work because of 692362. // to set the selection range, which won't work because of 692362.
if (selector == @selector(setAccessibilitySelectedText:) || if (_node->GetData().IsReadOnlyOrDisabled() && IsAXSetter(selector))
selector == @selector(setAccessibilitySelectedTextRange:)) { return NO;
return restriction != ax::mojom::Restriction::kReadOnly;
}
if (selector == @selector(setAccessibilityFocused:))
return _node->GetData().HasState(ax::mojom::State::kFocusable);
// TODO(https://crbug.com/386671): What about role-specific selectors? // TODO(https://crbug.com/386671): What about role-specific selectors?
return [super isAccessibilitySelectorAllowed:selector]; return [super isAccessibilitySelectorAllowed:selector];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment