Commit 95ffeb85 authored by Ian Prest's avatar Ian Prest Committed by Chromium LUCI CQ

A11y: Turn on a11y when VoiceControl is in use

Previously, to detect if VoiceOver was running on the Mac, we used an
undocumented attribute (AXEnhancedUserInterface) that was set on the
application.  Unfortunately, this doesn't work with the new VoiceControl
system.

After discussions with Apple, they recommended that we turn on a11y
whenever an AT accesses the 'accessibilityRole' property.  This would
work for VoiceControl, and should work with any new ATs in the future.
Since this attribute is called frequently, we use 'dispatch_once' to
ensure the expensive work is only done once.

One disadvantage is that we can no longer turn *off* a11y when the
'AXEnhancedUserInterface' attribute is set to zero, because doing so
breaks compatibility with VoiceControl.  (A11y would be enabled, then
quickly disabled again.)

Bug: 1143047
Change-Id: I41ed07b31476cef4a04fd0f2d9c994acc9311654
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2538257Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Ian Prest <iapres@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#833149}
parent 2b0de2d8
......@@ -4,6 +4,8 @@
#import "chrome/browser/chrome_browser_application_mac.h"
#include <dispatch/dispatch.h>
#include "base/check.h"
#include "base/command_line.h"
#include "base/mac/call_with_eh_frame.h"
......@@ -333,8 +335,6 @@ std::string DescriptionForNSEvent(NSEvent* event) {
content::BrowserAccessibilityState::GetInstance();
if ([value intValue] == 1)
accessibility_state->OnScreenReaderDetected();
else
accessibility_state->DisableAccessibility();
}
return [super accessibilitySetValue:value forAttribute:attribute];
}
......@@ -355,4 +355,19 @@ std::string DescriptionForNSEvent(NSEvent* event) {
_observers.RemoveObserver(observer);
}
- (NSAccessibilityRole)accessibilityRole {
// Our previous method of enabling a11y when the 'AXEnhancedUserInterface'
// attribute was set didn't work for the new VoiceControl system. After
// discussions with Apple, they recommended that we turn on a11y when an AT
// accesses the 'accessibilityRole' property. This works with VoiceControl,
// and should work with any other new ATs in the future.
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
content::BrowserAccessibilityState* accessibility_state =
content::BrowserAccessibilityState::GetInstance();
accessibility_state->OnScreenReaderDetected();
});
return [super accessibilityRole];
}
@end
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