From 794940272b7b6ab04ac7f4bc1782c8ce534cc54c Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 28 Oct 2020 20:24:37 -0700 Subject: [PATCH] fix: hover text only working when VO enabled (#26183) --- shell/browser/mac/electron_application.mm | 40 ++++++++--------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/shell/browser/mac/electron_application.mm b/shell/browser/mac/electron_application.mm index ac732190fdb8..e3c65c9eeeac 100644 --- a/shell/browser/mac/electron_application.mm +++ b/shell/browser/mac/electron_application.mm @@ -177,38 +177,24 @@ inline void dispatch_sync_main(dispatch_block_t block) { electron::Browser::Get()->OpenURL(base::SysNSStringToUTF8(url)); } -- (bool)voiceOverEnabled { - NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; - [defaults addSuiteNamed:@"com.apple.universalaccess"]; - [defaults synchronize]; - - return [defaults boolForKey:@"voiceOverOnOffKey"]; -} - - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute { - // Undocumented attribute that VoiceOver happens to set while running. - // Chromium uses this too, even though it's not exactly right. - if ([attribute isEqualToString:@"AXEnhancedUserInterface"]) { - bool enableAccessibility = ([self voiceOverEnabled] && [value boolValue]); - [self updateAccessibilityEnabled:enableAccessibility]; - } else if ([attribute isEqualToString:@"AXManualAccessibility"]) { - [self updateAccessibilityEnabled:[value boolValue]]; + // Undocumented attribute that screen reader related functionality + // sets when running. + if ([attribute isEqualToString:@"AXEnhancedUserInterface"] || + [attribute isEqualToString:@"AXManualAccessibility"]) { + auto* ax_state = content::BrowserAccessibilityState::GetInstance(); + if ([value boolValue]) { + ax_state->OnScreenReaderDetected(); + } else { + ax_state->DisableAccessibility(); + } + + electron::Browser::Get()->OnAccessibilitySupportChanged(); } + return [super accessibilitySetValue:value forAttribute:attribute]; } -- (void)updateAccessibilityEnabled:(BOOL)enabled { - auto* ax_state = content::BrowserAccessibilityState::GetInstance(); - - if (enabled) { - ax_state->OnScreenReaderDetected(); - } else { - ax_state->DisableAccessibility(); - } - - electron::Browser::Get()->OnAccessibilitySupportChanged(); -} - - (void)orderFrontStandardAboutPanel:(id)sender { electron::Browser::Get()->ShowAboutPanel(); }