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

Side by Side Diff: ui/views/cocoa/views_scrollbar_bridge.mm

Issue 1671313002: MacViews: Overlay Scrollbars with Show/Hide Animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "ui/views/cocoa/views_scrollbar_bridge.h"
6
7 #include "base/mac/mac_util.h"
8 #import "base/mac/sdk_forward_declarations.h"
9
10 @interface ViewsScrollbarBridge ()
11
12 // Called when we receive a NSPreferredScrollerStyleDidChangeNotification.
13 - (void)onScrollerStyleChanged:(NSNotification*)notification;
14
15 @end
16
17 @implementation ViewsScrollbarBridge
18
19 - (void)setDelegate:(ViewsScrollbarBridgeDelegate*)delegate {
20 DCHECK_NE(delegate, delegate_);
21 delegate_ = delegate;
22 if (!delegate_) {
23 [[NSNotificationCenter defaultCenter] removeObserver:self];
24 return;
25 }
26 [[NSNotificationCenter defaultCenter]
27 addObserver:self
28 selector:@selector(onScrollerStyleChanged:)
29 name:NSPreferredScrollerStyleDidChangeNotification
30 object:nil];
Avi (use Gerrit) 2016/02/22 19:37:07 Won't this end up with a double registration if ca
spqchan 2016/02/22 20:49:25 True, I changed it so it only sets the delegate wh
tapted 2016/02/22 22:34:57 I think there's a nicer way to fix this, just by r
31 }
32
33 - (void)dealloc {
34 DCHECK(!delegate_);
35 [super dealloc];
36 }
37
38 - (void)onScrollerStyleChanged:(NSNotification*)notification {
39 if (delegate_)
40 delegate_->OnScrollerStyleChanged();
41 }
42
43 + (NSScrollerStyle)getPreferredScrollerStyle {
44 if (![NSScroller respondsToSelector:@selector(preferredScrollerStyle)]) {
45 DCHECK(base::mac::IsOSSnowLeopard());
46 return NSScrollerStyleLegacy;
47 }
48 return [NSScroller preferredScrollerStyle];
49 }
50
51 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698