Bug 1503424 - Null-check NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification before using it in order to fix a startup crash on 10.10. r=hiro, a=pascalc
authorMarkus Stange <mstange@themasta.com>
Wed, 07 Nov 2018 21:38:21 +0000
changeset 492990 5783aac8a1de4ea1b5667ea4df68b673f30ea9d3
parent 492989 62d17dbe09ab40325dc1fa8f35299ebfa4f05f4e
child 492991 527b9e310603f6bd71d00caa757a30f2769f6895
push id1852
push userryanvm@gmail.com
push dateTue, 13 Nov 2018 15:30:01 +0000
treeherdermozilla-release@527b9e310603 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro, pascalc
bugs1503424
milestone63.0.3
Bug 1503424 - Null-check NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification before using it in order to fix a startup crash on 10.10. r=hiro, a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D11239
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -3107,21 +3107,23 @@ nsChildView::SetPrefersReducedMotionOver
   lookAndFeelCache.AppendElement(prefersReducedMotion);
 
   // If we could have a way to modify
   // NSWorkspace.accessibilityDisplayShouldReduceMotion, we could use it, but
   // unfortunately there is no way, so we change the cache value instead as if
   // it's set in the parent process.
   LookAndFeel::SetIntCache(lookAndFeelCache);
 
-  if (nsCocoaFeatures::OnMojaveOrLater()) {
+  if (nsCocoaFeatures::OnMojaveOrLater() &&
+      NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification) {
     [[[NSWorkspace sharedWorkspace] notificationCenter]
          postNotificationName: NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification
          object:nil];
-  } else if (nsCocoaFeatures::OnYosemiteOrLater()) {
+  } else if (nsCocoaFeatures::OnYosemiteOrLater() &&
+      NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification) {
     [[NSNotificationCenter defaultCenter]
        postNotificationName: NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification
        object:nil];
   } else {
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
@@ -3367,23 +3369,25 @@ NSEvent* gLastDragMouseDownEvent = nil;
                                            selector:@selector(systemMetricsChanged)
                                                name:NSControlTintDidChangeNotification
                                              object:nil];
   [[NSNotificationCenter defaultCenter] addObserver:self
                                            selector:@selector(systemMetricsChanged)
                                                name:NSSystemColorsDidChangeNotification
                                              object:nil];
 
-  if (nsCocoaFeatures::OnMojaveOrLater()) {
+  if (nsCocoaFeatures::OnMojaveOrLater() &&
+      NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification) {
     [[[NSWorkspace sharedWorkspace] notificationCenter]
            addObserver:self
               selector:@selector(systemMetricsChanged)
                   name:NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification
                 object:nil];
-  } else if (nsCocoaFeatures::OnYosemiteOrLater()) {
+  } else if (nsCocoaFeatures::OnYosemiteOrLater() &&
+             NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification) {
     [[NSNotificationCenter defaultCenter] addObserver:self
                                              selector:@selector(systemMetricsChanged)
                                                  name:NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification
                                                object:nil];
   }
 
   [[NSNotificationCenter defaultCenter] addObserver:self
                                            selector:@selector(scrollbarSystemMetricChanged)