OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 static ScrollbarSet& scrollbarSet() | 60 static ScrollbarSet& scrollbarSet() |
61 { | 61 { |
62 DEFINE_STATIC_LOCAL(ScrollbarSet, set, ()); | 62 DEFINE_STATIC_LOCAL(ScrollbarSet, set, ()); |
63 return set; | 63 return set; |
64 } | 64 } |
65 | 65 |
66 static float gInitialButtonDelay = 0.5f; | 66 static float gInitialButtonDelay = 0.5f; |
67 static float gAutoscrollButtonDelay = 0.05f; | 67 static float gAutoscrollButtonDelay = 0.05f; |
68 static NSScrollerStyle gPreferredScrollerStyle = NSScrollerStyleLegacy; | 68 static NSScrollerStyle gPreferredScrollerStyle = NSScrollerStyleLegacy; |
69 static bool gScrollAnimationEnabledForSystem = false; | |
70 | 69 |
71 ScrollbarTheme& ScrollbarTheme::nativeTheme() | 70 ScrollbarTheme& ScrollbarTheme::nativeTheme() |
72 { | 71 { |
73 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable()) { | 72 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable()) { |
74 DEFINE_STATIC_LOCAL(ScrollbarThemeMacOverlayAPI, overlayTheme, ()); | 73 DEFINE_STATIC_LOCAL(ScrollbarThemeMacOverlayAPI, overlayTheme, ()); |
75 return overlayTheme; | 74 return overlayTheme; |
76 } | 75 } |
77 { | 76 { |
78 DEFINE_STATIC_LOCAL(ScrollbarThemeMacNonOverlayAPI, nonOverlayTheme, ())
; | 77 DEFINE_STATIC_LOCAL(ScrollbarThemeMacNonOverlayAPI, nonOverlayTheme, ())
; |
79 return nonOverlayTheme; | 78 return nonOverlayTheme; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 IntRect tickmarkTrackRect = rect; | 151 IntRect tickmarkTrackRect = rect; |
153 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 1); | 152 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 1); |
154 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 2); | 153 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 2); |
155 paintGivenTickmarks(context.canvas(), scrollbar, tickmarkTrackRect, tickmark
s); | 154 paintGivenTickmarks(context.canvas(), scrollbar, tickmarkTrackRect, tickmark
s); |
156 } | 155 } |
157 | 156 |
158 ScrollbarThemeMacCommon::~ScrollbarThemeMacCommon() | 157 ScrollbarThemeMacCommon::~ScrollbarThemeMacCommon() |
159 { | 158 { |
160 } | 159 } |
161 | 160 |
162 void ScrollbarThemeMacCommon::preferencesChanged(float initialButtonDelay, float
autoscrollButtonDelay, NSScrollerStyle preferredScrollerStyle, bool redraw, boo
l scrollAnimationEnabled, WebScrollbarButtonsPlacement buttonPlacement) | 161 void ScrollbarThemeMacCommon::preferencesChanged(float initialButtonDelay, float
autoscrollButtonDelay, NSScrollerStyle preferredScrollerStyle, bool redraw, Web
ScrollbarButtonsPlacement buttonPlacement) |
163 { | 162 { |
164 updateButtonPlacement(buttonPlacement); | 163 updateButtonPlacement(buttonPlacement); |
165 gInitialButtonDelay = initialButtonDelay; | 164 gInitialButtonDelay = initialButtonDelay; |
166 gAutoscrollButtonDelay = autoscrollButtonDelay; | 165 gAutoscrollButtonDelay = autoscrollButtonDelay; |
167 gScrollAnimationEnabledForSystem = scrollAnimationEnabled; | |
168 bool sendScrollerStyleNotification = gPreferredScrollerStyle != preferredScr
ollerStyle; | 166 bool sendScrollerStyleNotification = gPreferredScrollerStyle != preferredScr
ollerStyle; |
169 gPreferredScrollerStyle = preferredScrollerStyle; | 167 gPreferredScrollerStyle = preferredScrollerStyle; |
170 if (redraw && !scrollbarSet().isEmpty()) { | 168 if (redraw && !scrollbarSet().isEmpty()) { |
171 ScrollbarSet::iterator end = scrollbarSet().end(); | 169 ScrollbarSet::iterator end = scrollbarSet().end(); |
172 for (ScrollbarSet::iterator it = scrollbarSet().begin(); it != end; ++it
) { | 170 for (ScrollbarSet::iterator it = scrollbarSet().begin(); it != end; ++it
) { |
173 (*it)->styleChanged(); | 171 (*it)->styleChanged(); |
174 (*it)->invalidate(); | 172 (*it)->invalidate(); |
175 } | 173 } |
176 } | 174 } |
177 if (sendScrollerStyleNotification) { | 175 if (sendScrollerStyleNotification) { |
178 [[NSNotificationCenter defaultCenter] | 176 [[NSNotificationCenter defaultCenter] |
179 postNotificationName:@"NSPreferredScrollerStyleDidChangeNotification
" | 177 postNotificationName:@"NSPreferredScrollerStyleDidChangeNotification
" |
180 object:nil | 178 object:nil |
181 userInfo:@{ @"NSScrollerStyle" : @(gPreferredScrollerSty
le) }]; | 179 userInfo:@{ @"NSScrollerStyle" : @(gPreferredScrollerSty
le) }]; |
182 } | 180 } |
183 } | 181 } |
184 | 182 |
185 bool ScrollbarThemeMacCommon::scrollAnimationEnabledForSystem() | |
186 { | |
187 return gScrollAnimationEnabledForSystem; | |
188 } | |
189 | |
190 double ScrollbarThemeMacCommon::initialAutoscrollTimerDelay() | 183 double ScrollbarThemeMacCommon::initialAutoscrollTimerDelay() |
191 { | 184 { |
192 return gInitialButtonDelay; | 185 return gInitialButtonDelay; |
193 } | 186 } |
194 | 187 |
195 double ScrollbarThemeMacCommon::autoscrollTimerDelay() | 188 double ScrollbarThemeMacCommon::autoscrollTimerDelay() |
196 { | 189 { |
197 return gAutoscrollButtonDelay; | 190 return gAutoscrollButtonDelay; |
198 } | 191 } |
199 | 192 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 // static | 224 // static |
232 bool ScrollbarThemeMacCommon::isOverlayAPIAvailable() | 225 bool ScrollbarThemeMacCommon::isOverlayAPIAvailable() |
233 { | 226 { |
234 static bool apiAvailable = | 227 static bool apiAvailable = |
235 [NSClassFromString(@"NSScrollerImp") respondsToSelector:@selector(scroll
erImpWithStyle:controlSize:horizontal:replacingScrollerImp:)] | 228 [NSClassFromString(@"NSScrollerImp") respondsToSelector:@selector(scroll
erImpWithStyle:controlSize:horizontal:replacingScrollerImp:)] |
236 && [NSClassFromString(@"NSScrollerImpPair") instancesRespondToSelector:@
selector(scrollerStyle)]; | 229 && [NSClassFromString(@"NSScrollerImpPair") instancesRespondToSelector:@
selector(scrollerStyle)]; |
237 return apiAvailable; | 230 return apiAvailable; |
238 } | 231 } |
239 | 232 |
240 } // namespace blink | 233 } // namespace blink |
OLD | NEW |