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

Side by Side Diff: ui/base/test/scoped_preferred_scroller_style_mac.mm

Issue 1863513002: Mac: Remove some remaining 10.6 logic for absent overlay scrollbar APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Zap notification, import appkit rather than forward decs Created 4 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/ScrollbarThemeMac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ui/base/test/scoped_preferred_scroller_style_mac.h" 5 #import "ui/base/test/scoped_preferred_scroller_style_mac.h"
6 6
7 #import "base/mac/sdk_forward_declarations.h" 7 #import <AppKit/AppKit.h>
8
8 #import "base/mac/scoped_objc_class_swizzler.h" 9 #import "base/mac/scoped_objc_class_swizzler.h"
9 10
10 using base::mac::ScopedObjCClassSwizzler; 11 using base::mac::ScopedObjCClassSwizzler;
11 12
12 namespace { 13 namespace {
13 14
14 void NotifyStyleChanged() { 15 void NotifyStyleChanged() {
15 [[NSNotificationCenter defaultCenter] 16 [[NSNotificationCenter defaultCenter]
16 postNotificationName:NSPreferredScrollerStyleDidChangeNotification 17 postNotificationName:NSPreferredScrollerStyleDidChangeNotification
17 object:nil]; 18 object:nil];
(...skipping 29 matching lines...) Expand all
47 return NSScrollerStyleOverlay; 48 return NSScrollerStyleOverlay;
48 } 49 }
49 50
50 @end 51 @end
51 52
52 namespace ui { 53 namespace ui {
53 namespace test { 54 namespace test {
54 55
55 ScopedPreferredScrollerStyle::ScopedPreferredScrollerStyle(bool overlay) 56 ScopedPreferredScrollerStyle::ScopedPreferredScrollerStyle(bool overlay)
56 : overlay_(overlay) { 57 : overlay_(overlay) {
57 if (![NSScroller respondsToSelector:@selector(preferredScrollerStyle)])
58 return;
59
60 NSInteger previous_style = [NSScroller preferredScrollerStyle]; 58 NSInteger previous_style = [NSScroller preferredScrollerStyle];
61 Class style_class = overlay_ 59 Class style_class = overlay_
62 ? [FakeNSScrollerPreferredStyleOverlayDonor class] 60 ? [FakeNSScrollerPreferredStyleOverlayDonor class]
63 : [FakeNSScrollerPreferredStyleLegacyDonor class]; 61 : [FakeNSScrollerPreferredStyleLegacyDonor class];
64 62
65 swizzler_.reset(new ScopedObjCClassSwizzler( 63 swizzler_.reset(new ScopedObjCClassSwizzler(
66 [NSScroller class], style_class, @selector(preferredScrollerStyle))); 64 [NSScroller class], style_class, @selector(preferredScrollerStyle)));
67 65
68 if (previous_style != GetScrollerStyle(overlay_)) 66 if (previous_style != GetScrollerStyle(overlay_))
69 NotifyStyleChanged(); 67 NotifyStyleChanged();
70 } 68 }
71 69
72 ScopedPreferredScrollerStyle::~ScopedPreferredScrollerStyle() { 70 ScopedPreferredScrollerStyle::~ScopedPreferredScrollerStyle() {
73 if (!swizzler_)
74 return; // Handle 10.6, which wouldn't have swizzled anything.
75
76 swizzler_.reset(); 71 swizzler_.reset();
77 72
78 if ([NSScroller preferredScrollerStyle] != GetScrollerStyle(overlay_)) 73 if ([NSScroller preferredScrollerStyle] != GetScrollerStyle(overlay_))
79 NotifyStyleChanged(); 74 NotifyStyleChanged();
80 } 75 }
81 76
82 } // namespace test 77 } // namespace test
83 } // namespace ui 78 } // namespace ui
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/ScrollbarThemeMac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698