Browse Source

fix: enable basic a11y when voice control is active (#37144)

* fix: enable basic a11y when voice control is active

c.f. https://chromium-review.googlesource.com/c/chromium/src/+/2680102

Co-authored-by: Samuel Attard <[email protected]>

* Update shell/browser/mac/electron_application.mm

Co-authored-by: Robo <[email protected]>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Samuel Attard <[email protected]>
Co-authored-by: Shelley Vohr <[email protected]>
Co-authored-by: Robo <[email protected]>
trop[bot] 2 years ago
parent
commit
40cbdd340d
1 changed files with 12 additions and 0 deletions
  1. 12 0
      shell/browser/mac/electron_application.mm

+ 12 - 0
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.mode())) {
+    ax_state->AddAccessibilityModeFlags(ui::kAXModeBasic);
+  }
+  return [super accessibilityRole];
+}
+
 - (void)orderFrontStandardAboutPanel:(id)sender {
   electron::Browser::Get()->ShowAboutPanel();
 }