| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 typedef HashSet<ScrollbarThemeClient*> ScrollbarSet; | 63 typedef HashSet<ScrollbarThemeClient*> ScrollbarSet; |
| 64 | 64 |
| 65 static ScrollbarSet& scrollbarSet() | 65 static ScrollbarSet& scrollbarSet() |
| 66 { | 66 { |
| 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 @interface WebScrollbarPrefsObserver : NSObject | |
| 74 { | |
| 75 } | |
| 76 | |
| 77 + (void)registerAsObserver; | |
| 78 + (void)appearancePrefsChanged:(NSNotification*)theNotification; | |
| 79 + (void)behaviorPrefsChanged:(NSNotification*)theNotification; | |
| 80 | |
| 81 @end | |
| 82 | |
| 83 @implementation WebScrollbarPrefsObserver | |
| 84 | |
| 85 + (void)appearancePrefsChanged:(NSNotification*)unusedNotification | |
| 86 { | |
| 87 UNUSED_PARAM(unusedNotification); | |
| 88 | |
| 89 ScrollbarTheme* theme = ScrollbarTheme::theme(); | |
| 90 if (theme->isMockTheme()) | |
| 91 return; | |
| 92 | |
| 93 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
| 94 [defaults synchronize]; | |
| 95 static_cast<ScrollbarThemeMacCommon*>(ScrollbarTheme::theme())->preferencesC
hanged( | |
| 96 [defaults floatForKey:@"NSScrollerButtonDelay"], [defaults floatForKey:@
"NSScrollerButtonPeriod"], | |
| 97 [defaults boolForKey:@"AppleScrollerPagingBehavior"], true); | |
| 98 } | |
| 99 | |
| 100 + (void)behaviorPrefsChanged:(NSNotification*)unusedNotification | |
| 101 { | |
| 102 UNUSED_PARAM(unusedNotification); | |
| 103 | |
| 104 ScrollbarTheme* theme = ScrollbarTheme::theme(); | |
| 105 if (theme->isMockTheme()) | |
| 106 return; | |
| 107 | |
| 108 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
| 109 [defaults synchronize]; | |
| 110 static_cast<ScrollbarThemeMacCommon*>(ScrollbarTheme::theme())->preferencesC
hanged( | |
| 111 [defaults floatForKey:@"NSScrollerButtonDelay"], [defaults floatForKey:@
"NSScrollerButtonPeriod"], | |
| 112 [defaults boolForKey:@"AppleScrollerPagingBehavior"], false); | |
| 113 } | |
| 114 | |
| 115 + (void)registerAsObserver | |
| 116 { | |
| 117 [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@
selector(appearancePrefsChanged:) name:@"AppleAquaScrollBarVariantChanged" objec
t:nil suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately]; | |
| 118 [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@
selector(behaviorPrefsChanged:) name:@"AppleNoRedisplayAppearancePreferenceChang
ed" object:nil suspensionBehavior:NSNotificationSuspensionBehaviorCoalesce]; | |
| 119 } | |
| 120 | |
| 121 @end | |
| 122 | |
| 123 namespace WebCore { | 73 namespace WebCore { |
| 124 | 74 |
| 125 static float gInitialButtonDelay = 0.5f; | 75 static float gInitialButtonDelay = 0.5f; |
| 126 static float gAutoscrollButtonDelay = 0.05f; | 76 static float gAutoscrollButtonDelay = 0.05f; |
| 127 static bool gJumpOnTrackClick = false; | 77 static bool gJumpOnTrackClick = false; |
| 128 | 78 |
| 129 ScrollbarTheme* ScrollbarTheme::nativeTheme() | 79 ScrollbarTheme* ScrollbarTheme::nativeTheme() |
| 130 { | 80 { |
| 131 static ScrollbarThemeMacCommon* theme = NULL; | 81 static ScrollbarThemeMacCommon* theme = NULL; |
| 132 if (theme) | 82 if (theme) |
| 133 return theme; | 83 return theme; |
| 134 if (isScrollbarOverlayAPIAvailable()) { | 84 if (isScrollbarOverlayAPIAvailable()) { |
| 135 DEFINE_STATIC_LOCAL(ScrollbarThemeMacOverlayAPI, overlayTheme, ()); | 85 DEFINE_STATIC_LOCAL(ScrollbarThemeMacOverlayAPI, overlayTheme, ()); |
| 136 theme = &overlayTheme; | 86 theme = &overlayTheme; |
| 137 } else { | 87 } else { |
| 138 DEFINE_STATIC_LOCAL(ScrollbarThemeMacNonOverlayAPI, nonOverlayTheme, ())
; | 88 DEFINE_STATIC_LOCAL(ScrollbarThemeMacNonOverlayAPI, nonOverlayTheme, ())
; |
| 139 theme = &nonOverlayTheme; | 89 theme = &nonOverlayTheme; |
| 140 } | 90 } |
| 141 theme->Initialize(); | |
| 142 return theme; | 91 return theme; |
| 143 } | 92 } |
| 144 | 93 |
| 145 void ScrollbarThemeMacCommon::registerScrollbar(ScrollbarThemeClient* scrollbar) | 94 void ScrollbarThemeMacCommon::registerScrollbar(ScrollbarThemeClient* scrollbar) |
| 146 { | 95 { |
| 147 scrollbarSet().add(scrollbar); | 96 scrollbarSet().add(scrollbar); |
| 148 } | 97 } |
| 149 | 98 |
| 150 void ScrollbarThemeMacCommon::unregisterScrollbar(ScrollbarThemeClient* scrollba
r) | 99 void ScrollbarThemeMacCommon::unregisterScrollbar(ScrollbarThemeClient* scrollba
r) |
| 151 { | 100 { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 if (!tickmarks.size()) | 281 if (!tickmarks.size()) |
| 333 return; | 282 return; |
| 334 | 283 |
| 335 // Inset a bit. | 284 // Inset a bit. |
| 336 IntRect tickmarkTrackRect = rect; | 285 IntRect tickmarkTrackRect = rect; |
| 337 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 1); | 286 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 1); |
| 338 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 2); | 287 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 2); |
| 339 paintGivenTickmarks(context, scrollbar, tickmarkTrackRect, tickmarks); | 288 paintGivenTickmarks(context, scrollbar, tickmarkTrackRect, tickmarks); |
| 340 } | 289 } |
| 341 | 290 |
| 342 void ScrollbarThemeMacCommon::Initialize() | |
| 343 { | |
| 344 [WebScrollbarPrefsObserver registerAsObserver]; | |
| 345 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
| 346 [defaults synchronize]; | |
| 347 preferencesChanged( | |
| 348 [defaults floatForKey:@"NSScrollerButtonDelay"], [defaults floatForKey:@
"NSScrollerButtonPeriod"], | |
| 349 [defaults boolForKey:@"AppleScrollerPagingBehavior"], false); | |
| 350 } | |
| 351 | |
| 352 ScrollbarThemeMacCommon::~ScrollbarThemeMacCommon() | 291 ScrollbarThemeMacCommon::~ScrollbarThemeMacCommon() |
| 353 { | 292 { |
| 354 } | 293 } |
| 355 | 294 |
| 356 void ScrollbarThemeMacCommon::preferencesChanged(float initialButtonDelay, float
autoscrollButtonDelay, bool jumpOnTrackClick, bool redraw) | 295 void ScrollbarThemeMacCommon::preferencesChanged(float initialButtonDelay, float
autoscrollButtonDelay, bool jumpOnTrackClick, bool redraw) |
| 357 { | 296 { |
| 358 updateButtonPlacement(); | 297 updateButtonPlacement(); |
| 359 gInitialButtonDelay = initialButtonDelay; | 298 gInitialButtonDelay = initialButtonDelay; |
| 360 gAutoscrollButtonDelay = autoscrollButtonDelay; | 299 gAutoscrollButtonDelay = autoscrollButtonDelay; |
| 361 gJumpOnTrackClick = jumpOnTrackClick; | 300 gJumpOnTrackClick = jumpOnTrackClick; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 case ForwardButtonEndPart: | 343 case ForwardButtonEndPart: |
| 405 return kThemeBottomOutsideArrowPressed; | 344 return kThemeBottomOutsideArrowPressed; |
| 406 case ThumbPart: | 345 case ThumbPart: |
| 407 return kThemeThumbPressed; | 346 return kThemeThumbPressed; |
| 408 default: | 347 default: |
| 409 return 0; | 348 return 0; |
| 410 } | 349 } |
| 411 } | 350 } |
| 412 | 351 |
| 413 } // namespace WebCore | 352 } // namespace WebCore |
| OLD | NEW |