From b57f5086efb9be04740686f4d5b4f11bdcdb4e86 Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Wed, 22 Jul 2020 15:29:01 -0700 Subject: [PATCH] fix: Allow VoiceOver to navigate "back into" web contents (#24655) * fix: Use ElectronAdaptedContentView * fix: Actually, nevermind, it's "BrowserAccessebilityCocoa" * chore: Remove things instead of manually keeping them --- shell/browser/ui/cocoa/electron_ns_window.mm | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/shell/browser/ui/cocoa/electron_ns_window.mm b/shell/browser/ui/cocoa/electron_ns_window.mm index 05c9af04fe6b..8da315c8f6bd 100644 --- a/shell/browser/ui/cocoa/electron_ns_window.mm +++ b/shell/browser/ui/cocoa/electron_ns_window.mm @@ -121,29 +121,21 @@ bool ScopedDisableResize::disable_resize_ = false; 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; }