From 4430736cbc77ba7d79719a0bfbb0cd4b237661a8 Mon Sep 17 00:00:00 2001 From: faultyserver Date: Wed, 8 Apr 2020 14:23:06 -0700 Subject: [PATCH] Port of https://github.com/electron/electron/pull/22399 to address blank VoiceOver content --- shell/browser/ui/cocoa/atom_ns_window.mm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/shell/browser/ui/cocoa/atom_ns_window.mm b/shell/browser/ui/cocoa/atom_ns_window.mm index 95eba2a35cdba..e9444391031eb 100644 --- a/shell/browser/ui/cocoa/atom_ns_window.mm +++ b/shell/browser/ui/cocoa/atom_ns_window.mm @@ -120,7 +120,18 @@ - (id)accessibilityAttributeValue:(NSString*)attribute { [NSButtonCell class], @"RenderWidgetHostViewCocoa"]; NSArray* children = [super accessibilityAttributeValue:attribute]; - return [children filteredArrayUsingPredicate:predicate]; + 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; } - (NSString*)accessibilityTitle {