]> khamidou — GitHub mirrors - electron.git/commitdiff
Enable accessibility tree only when VoiceOver enabled, fixes atom/atom#3288.
authorTheo Julienne <theojulienne@github.com>
Thu, 8 Oct 2015 22:56:26 +0000 (15:56 -0700)
committerTheo Julienne <theojulienne@github.com>
Thu, 8 Oct 2015 22:56:26 +0000 (15:56 -0700)
atom/browser/mac/atom_application.mm

index 9eaabc410bdaef7f18ab146e71bc7aed0288e5a5..cc9c6accc83dcb7260413fcc9a1184368724a3fa 100644 (file)
   atom::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"]) {
-    [self updateAccessibilityEnabled:[value boolValue]];
+    bool enableAccessibility = ([self voiceOverEnabled] && [value boolValue]);
+    [self updateAccessibilityEnabled:enableAccessibility];
   }
   return [super accessibilitySetValue:value forAttribute:attribute];
 }