Bug 1673503 - Simplify NSScroller.preferredScrollerStyle API usage. r=spohl
authorMarkus Stange <mstange.moz@gmail.com>
Tue, 27 Oct 2020 21:35:10 +0000
changeset 554820 385c6b10ed5c7a6e8d68b1637a8cf15058a5f238
parent 554819 56697cdf8cf3b9c8b3ccaff76c556228989bd69f
child 554821 095e60791055bf46cd722a87e79459e583933f06
push id129588
push usermstange@themasta.com
push dateTue, 27 Oct 2020 21:37:45 +0000
treeherderautoland@385c6b10ed5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl
bugs1673503
milestone84.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1673503 - Simplify NSScroller.preferredScrollerStyle API usage. r=spohl This API has been available since 10.7. Differential Revision: https://phabricator.services.mozilla.com/D94796
widget/cocoa/nsLookAndFeel.h
widget/cocoa/nsLookAndFeel.mm
--- a/widget/cocoa/nsLookAndFeel.h
+++ b/widget/cocoa/nsLookAndFeel.h
@@ -26,17 +26,16 @@ class nsLookAndFeel final : public nsXPL
   }
 
   static bool UseOverlayScrollbars();
 
   LookAndFeelCache GetCacheImpl() override;
   void SetCacheImpl(const LookAndFeelCache& aCache) override;
 
  protected:
-  static bool SystemWantsOverlayScrollbars();
   static bool AllowOverlayScrollbarsOverlap();
 
   static bool SystemWantsDarkTheme();
   static nscolor ProcessSelectionBackground(nscolor aColor);
 
  private:
   int32_t mUseOverlayScrollbars;
   bool mUseOverlayScrollbarsCached;
--- a/widget/cocoa/nsLookAndFeel.mm
+++ b/widget/cocoa/nsLookAndFeel.mm
@@ -17,23 +17,16 @@
 #include "mozilla/gfx/2D.h"
 #include "mozilla/widget/WidgetMessageUtils.h"
 
 #import <Cocoa/Cocoa.h>
 
 // This must be included last:
 #include "nsObjCExceptions.h"
 
-enum { mozNSScrollerStyleLegacy = 0, mozNSScrollerStyleOverlay = 1 };
-typedef NSInteger mozNSScrollerStyle;
-
-@interface NSScroller (AvailableSinceLion)
-+ (mozNSScrollerStyle)preferredScrollerStyle;
-@end
-
 // Available from 10.12 onwards; test availability at runtime before using
 @interface NSWorkspace (AvailableSinceSierra)
 @property(readonly) BOOL accessibilityDisplayShouldReduceMotion;
 @end
 
 nsLookAndFeel::nsLookAndFeel()
     : nsXPLookAndFeel(),
       mUseOverlayScrollbars(-1),
@@ -468,17 +461,17 @@ nsresult nsLookAndFeel::GetIntImpl(IntID
     case IntID::ScrollArrowStyle:
       aResult = eScrollArrow_None;
       break;
     case IntID::ScrollSliderStyle:
       aResult = eScrollThumbStyle_Proportional;
       break;
     case IntID::UseOverlayScrollbars:
       if (!mUseOverlayScrollbarsCached) {
-        mUseOverlayScrollbars = SystemWantsOverlayScrollbars() ? 1 : 0;
+        mUseOverlayScrollbars = NSScroller.preferredScrollerStyle == NSScrollerStyleOverlay ? 1 : 0;
         mUseOverlayScrollbarsCached = true;
       }
       aResult = mUseOverlayScrollbars;
       break;
     case IntID::AllowOverlayScrollbarsOverlap:
       if (!mAllowOverlayScrollbarsOverlapCached) {
         mAllowOverlayScrollbarsOverlap = AllowOverlayScrollbarsOverlap() ? 1 : 0;
         mAllowOverlayScrollbarsOverlapCached = true;
@@ -609,21 +602,16 @@ nsresult nsLookAndFeel::GetFloatImpl(Flo
       res = NS_ERROR_FAILURE;
   }
 
   return res;
 }
 
 bool nsLookAndFeel::UseOverlayScrollbars() { return GetInt(IntID::UseOverlayScrollbars) != 0; }
 
-bool nsLookAndFeel::SystemWantsOverlayScrollbars() {
-  return ([NSScroller respondsToSelector:@selector(preferredScrollerStyle)] &&
-          [NSScroller preferredScrollerStyle] == mozNSScrollerStyleOverlay);
-}
-
 bool nsLookAndFeel::AllowOverlayScrollbarsOverlap() { return (UseOverlayScrollbars()); }
 
 bool nsLookAndFeel::SystemWantsDarkTheme() {
   // This returns true if the macOS system appearance is set to dark mode on
   // 10.14+, false otherwise.
   if (!nsCocoaFeatures::OnMojaveOrLater()) {
     return false;
   }