From 06da4d2c662c3b9e4f5c874a8d63cf2359fb2d59 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 26 Oct 2020 22:17:55 -0700 Subject: [PATCH 1/2] fix: hover text only working when VO enabled --- shell/browser/mac/electron_application.mm | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/shell/browser/mac/electron_application.mm b/shell/browser/mac/electron_application.mm index ac732190fdb80..f4f224f797eb5 100644 --- a/shell/browser/mac/electron_application.mm +++ b/shell/browser/mac/electron_application.mm @@ -177,20 +177,11 @@ - (void)handleURLEvent:(NSAppleEventDescriptor*)event 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]; + [self updateAccessibilityEnabled:[value boolValue]]; } else if ([attribute isEqualToString:@"AXManualAccessibility"]) { [self updateAccessibilityEnabled:[value boolValue]]; } From 6386bf943e4a2d17b49abf461fda9154359039ca Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 27 Oct 2020 14:22:13 -0700 Subject: [PATCH 2/2] chore: simplify conditional --- shell/browser/mac/electron_application.mm | 29 ++++++++++------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/shell/browser/mac/electron_application.mm b/shell/browser/mac/electron_application.mm index f4f224f797eb5..e3c65c9eeeacb 100644 --- a/shell/browser/mac/electron_application.mm +++ b/shell/browser/mac/electron_application.mm @@ -178,26 +178,21 @@ - (void)handleURLEvent:(NSAppleEventDescriptor*)event } - (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"]) { - [self updateAccessibilityEnabled:[value boolValue]]; - } else if ([attribute isEqualToString:@"AXManualAccessibility"]) { - [self updateAccessibilityEnabled:[value boolValue]]; - } - return [super accessibilitySetValue:value forAttribute:attribute]; -} - -- (void)updateAccessibilityEnabled:(BOOL)enabled { - auto* ax_state = content::BrowserAccessibilityState::GetInstance(); + // 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(); + } - if (enabled) { - ax_state->OnScreenReaderDetected(); - } else { - ax_state->DisableAccessibility(); + electron::Browser::Get()->OnAccessibilitySupportChanged(); } - electron::Browser::Get()->OnAccessibilitySupportChanged(); + return [super accessibilitySetValue:value forAttribute:attribute]; } - (void)orderFrontStandardAboutPanel:(id)sender {