| 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" |
| 27 #include "platform/scroll/ScrollbarThemeMacCommon.h" | 28 #include "platform/scroll/ScrollbarThemeMacCommon.h" |
| 28 | 29 |
| 29 #include <Carbon/Carbon.h> | 30 #include <Carbon/Carbon.h> |
| 30 #include "platform/PlatformMouseEvent.h" | 31 #include "platform/PlatformMouseEvent.h" |
| 31 #include "platform/graphics/Gradient.h" | 32 #include "platform/graphics/Gradient.h" |
| 32 #include "platform/graphics/GraphicsContext.h" | 33 #include "platform/graphics/GraphicsContext.h" |
| 33 #include "platform/graphics/GraphicsContextStateSaver.h" | 34 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 34 #include "platform/graphics/GraphicsLayer.h" | 35 #include "platform/graphics/GraphicsLayer.h" |
| 35 #include "platform/graphics/ImageBuffer.h" | 36 #include "platform/graphics/ImageBuffer.h" |
| 36 #include "platform/mac/ColorMac.h" | 37 #include "platform/mac/ColorMac.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 67 return set; | 68 return set; |
| 68 } | 69 } |
| 69 | 70 |
| 70 } | 71 } |
| 71 | 72 |
| 72 namespace WebCore { | 73 namespace WebCore { |
| 73 | 74 |
| 74 static float gInitialButtonDelay = 0.5f; | 75 static float gInitialButtonDelay = 0.5f; |
| 75 static float gAutoscrollButtonDelay = 0.05f; | 76 static float gAutoscrollButtonDelay = 0.05f; |
| 76 static bool gJumpOnTrackClick = false; | 77 static bool gJumpOnTrackClick = false; |
| 78 static NSScrollerStyle gPreferredScrollerStyle = NSScrollerStyleLegacy; |
| 77 | 79 |
| 78 ScrollbarTheme* ScrollbarTheme::nativeTheme() | 80 ScrollbarTheme* ScrollbarTheme::nativeTheme() |
| 79 { | 81 { |
| 80 static ScrollbarThemeMacCommon* theme = NULL; | 82 static ScrollbarThemeMacCommon* theme = NULL; |
| 81 if (theme) | 83 if (theme) |
| 82 return theme; | 84 return theme; |
| 83 if (isScrollbarOverlayAPIAvailable()) { | 85 if (ScrollbarThemeMacCommon::isOverlayAPIAvailable()) { |
| 84 DEFINE_STATIC_LOCAL(ScrollbarThemeMacOverlayAPI, overlayTheme, ()); | 86 DEFINE_STATIC_LOCAL(ScrollbarThemeMacOverlayAPI, overlayTheme, ()); |
| 85 theme = &overlayTheme; | 87 theme = &overlayTheme; |
| 86 } else { | 88 } else { |
| 87 DEFINE_STATIC_LOCAL(ScrollbarThemeMacNonOverlayAPI, nonOverlayTheme, ())
; | 89 DEFINE_STATIC_LOCAL(ScrollbarThemeMacNonOverlayAPI, nonOverlayTheme, ())
; |
| 88 theme = &nonOverlayTheme; | 90 theme = &nonOverlayTheme; |
| 89 } | 91 } |
| 90 return theme; | 92 return theme; |
| 91 } | 93 } |
| 92 | 94 |
| 93 void ScrollbarThemeMacCommon::registerScrollbar(ScrollbarThemeClient* scrollbar) | 95 void ScrollbarThemeMacCommon::registerScrollbar(ScrollbarThemeClient* scrollbar) |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 IntRect tickmarkTrackRect = rect; | 286 IntRect tickmarkTrackRect = rect; |
| 285 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 1); | 287 tickmarkTrackRect.setX(tickmarkTrackRect.x() + 1); |
| 286 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 2); | 288 tickmarkTrackRect.setWidth(tickmarkTrackRect.width() - 2); |
| 287 paintGivenTickmarks(context, scrollbar, tickmarkTrackRect, tickmarks); | 289 paintGivenTickmarks(context, scrollbar, tickmarkTrackRect, tickmarks); |
| 288 } | 290 } |
| 289 | 291 |
| 290 ScrollbarThemeMacCommon::~ScrollbarThemeMacCommon() | 292 ScrollbarThemeMacCommon::~ScrollbarThemeMacCommon() |
| 291 { | 293 { |
| 292 } | 294 } |
| 293 | 295 |
| 294 void ScrollbarThemeMacCommon::preferencesChanged(float initialButtonDelay, float
autoscrollButtonDelay, bool jumpOnTrackClick, bool redraw) | 296 void ScrollbarThemeMacCommon::preferencesChanged(float initialButtonDelay, float
autoscrollButtonDelay, bool jumpOnTrackClick, NSScrollerStyle preferredScroller
Style, bool redraw) |
| 295 { | 297 { |
| 296 updateButtonPlacement(); | 298 updateButtonPlacement(); |
| 297 gInitialButtonDelay = initialButtonDelay; | 299 gInitialButtonDelay = initialButtonDelay; |
| 298 gAutoscrollButtonDelay = autoscrollButtonDelay; | 300 gAutoscrollButtonDelay = autoscrollButtonDelay; |
| 299 gJumpOnTrackClick = jumpOnTrackClick; | 301 gJumpOnTrackClick = jumpOnTrackClick; |
| 302 bool sendScrollerStyleNotification = gPreferredScrollerStyle != preferredScr
ollerStyle; |
| 303 gPreferredScrollerStyle = preferredScrollerStyle; |
| 300 if (redraw && !scrollbarSet().isEmpty()) { | 304 if (redraw && !scrollbarSet().isEmpty()) { |
| 301 ScrollbarSet::iterator end = scrollbarSet().end(); | 305 ScrollbarSet::iterator end = scrollbarSet().end(); |
| 302 for (ScrollbarSet::iterator it = scrollbarSet().begin(); it != end; ++it
) { | 306 for (ScrollbarSet::iterator it = scrollbarSet().begin(); it != end; ++it
) { |
| 303 (*it)->styleChanged(); | 307 (*it)->styleChanged(); |
| 304 (*it)->invalidate(); | 308 (*it)->invalidate(); |
| 305 } | 309 } |
| 306 } | 310 } |
| 311 if (sendScrollerStyleNotification) { |
| 312 [[NSNotificationCenter defaultCenter] |
| 313 postNotificationName:@"NSPreferredScrollerStyleDidChangeNotification
" |
| 314 object:nil |
| 315 userInfo:@{ @"NSScrollerStyle" : @(gPreferredScrollerSty
le) }]; |
| 316 } |
| 307 } | 317 } |
| 308 | 318 |
| 309 double ScrollbarThemeMacCommon::initialAutoscrollTimerDelay() | 319 double ScrollbarThemeMacCommon::initialAutoscrollTimerDelay() |
| 310 { | 320 { |
| 311 return gInitialButtonDelay; | 321 return gInitialButtonDelay; |
| 312 } | 322 } |
| 313 | 323 |
| 314 double ScrollbarThemeMacCommon::autoscrollTimerDelay() | 324 double ScrollbarThemeMacCommon::autoscrollTimerDelay() |
| 315 { | 325 { |
| 316 return gAutoscrollButtonDelay; | 326 return gAutoscrollButtonDelay; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 341 return kThemeTopInsideArrowPressed; | 351 return kThemeTopInsideArrowPressed; |
| 342 case ForwardButtonEndPart: | 352 case ForwardButtonEndPart: |
| 343 return kThemeBottomOutsideArrowPressed; | 353 return kThemeBottomOutsideArrowPressed; |
| 344 case ThumbPart: | 354 case ThumbPart: |
| 345 return kThemeThumbPressed; | 355 return kThemeThumbPressed; |
| 346 default: | 356 default: |
| 347 return 0; | 357 return 0; |
| 348 } | 358 } |
| 349 } | 359 } |
| 350 | 360 |
| 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 |
| 351 } // namespace WebCore | 378 } // namespace WebCore |
| OLD | NEW |