Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1211)

Unified Diff: Source/platform/scroll/ScrollbarThemeMacCommon.mm

Issue 136333009: Move preferred scrollbar style preference change listening from renderer to browser, 3 of 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« no previous file with comments | « Source/platform/scroll/ScrollbarThemeMacCommon.h ('k') | Source/platform/scroll/ScrollbarThemeMacOverlayAPI.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698