From 7dcd97f8644d2c7357009a3428901b838130ddcf Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 6 Feb 2023 03:32:21 -0800 Subject: [PATCH] fix: enable basic a11y when voice control is active (#37122) c.f. https://chromium-review.googlesource.com/c/chromium/src/+/2680102 --- shell/browser/mac/electron_application.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/shell/browser/mac/electron_application.mm b/shell/browser/mac/electron_application.mm index d6ff91475e75..24c14b9628db 100644 --- a/shell/browser/mac/electron_application.mm +++ b/shell/browser/mac/electron_application.mm @@ -193,6 +193,18 @@ inline void dispatch_sync_main(dispatch_block_t block) { return [super accessibilitySetValue:value forAttribute:attribute]; } +- (NSAccessibilityRole)accessibilityRole { + // For non-VoiceOver AT, such as Voice Control, Apple recommends turning on + // a11y when an AT accesses the 'accessibilityRole' property. This function + // is accessed frequently so we only change the accessibility state when + // accessibility is disabled. + auto* ax_state = content::BrowserAccessibilityState::GetInstance(); + if (!ax_state->GetAccessibilityMode().has_mode(ui::kAXModeBasic.flags())) { + ax_state->AddAccessibilityModeFlags(ui::kAXModeBasic); + } + return [super accessibilityRole]; +} + - (void)orderFrontStandardAboutPanel:(id)sender { electron::Browser::Get()->ShowAboutPanel(); }