Skip to content

Commit

Permalink
fix: restore accessibility window title on macOS (#21466)
Browse files Browse the repository at this point in the history
Electron's `AtomNSWindow` implements `accessibilityAttributeValue` to
provide various accessibility info to the OS, including window titles.

Chromium 75 changed to Apple's newer accessibility API for window titles
in the super class that `AtomNSWindow` inherits from. macOS still
supports both the old and new style APIs, but it will prefer the new
style if it is implemented.  This means the Electron window title is
being ignored because the newer API at the Chromium level has taken
precedence.

By implementing the newer accessibility API in `AtomNSWindow`, this
restores correct accessibility window titles in macOS Electron apps.

This is a regression has been present since Electron 6.0.0 (the first
release including the Chromium change above).
  • Loading branch information
trop[bot] authored and codebytere committed Dec 11, 2019
1 parent 89a7bdb commit d1d3d1b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions shell/browser/ui/cocoa/atom_ns_window.mm
Expand Up @@ -103,8 +103,6 @@ - (void)setFrame:(NSRect)windowFrame display:(BOOL)displayViews {
}

- (id)accessibilityAttributeValue:(NSString*)attribute {
if ([attribute isEqual:NSAccessibilityTitleAttribute])
return base::SysUTF8ToNSString(shell_->GetTitle());
if ([attribute isEqual:NSAccessibilityEnabledAttribute])
return [NSNumber numberWithBool:YES];
if (![attribute isEqualToString:@"AXChildren"])
Expand All @@ -125,6 +123,10 @@ - (id)accessibilityAttributeValue:(NSString*)attribute {
return [children filteredArrayUsingPredicate:predicate];
}

- (NSString*)accessibilityTitle {
return base::SysUTF8ToNSString(shell_->GetTitle());
}

- (BOOL)canBecomeMainWindow {
return !self.disableKeyOrMainWindow;
}
Expand Down

0 comments on commit d1d3d1b

Please sign in to comment.