Bug 1503424 - Null-check NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification before using it in order to fix a startup crash on 10.10. r=hiro, a=jcristau
authorMarkus Stange <mstange@themasta.com>
Wed, 07 Nov 2018 21:38:21 +0000
changeset 498425 dc2f3f105676
parent 498424 4d3a4ce7e9c6
child 498426 2da6ab9b72ac
push id10154
push userryanvm@gmail.com
push dateFri, 09 Nov 2018 16:38:03 +0000
treeherdermozilla-beta@d84c76f0dddd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro, jcristau
bugs1503424
milestone64.0
Bug 1503424 - Null-check NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification before using it in order to fix a startup crash on 10.10. r=hiro, a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D11239
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -3051,21 +3051,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;
@@ -3310,23 +3312,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)