Index: Source/platform/scroll/ScrollbarThemeMacCommon.mm |
diff --git a/Source/platform/scroll/ScrollbarThemeMacCommon.mm b/Source/platform/scroll/ScrollbarThemeMacCommon.mm |
index f111c063ad33d45ecdc08e1b22bc0983c4dfb929..402d99aa23091b5f68ae005b92ace64a5717dd2d 100644 |
--- a/Source/platform/scroll/ScrollbarThemeMacCommon.mm |
+++ b/Source/platform/scroll/ScrollbarThemeMacCommon.mm |
@@ -24,6 +24,7 @@ |
*/ |
#include "config.h" |
+#include "RuntimeEnabledFeatures.h" |
#include "platform/scroll/ScrollbarThemeMacCommon.h" |
#include <Carbon/Carbon.h> |
@@ -74,13 +75,14 @@ namespace WebCore { |
static float gInitialButtonDelay = 0.5f; |
static float gAutoscrollButtonDelay = 0.05f; |
static bool gJumpOnTrackClick = false; |
+static NSScrollerStyle gPreferredScrollerStyle = NSScrollerStyleLegacy; |
ScrollbarTheme* ScrollbarTheme::nativeTheme() |
{ |
static ScrollbarThemeMacCommon* theme = NULL; |
if (theme) |
return theme; |
- if (isScrollbarOverlayAPIAvailable()) { |
+ if (ScrollbarThemeMacCommon::isOverlayAPIAvailable()) { |
DEFINE_STATIC_LOCAL(ScrollbarThemeMacOverlayAPI, overlayTheme, ()); |
theme = &overlayTheme; |
} else { |
@@ -291,12 +293,14 @@ ScrollbarThemeMacCommon::~ScrollbarThemeMacCommon() |
{ |
} |
-void ScrollbarThemeMacCommon::preferencesChanged(float initialButtonDelay, float autoscrollButtonDelay, bool jumpOnTrackClick, bool redraw) |
+void ScrollbarThemeMacCommon::preferencesChanged(float initialButtonDelay, float autoscrollButtonDelay, bool jumpOnTrackClick, NSScrollerStyle preferredScrollerStyle, bool redraw) |
{ |
updateButtonPlacement(); |
gInitialButtonDelay = initialButtonDelay; |
gAutoscrollButtonDelay = autoscrollButtonDelay; |
gJumpOnTrackClick = jumpOnTrackClick; |
+ bool sendScrollerStyleNotification = gPreferredScrollerStyle != preferredScrollerStyle; |
+ gPreferredScrollerStyle = preferredScrollerStyle; |
if (redraw && !scrollbarSet().isEmpty()) { |
ScrollbarSet::iterator end = scrollbarSet().end(); |
for (ScrollbarSet::iterator it = scrollbarSet().begin(); it != end; ++it) { |
@@ -304,6 +308,12 @@ void ScrollbarThemeMacCommon::preferencesChanged(float initialButtonDelay, float |
(*it)->invalidate(); |
} |
} |
+ if (sendScrollerStyleNotification) { |
+ [[NSNotificationCenter defaultCenter] |
+ postNotificationName:@"NSPreferredScrollerStyleDidChangeNotification" |
+ object:nil |
+ userInfo:@{ @"NSScrollerStyle" : @(gPreferredScrollerStyle) }]; |
+ } |
} |
double ScrollbarThemeMacCommon::initialAutoscrollTimerDelay() |
@@ -348,4 +358,21 @@ int ScrollbarThemeMacCommon::scrollbarPartToHIPressedState(ScrollbarPart part) |
} |
} |
+// static |
+NSScrollerStyle ScrollbarThemeMacCommon::recommendedScrollerStyle() |
+{ |
+ if (RuntimeEnabledFeatures::overlayScrollbarsEnabled()) |
+ return NSScrollerStyleOverlay; |
+ return gPreferredScrollerStyle; |
+} |
+ |
+// static |
+bool ScrollbarThemeMacCommon::isOverlayAPIAvailable() |
+{ |
+ static bool apiAvailable = |
+ [NSClassFromString(@"NSScrollerImp") respondsToSelector:@selector(scrollerImpWithStyle:controlSize:horizontal:replacingScrollerImp:)] |
+ && [NSClassFromString(@"NSScrollerImpPair") instancesRespondToSelector:@selector(scrollerStyle)]; |
+ return apiAvailable; |
+} |
+ |
} // namespace WebCore |