Skip to content

Commit

Permalink
fix: hover text only working when VO enabled (#26246)
Browse files Browse the repository at this point in the history
* fix: hover text only working when VO enabled

* chore: simplify conditional

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
  • Loading branch information
trop[bot] and codebytere committed Oct 29, 2020
1 parent dd3fbae commit 7ec0014
Showing 1 changed file with 12 additions and 26 deletions.
38 changes: 12 additions & 26 deletions shell/browser/mac/electron_application.mm
Expand Up @@ -177,36 +177,22 @@ - (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];
} 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 {
Expand Down

0 comments on commit 7ec0014

Please sign in to comment.