aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Elly Fong-Jones <ellyjones@chromium.org>2019-02-19 13:52:08 -0500
committerGravatar Thomas Van Lenten <thomasvl@google.com>2019-02-19 14:09:16 -0500
commitaa1a3d2d447905999f119efbb70b3786c5eafa13 (patch)
tree965e3d0e846cc4fe627951e9bec7c98b8f3f7f56
parentac915f8a468cd8602108d24d0191d43fac93d604 (diff)
GTMLocalizer: use NSAccessibility on 10.10+ deployment targets
This change makes GTMLocalizer use NSAccessibility when building for 10.10+ deployment targets. I tested this change by: 1) Hacking the GTM Xcode project to build with a 10.10 deployment target, and ignoring the other deprecated API uses; 2) Patching this GTM into the chromium tree (which does target 10.10) and ensuring that it still builds
-rw-r--r--AppKit/GTMUILocalizer.m12
1 files changed, 12 insertions, 0 deletions
diff --git a/AppKit/GTMUILocalizer.m b/AppKit/GTMUILocalizer.m
index 07f11e4..80fc6b2 100644
--- a/AppKit/GTMUILocalizer.m
+++ b/AppKit/GTMUILocalizer.m
@@ -407,6 +407,17 @@
}
- (void)localizeAccessibility:(id)object {
+#if defined(MAC_OS_X_VERSION_10_10) && \
+ MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
+ id<NSAccessibility> accessible = object;
+ if ([accessible conformsToProtocol:@protocol(NSAccessibility)]) {
+ NSString* help = [accessible accessibilityHelp];
+ NSString* localizedHelp = [self localizedStringForString:help];
+ if (localizedHelp) {
+ [accessible setAccessibilityHelp:localizedHelp];
+ }
+ }
+#else
NSArray *supportedAttrs = [object accessibilityAttributeNames];
if ([supportedAttrs containsObject:NSAccessibilityHelpAttribute]) {
NSString *accessibilityHelp
@@ -420,6 +431,7 @@
}
}
}
+#endif
// We cannot do the same thing with NSAccessibilityDescriptionAttribute; see
// the links in the header file for more details.