Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow VoiceOver to navigate "back into" web contents #24699

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 5 additions & 13 deletions shell/browser/ui/cocoa/electron_ns_window.mm
Expand Up @@ -121,29 +121,21 @@ - (id)accessibilityAttributeValue:(NSString*)attribute {
if (![attribute isEqualToString:@"AXChildren"])
return [super accessibilityAttributeValue:attribute];

// Filter out objects that aren't the title bar buttons. This has the effect
// of removing the window title, which VoiceOver already sees.
// We want to remove the window title (also known as
// NSAccessibilityReparentingCellProxy), which VoiceOver already sees.
// * when VoiceOver is disabled, this causes Cmd+C to be used for TTS but
// still leaves the buttons available in the accessibility tree.
// * when VoiceOver is enabled, the full accessibility tree is used.
// Without removing the title and with VO disabled, the TTS would always read
// the window title instead of using Cmd+C to get the selected text.
NSPredicate* predicate = [NSPredicate
predicateWithFormat:@"(self isKindOfClass: %@) OR (self.className == %@)",
[NSButtonCell class], @"RenderWidgetHostViewCocoa"];
NSPredicate* predicate =
[NSPredicate predicateWithFormat:@"(self.className != %@)",
@"NSAccessibilityReparentingCellProxy"];

NSArray* children = [super accessibilityAttributeValue:attribute];
NSMutableArray* mutableChildren = [[children mutableCopy] autorelease];
[mutableChildren filterUsingPredicate:predicate];

// We need to add the web contents: Without us doing so, VoiceOver
// users will be able to navigate up the a11y tree, but not back down.
// The content view contains the "web contents", which VoiceOver
// immediately understands.
NSView* contentView =
[shell_->GetNativeWindow().GetNativeNSWindow() contentView];
[mutableChildren addObject:contentView];

return mutableChildren;
}

Expand Down