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

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: 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
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 "base/mac/sdk_forward_declarations.h"
8 #import "base/mac/scoped_objc_class_swizzler.h" 8 #import "base/mac/scoped_objc_class_swizzler.h"
9 9
10 using base::mac::ScopedObjCClassSwizzler; 10 using base::mac::ScopedObjCClassSwizzler;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 return NSScrollerStyleOverlay; 47 return NSScrollerStyleOverlay;
48 } 48 }
49 49
50 @end 50 @end
51 51
52 namespace ui { 52 namespace ui {
53 namespace test { 53 namespace test {
54 54
55 ScopedPreferredScrollerStyle::ScopedPreferredScrollerStyle(bool overlay) 55 ScopedPreferredScrollerStyle::ScopedPreferredScrollerStyle(bool overlay)
56 : overlay_(overlay) { 56 : overlay_(overlay) {
57 if (![NSScroller respondsToSelector:@selector(preferredScrollerStyle)])
58 return;
59
60 NSInteger previous_style = [NSScroller preferredScrollerStyle]; 57 NSInteger previous_style = [NSScroller preferredScrollerStyle];
61 Class style_class = overlay_ 58 Class style_class = overlay_
62 ? [FakeNSScrollerPreferredStyleOverlayDonor class] 59 ? [FakeNSScrollerPreferredStyleOverlayDonor class]
63 : [FakeNSScrollerPreferredStyleLegacyDonor class]; 60 : [FakeNSScrollerPreferredStyleLegacyDonor class];
64 61
65 swizzler_.reset(new ScopedObjCClassSwizzler( 62 swizzler_.reset(new ScopedObjCClassSwizzler(
66 [NSScroller class], style_class, @selector(preferredScrollerStyle))); 63 [NSScroller class], style_class, @selector(preferredScrollerStyle)));
67 64
68 if (previous_style != GetScrollerStyle(overlay_)) 65 if (previous_style != GetScrollerStyle(overlay_))
69 NotifyStyleChanged(); 66 NotifyStyleChanged();
70 } 67 }
71 68
72 ScopedPreferredScrollerStyle::~ScopedPreferredScrollerStyle() { 69 ScopedPreferredScrollerStyle::~ScopedPreferredScrollerStyle() {
73 if (!swizzler_)
74 return; // Handle 10.6, which wouldn't have swizzled anything.
75
76 swizzler_.reset(); 70 swizzler_.reset();
77 71
78 if ([NSScroller preferredScrollerStyle] != GetScrollerStyle(overlay_)) 72 if ([NSScroller preferredScrollerStyle] != GetScrollerStyle(overlay_))
79 NotifyStyleChanged(); 73 NotifyStyleChanged();
80 } 74 }
81 75
82 } // namespace test 76 } // namespace test
83 } // namespace ui 77 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698