| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "RuntimeEnabledFeatures.h" | |
| 28 #include "platform/scroll/ScrollbarThemeMacCommon.h" | 27 #include "platform/scroll/ScrollbarThemeMacCommon.h" |
| 29 | 28 |
| 30 #include <Carbon/Carbon.h> | 29 #include <Carbon/Carbon.h> |
| 31 #include "platform/PlatformMouseEvent.h" | 30 #include "platform/PlatformMouseEvent.h" |
| 32 #include "platform/graphics/Gradient.h" | 31 #include "platform/graphics/Gradient.h" |
| 33 #include "platform/graphics/GraphicsContext.h" | 32 #include "platform/graphics/GraphicsContext.h" |
| 34 #include "platform/graphics/GraphicsContextStateSaver.h" | 33 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 35 #include "platform/graphics/GraphicsLayer.h" | 34 #include "platform/graphics/GraphicsLayer.h" |
| 36 #include "platform/graphics/ImageBuffer.h" | 35 #include "platform/graphics/ImageBuffer.h" |
| 37 #include "platform/mac/ColorMac.h" | 36 #include "platform/mac/ColorMac.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 68 return set; | 67 return set; |
| 69 } | 68 } |
| 70 | 69 |
| 71 } | 70 } |
| 72 | 71 |
| 73 namespace WebCore { | 72 namespace WebCore { |
| 74 | 73 |
| 75 static float gInitialButtonDelay = 0.5f; | 74 static float gInitialButtonDelay = 0.5f; |
| 76 static float gAutoscrollButtonDelay = 0.05f; | 75 static float gAutoscrollButtonDelay = 0.05f; |
| 77 static bool gJumpOnTrackClick = false; | 76 static bool gJumpOnTrackClick = false; |
| 78 static NSScrollerStyle gPreferredScrollerStyle = NSScrollerStyleLegacy; | |
| 79 | 77 |
| 80 ScrollbarTheme* ScrollbarTheme::nativeTheme() | 78 ScrollbarTheme* ScrollbarTheme::nativeTheme() |
| 81 { | 79 { |
| 82 static ScrollbarThemeMacCommon* theme = NULL; | 80 static ScrollbarThemeMacCommon* theme = NULL; |
| 83 if (theme) | 81 if (theme) |
| 84 return theme; | 82 return theme; |
| 85 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable()) { | 83 if (isScrollbarOverlayAPIAvailable()) { |
| 86 DEFINE_STATIC_LOCAL(ScrollbarThemeMacOverlayAPI, overlayTheme, ()); | 84 DEFINE_STATIC_LOCAL(ScrollbarThemeMacOverlayAPI, overlayTheme, ()); |
| 87 theme = &overlayTheme; | 85 theme = &overlayTheme; |
| 88 } else { | 86 } else { |
| 89 DEFINE_STATIC_LOCAL(ScrollbarThemeMacNonOverlayAPI, nonOverlayTheme, ())
; | 87 DEFINE_STATIC_LOCAL(ScrollbarThemeMacNonOverlayAPI, nonOverlayTheme, ())
; |
| 90 theme = &nonOverlayTheme; | 88 theme = &nonOverlayTheme; |
| 91 } | 89 } |
| 92 return theme; | 90 return theme; |
| 93 } | 91 } |
| 94 | 92 |
| 95 void ScrollbarThemeMacCommon::registerScrollbar(ScrollbarThemeClient* scrollbar) | 93 void ScrollbarThemeMacCommon::registerScrollbar(ScrollbarThemeClient* scrollbar) |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 IntRect tickmarkTrackRect = rect; | 284 IntRect tickmarkTrackRect = rect; |
| 287 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 1); | 285 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 1); |
| 288 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 2); | 286 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 2); |
| 289 paintGivenTickmarks(context, scrollbar, tickmarkTrackRect, tickmarks); | 287 paintGivenTickmarks(context, scrollbar, tickmarkTrackRect, tickmarks); |
| 290 } | 288 } |
| 291 | 289 |
| 292 ScrollbarThemeMacCommon::~ScrollbarThemeMacCommon() | 290 ScrollbarThemeMacCommon::~ScrollbarThemeMacCommon() |
| 293 { | 291 { |
| 294 } | 292 } |
| 295 | 293 |
| 296 void ScrollbarThemeMacCommon::preferencesChanged(float initialButtonDelay, float
autoscrollButtonDelay, bool jumpOnTrackClick, NSScrollerStyle preferredScroller
Style, bool redraw) | 294 void ScrollbarThemeMacCommon::preferencesChanged(float initialButtonDelay, float
autoscrollButtonDelay, bool jumpOnTrackClick, bool redraw) |
| 297 { | 295 { |
| 298 updateButtonPlacement(); | 296 updateButtonPlacement(); |
| 299 gInitialButtonDelay = initialButtonDelay; | 297 gInitialButtonDelay = initialButtonDelay; |
| 300 gAutoscrollButtonDelay = autoscrollButtonDelay; | 298 gAutoscrollButtonDelay = autoscrollButtonDelay; |
| 301 gJumpOnTrackClick = jumpOnTrackClick; | 299 gJumpOnTrackClick = jumpOnTrackClick; |
| 302 bool sendScrollerStyleNotification = gPreferredScrollerStyle != preferredScr
ollerStyle; | |
| 303 gPreferredScrollerStyle = preferredScrollerStyle; | |
| 304 if (redraw && !scrollbarSet().isEmpty()) { | 300 if (redraw && !scrollbarSet().isEmpty()) { |
| 305 ScrollbarSet::iterator end = scrollbarSet().end(); | 301 ScrollbarSet::iterator end = scrollbarSet().end(); |
| 306 for (ScrollbarSet::iterator it = scrollbarSet().begin(); it != end; ++it
) { | 302 for (ScrollbarSet::iterator it = scrollbarSet().begin(); it != end; ++it
) { |
| 307 (*it)->styleChanged(); | 303 (*it)->styleChanged(); |
| 308 (*it)->invalidate(); | 304 (*it)->invalidate(); |
| 309 } | 305 } |
| 310 } | 306 } |
| 311 if (sendScrollerStyleNotification) { | |
| 312 [[NSNotificationCenter defaultCenter] | |
| 313 postNotificationName:@"NSPreferredScrollerStyleDidChangeNotification
" | |
| 314 object:nil | |
| 315 userInfo:@{ @"NSScrollerStyle" : @(gPreferredScrollerSty
le) }]; | |
| 316 } | |
| 317 } | 307 } |
| 318 | 308 |
| 319 double ScrollbarThemeMacCommon::initialAutoscrollTimerDelay() | 309 double ScrollbarThemeMacCommon::initialAutoscrollTimerDelay() |
| 320 { | 310 { |
| 321 return gInitialButtonDelay; | 311 return gInitialButtonDelay; |
| 322 } | 312 } |
| 323 | 313 |
| 324 double ScrollbarThemeMacCommon::autoscrollTimerDelay() | 314 double ScrollbarThemeMacCommon::autoscrollTimerDelay() |
| 325 { | 315 { |
| 326 return gAutoscrollButtonDelay; | 316 return gAutoscrollButtonDelay; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 351 return kThemeTopInsideArrowPressed; | 341 return kThemeTopInsideArrowPressed; |
| 352 case ForwardButtonEndPart: | 342 case ForwardButtonEndPart: |
| 353 return kThemeBottomOutsideArrowPressed; | 343 return kThemeBottomOutsideArrowPressed; |
| 354 case ThumbPart: | 344 case ThumbPart: |
| 355 return kThemeThumbPressed; | 345 return kThemeThumbPressed; |
| 356 default: | 346 default: |
| 357 return 0; | 347 return 0; |
| 358 } | 348 } |
| 359 } | 349 } |
| 360 | 350 |
| 361 // static | |
| 362 NSScrollerStyle ScrollbarThemeMacCommon::recommendedScrollerStyle() | |
| 363 { | |
| 364 if (RuntimeEnabledFeatures::overlayScrollbarsEnabled()) | |
| 365 return NSScrollerStyleOverlay; | |
| 366 return gPreferredScrollerStyle; | |
| 367 } | |
| 368 | |
| 369 // static | |
| 370 bool ScrollbarThemeMacCommon::isOverlayAPIAvailable() | |
| 371 { | |
| 372 static bool apiAvailable = | |
| 373 [NSClassFromString(@"NSScrollerImp") respondsToSelector:@selector(scroll
erImpWithStyle:controlSize:horizontal:replacingScrollerImp:)] | |
| 374 && [NSClassFromString(@"NSScrollerImpPair") instancesRespondToSelector:@
selector(scrollerStyle)]; | |
| 375 return apiAvailable; | |
| 376 } | |
| 377 | |
| 378 } // namespace WebCore | 351 } // namespace WebCore |
| OLD | NEW |