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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 DEFINE_STATIC_LOCAL(ScrollbarSet, set, ()); | 67 DEFINE_STATIC_LOCAL(ScrollbarSet, set, ()); |
68 return set; | 68 return set; |
69 } | 69 } |
70 | 70 |
71 } | 71 } |
72 | 72 |
73 namespace WebCore { | 73 namespace WebCore { |
74 | 74 |
75 static float gInitialButtonDelay = 0.5f; | 75 static float gInitialButtonDelay = 0.5f; |
76 static float gAutoscrollButtonDelay = 0.05f; | 76 static float gAutoscrollButtonDelay = 0.05f; |
77 static bool gJumpOnTrackClick = false; | |
78 static NSScrollerStyle gPreferredScrollerStyle = NSScrollerStyleLegacy; | 77 static NSScrollerStyle gPreferredScrollerStyle = NSScrollerStyleLegacy; |
79 | 78 |
80 ScrollbarTheme* ScrollbarTheme::nativeTheme() | 79 ScrollbarTheme* ScrollbarTheme::nativeTheme() |
81 { | 80 { |
82 static ScrollbarThemeMacCommon* theme = NULL; | 81 static ScrollbarThemeMacCommon* theme = NULL; |
83 if (theme) | 82 if (theme) |
84 return theme; | 83 return theme; |
85 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable()) { | 84 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable()) { |
86 DEFINE_STATIC_LOCAL(ScrollbarThemeMacOverlayAPI, overlayTheme, ()); | 85 DEFINE_STATIC_LOCAL(ScrollbarThemeMacOverlayAPI, overlayTheme, ()); |
87 theme = &overlayTheme; | 86 theme = &overlayTheme; |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 IntRect tickmarkTrackRect = rect; | 285 IntRect tickmarkTrackRect = rect; |
287 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 1); | 286 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 1); |
288 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 2); | 287 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 2); |
289 paintGivenTickmarks(context, scrollbar, tickmarkTrackRect, tickmarks); | 288 paintGivenTickmarks(context, scrollbar, tickmarkTrackRect, tickmarks); |
290 } | 289 } |
291 | 290 |
292 ScrollbarThemeMacCommon::~ScrollbarThemeMacCommon() | 291 ScrollbarThemeMacCommon::~ScrollbarThemeMacCommon() |
293 { | 292 { |
294 } | 293 } |
295 | 294 |
296 void ScrollbarThemeMacCommon::preferencesChanged(float initialButtonDelay, float
autoscrollButtonDelay, bool jumpOnTrackClick, NSScrollerStyle preferredScroller
Style, bool redraw) | 295 void ScrollbarThemeMacCommon::preferencesChanged(float initialButtonDelay, float
autoscrollButtonDelay, NSScrollerStyle preferredScrollerStyle, bool redraw) |
297 { | 296 { |
298 updateButtonPlacement(); | 297 updateButtonPlacement(); |
299 gInitialButtonDelay = initialButtonDelay; | 298 gInitialButtonDelay = initialButtonDelay; |
300 gAutoscrollButtonDelay = autoscrollButtonDelay; | 299 gAutoscrollButtonDelay = autoscrollButtonDelay; |
301 gJumpOnTrackClick = jumpOnTrackClick; | |
302 bool sendScrollerStyleNotification = gPreferredScrollerStyle != preferredScr
ollerStyle; | 300 bool sendScrollerStyleNotification = gPreferredScrollerStyle != preferredScr
ollerStyle; |
303 gPreferredScrollerStyle = preferredScrollerStyle; | 301 gPreferredScrollerStyle = preferredScrollerStyle; |
304 if (redraw && !scrollbarSet().isEmpty()) { | 302 if (redraw && !scrollbarSet().isEmpty()) { |
305 ScrollbarSet::iterator end = scrollbarSet().end(); | 303 ScrollbarSet::iterator end = scrollbarSet().end(); |
306 for (ScrollbarSet::iterator it = scrollbarSet().begin(); it != end; ++it
) { | 304 for (ScrollbarSet::iterator it = scrollbarSet().begin(); it != end; ++it
) { |
307 (*it)->styleChanged(); | 305 (*it)->styleChanged(); |
308 (*it)->invalidate(); | 306 (*it)->invalidate(); |
309 } | 307 } |
310 } | 308 } |
311 if (sendScrollerStyleNotification) { | 309 if (sendScrollerStyleNotification) { |
312 [[NSNotificationCenter defaultCenter] | 310 [[NSNotificationCenter defaultCenter] |
313 postNotificationName:@"NSPreferredScrollerStyleDidChangeNotification
" | 311 postNotificationName:@"NSPreferredScrollerStyleDidChangeNotification
" |
314 object:nil | 312 object:nil |
315 userInfo:@{ @"NSScrollerStyle" : @(gPreferredScrollerSty
le) }]; | 313 userInfo:@{ @"NSScrollerStyle" : @(gPreferredScrollerSty
le) }]; |
316 } | 314 } |
317 } | 315 } |
318 | 316 |
319 double ScrollbarThemeMacCommon::initialAutoscrollTimerDelay() | 317 double ScrollbarThemeMacCommon::initialAutoscrollTimerDelay() |
320 { | 318 { |
321 return gInitialButtonDelay; | 319 return gInitialButtonDelay; |
322 } | 320 } |
323 | 321 |
324 double ScrollbarThemeMacCommon::autoscrollTimerDelay() | 322 double ScrollbarThemeMacCommon::autoscrollTimerDelay() |
325 { | 323 { |
326 return gAutoscrollButtonDelay; | 324 return gAutoscrollButtonDelay; |
327 } | 325 } |
328 | 326 |
329 bool ScrollbarThemeMacCommon::shouldCenterOnThumb(ScrollbarThemeClient*, const P
latformMouseEvent& evt) | |
330 { | |
331 if (evt.button() != LeftButton) | |
332 return false; | |
333 if (gJumpOnTrackClick) | |
334 return !evt.altKey(); | |
335 return evt.altKey(); | |
336 } | |
337 | |
338 bool ScrollbarThemeMacCommon::shouldDragDocumentInsteadOfThumb(ScrollbarThemeCli
ent*, const PlatformMouseEvent& event) | 327 bool ScrollbarThemeMacCommon::shouldDragDocumentInsteadOfThumb(ScrollbarThemeCli
ent*, const PlatformMouseEvent& event) |
339 { | 328 { |
340 return event.altKey(); | 329 return event.altKey(); |
341 } | 330 } |
342 | 331 |
343 int ScrollbarThemeMacCommon::scrollbarPartToHIPressedState(ScrollbarPart part) | 332 int ScrollbarThemeMacCommon::scrollbarPartToHIPressedState(ScrollbarPart part) |
344 { | 333 { |
345 switch (part) { | 334 switch (part) { |
346 case BackButtonStartPart: | 335 case BackButtonStartPart: |
347 return kThemeTopOutsideArrowPressed; | 336 return kThemeTopOutsideArrowPressed; |
(...skipping 21 matching lines...) Expand all Loading... |
369 // static | 358 // static |
370 bool ScrollbarThemeMacCommon::isOverlayAPIAvailable() | 359 bool ScrollbarThemeMacCommon::isOverlayAPIAvailable() |
371 { | 360 { |
372 static bool apiAvailable = | 361 static bool apiAvailable = |
373 [NSClassFromString(@"NSScrollerImp") respondsToSelector:@selector(scroll
erImpWithStyle:controlSize:horizontal:replacingScrollerImp:)] | 362 [NSClassFromString(@"NSScrollerImp") respondsToSelector:@selector(scroll
erImpWithStyle:controlSize:horizontal:replacingScrollerImp:)] |
374 && [NSClassFromString(@"NSScrollerImpPair") instancesRespondToSelector:@
selector(scrollerStyle)]; | 363 && [NSClassFromString(@"NSScrollerImpPair") instancesRespondToSelector:@
selector(scrollerStyle)]; |
375 return apiAvailable; | 364 return apiAvailable; |
376 } | 365 } |
377 | 366 |
378 } // namespace WebCore | 367 } // namespace WebCore |
OLD | NEW |