OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010, 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 currentValue = 1 - progress; | 423 currentValue = 1 - progress; |
424 else | 424 else |
425 currentValue = progress; | 425 currentValue = progress; |
426 | 426 |
427 switch (_featureToAnimate) { | 427 switch (_featureToAnimate) { |
428 case ThumbAlpha: | 428 case ThumbAlpha: |
429 [_scrollbarPainter.get() setKnobAlpha:currentValue]; | 429 [_scrollbarPainter.get() setKnobAlpha:currentValue]; |
430 break; | 430 break; |
431 case TrackAlpha: | 431 case TrackAlpha: |
432 [_scrollbarPainter.get() setTrackAlpha:currentValue]; | 432 [_scrollbarPainter.get() setTrackAlpha:currentValue]; |
| 433 _scrollbar->setTrackNeedsRepaint(true); |
433 break; | 434 break; |
434 case UIStateTransition: | 435 case UIStateTransition: |
435 [_scrollbarPainter.get() setUiStateTransitionProgress:currentValue]; | 436 [_scrollbarPainter.get() setUiStateTransitionProgress:currentValue]; |
| 437 _scrollbar->setThumbNeedsRepaint(true); |
| 438 _scrollbar->setTrackNeedsRepaint(true); |
436 break; | 439 break; |
437 case ExpansionTransition: | 440 case ExpansionTransition: |
438 [_scrollbarPainter.get() setExpansionTransitionProgress:currentValue]; | 441 [_scrollbarPainter.get() setExpansionTransitionProgress:currentValue]; |
| 442 _scrollbar->setThumbNeedsRepaint(true); |
439 break; | 443 break; |
440 } | 444 } |
441 | 445 |
442 _scrollbar->setNeedsPaintInvalidation(); | 446 _scrollbar->setNeedsPaintInvalidation(); |
443 } | 447 } |
444 | 448 |
445 - (void)invalidate | 449 - (void)invalidate |
446 { | 450 { |
447 BEGIN_BLOCK_OBJC_EXCEPTIONS; | 451 BEGIN_BLOCK_OBJC_EXCEPTIONS; |
448 [self stopAnimation]; | 452 [self stopAnimation]; |
449 END_BLOCK_OBJC_EXCEPTIONS; | 453 END_BLOCK_OBJC_EXCEPTIONS; |
450 _scrollbar = 0; | 454 _scrollbar = 0; |
451 } | 455 } |
452 | 456 |
453 @end | 457 @end |
454 | 458 |
455 @interface WebScrollbarPainterDelegate : NSObject<NSAnimationDelegate> | 459 @interface WebScrollbarPainterDelegate : NSObject<NSAnimationDelegate> |
456 { | 460 { |
457 blink::Scrollbar* _scrollbar; | 461 blink::Scrollbar* _scrollbar; |
458 | 462 |
459 RetainPtr<WebScrollbarPartAnimation> _knobAlphaAnimation; | 463 RetainPtr<WebScrollbarPartAnimation> _knobAlphaAnimation; |
460 RetainPtr<WebScrollbarPartAnimation> _trackAlphaAnimation; | 464 RetainPtr<WebScrollbarPartAnimation> _trackAlphaAnimation; |
461 RetainPtr<WebScrollbarPartAnimation> _uiStateTransitionAnimation; | 465 RetainPtr<WebScrollbarPartAnimation> _uiStateTransitionAnimation; |
462 RetainPtr<WebScrollbarPartAnimation> _expansionTransitionAnimation; | 466 RetainPtr<WebScrollbarPartAnimation> _expansionTransitionAnimation; |
| 467 BOOL _hasExpandedSinceInvisible; |
463 } | 468 } |
464 - (id)initWithScrollbar:(blink::Scrollbar*)scrollbar; | 469 - (id)initWithScrollbar:(blink::Scrollbar*)scrollbar; |
465 - (void)updateVisibilityImmediately:(bool)show; | 470 - (void)updateVisibilityImmediately:(bool)show; |
466 - (void)cancelAnimations; | 471 - (void)cancelAnimations; |
467 @end | 472 @end |
468 | 473 |
469 @implementation WebScrollbarPainterDelegate | 474 @implementation WebScrollbarPainterDelegate |
470 | 475 |
471 - (id)initWithScrollbar:(blink::Scrollbar*)scrollbar | 476 - (id)initWithScrollbar:(blink::Scrollbar*)scrollbar |
472 { | 477 { |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 // If we don't need to initialize the animation, just reset the values i
n case they have changed. | 640 // If we don't need to initialize the animation, just reset the values i
n case they have changed. |
636 [_expansionTransitionAnimation.get() setStartValue:[scrollbarPainter uiS
tateTransitionProgress]]; | 641 [_expansionTransitionAnimation.get() setStartValue:[scrollbarPainter uiS
tateTransitionProgress]]; |
637 [_expansionTransitionAnimation.get() setEndValue:1.0]; | 642 [_expansionTransitionAnimation.get() setEndValue:1.0]; |
638 [_expansionTransitionAnimation.get() setDuration:duration]; | 643 [_expansionTransitionAnimation.get() setDuration:duration]; |
639 } | 644 } |
640 [_expansionTransitionAnimation.get() startAnimation]; | 645 [_expansionTransitionAnimation.get() startAnimation]; |
641 } | 646 } |
642 | 647 |
643 - (void)scrollerImp:(id)scrollerImp overlayScrollerStateChangedTo:(NSUInteger)ne
wOverlayScrollerState | 648 - (void)scrollerImp:(id)scrollerImp overlayScrollerStateChangedTo:(NSUInteger)ne
wOverlayScrollerState |
644 { | 649 { |
| 650 // The names of these states are based on their observed behavior, and are n
ot based on documentation. |
| 651 enum { |
| 652 NSScrollerStateInvisible = 0, |
| 653 NSScrollerStateKnob = 1, |
| 654 NSScrollerStateExpanded = 2 |
| 655 }; |
| 656 // We do not receive notifications about the thumb un-expanding when the scr
ollbar fades away. Ensure |
| 657 // that we re-paint the thumb the next time that we transition away from bei
ng invisible, so that |
| 658 // the thumb doesn't stick in an expanded state. |
| 659 if (newOverlayScrollerState == NSScrollerStateExpanded) { |
| 660 _hasExpandedSinceInvisible = YES; |
| 661 } else if (newOverlayScrollerState != NSScrollerStateInvisible && _hasExpand
edSinceInvisible) { |
| 662 _scrollbar->setThumbNeedsRepaint(true); |
| 663 _hasExpandedSinceInvisible = NO; |
| 664 } |
645 } | 665 } |
646 | 666 |
647 - (void)invalidate | 667 - (void)invalidate |
648 { | 668 { |
649 _scrollbar = 0; | 669 _scrollbar = 0; |
650 BEGIN_BLOCK_OBJC_EXCEPTIONS; | 670 BEGIN_BLOCK_OBJC_EXCEPTIONS; |
651 [_knobAlphaAnimation.get() invalidate]; | 671 [_knobAlphaAnimation.get() invalidate]; |
652 [_trackAlphaAnimation.get() invalidate]; | 672 [_trackAlphaAnimation.get() invalidate]; |
653 [_uiStateTransitionAnimation.get() invalidate]; | 673 [_uiStateTransitionAnimation.get() invalidate]; |
654 [_expansionTransitionAnimation.get() invalidate]; | 674 [_expansionTransitionAnimation.get() invalidate]; |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 | 1082 |
1063 ScrollbarThemeMacOverlayAPI* macTheme = macOverlayScrollbarTheme(); | 1083 ScrollbarThemeMacOverlayAPI* macTheme = macOverlayScrollbarTheme(); |
1064 if (!macTheme) { | 1084 if (!macTheme) { |
1065 m_needsScrollerStyleUpdate = false; | 1085 m_needsScrollerStyleUpdate = false; |
1066 return; | 1086 return; |
1067 } | 1087 } |
1068 | 1088 |
1069 NSScrollerStyle newStyle = [m_scrollbarPainterController.get() scrollerStyle
]; | 1089 NSScrollerStyle newStyle = [m_scrollbarPainterController.get() scrollerStyle
]; |
1070 | 1090 |
1071 if (Scrollbar* verticalScrollbar = scrollableArea()->verticalScrollbar()) { | 1091 if (Scrollbar* verticalScrollbar = scrollableArea()->verticalScrollbar()) { |
| 1092 verticalScrollbar->setTrackNeedsRepaint(true); |
| 1093 verticalScrollbar->setThumbNeedsRepaint(true); |
1072 verticalScrollbar->setNeedsPaintInvalidation(); | 1094 verticalScrollbar->setNeedsPaintInvalidation(); |
1073 | 1095 |
1074 ScrollbarPainter oldVerticalPainter = [m_scrollbarPainterController.get(
) verticalScrollerImp]; | 1096 ScrollbarPainter oldVerticalPainter = [m_scrollbarPainterController.get(
) verticalScrollerImp]; |
1075 ScrollbarPainter newVerticalPainter = [NSClassFromString(@"NSScrollerImp
") scrollerImpWithStyle:newStyle | 1097 ScrollbarPainter newVerticalPainter = [NSClassFromString(@"NSScrollerImp
") scrollerImpWithStyle:newStyle |
1076
controlSize:(NSControlSize)verticalScrollbar->controlSize() | 1098
controlSize:(NSControlSize)verticalScrollbar->controlSize() |
1077
horizontal:NO | 1099
horizontal:NO |
1078
replacingScrollerImp:oldVerticalPainter]; | 1100
replacingScrollerImp:oldVerticalPainter]; |
1079 [m_scrollbarPainterController.get() setVerticalScrollerImp:newVerticalPa
inter]; | 1101 [m_scrollbarPainterController.get() setVerticalScrollerImp:newVerticalPa
inter]; |
1080 macTheme->setNewPainterForScrollbar(verticalScrollbar, newVerticalPainte
r); | 1102 macTheme->setNewPainterForScrollbar(verticalScrollbar, newVerticalPainte
r); |
1081 | 1103 |
1082 // The different scrollbar styles have different thicknesses, so we must
re-set the | 1104 // The different scrollbar styles have different thicknesses, so we must
re-set the |
1083 // frameRect to the new thickness, and the re-layout below will ensure t
he position | 1105 // frameRect to the new thickness, and the re-layout below will ensure t
he position |
1084 // and length are properly updated. | 1106 // and length are properly updated. |
1085 int thickness = macTheme->scrollbarThickness(verticalScrollbar->controlS
ize()); | 1107 int thickness = macTheme->scrollbarThickness(verticalScrollbar->controlS
ize()); |
1086 verticalScrollbar->setFrameRect(IntRect(0, 0, thickness, thickness)); | 1108 verticalScrollbar->setFrameRect(IntRect(0, 0, thickness, thickness)); |
1087 } | 1109 } |
1088 | 1110 |
1089 if (Scrollbar* horizontalScrollbar = scrollableArea()->horizontalScrollbar()
) { | 1111 if (Scrollbar* horizontalScrollbar = scrollableArea()->horizontalScrollbar()
) { |
| 1112 horizontalScrollbar->setTrackNeedsRepaint(true); |
| 1113 horizontalScrollbar->setThumbNeedsRepaint(true); |
1090 horizontalScrollbar->setNeedsPaintInvalidation(); | 1114 horizontalScrollbar->setNeedsPaintInvalidation(); |
1091 | 1115 |
1092 ScrollbarPainter oldHorizontalPainter = [m_scrollbarPainterController.ge
t() horizontalScrollerImp]; | 1116 ScrollbarPainter oldHorizontalPainter = [m_scrollbarPainterController.ge
t() horizontalScrollerImp]; |
1093 ScrollbarPainter newHorizontalPainter = [NSClassFromString(@"NSScrollerI
mp") scrollerImpWithStyle:newStyle | 1117 ScrollbarPainter newHorizontalPainter = [NSClassFromString(@"NSScrollerI
mp") scrollerImpWithStyle:newStyle |
1094
controlSize:(NSControlSize)horizontalScrollbar->controlSize() | 1118
controlSize:(NSControlSize)horizontalScrollbar->controlSize() |
1095
horizontal:YES | 1119
horizontal:YES |
1096
replacingScrollerImp:oldHorizontalPainter]; | 1120
replacingScrollerImp:oldHorizontalPainter]; |
1097 [m_scrollbarPainterController.get() setHorizontalScrollerImp:newHorizont
alPainter]; | 1121 [m_scrollbarPainterController.get() setHorizontalScrollerImp:newHorizont
alPainter]; |
1098 macTheme->setNewPainterForScrollbar(horizontalScrollbar, newHorizontalPa
inter); | 1122 macTheme->setNewPainterForScrollbar(horizontalScrollbar, newHorizontalPa
inter); |
1099 | 1123 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 return; | 1188 return; |
1165 | 1189 |
1166 m_visibleScrollerThumbRect = rectInViewCoordinates; | 1190 m_visibleScrollerThumbRect = rectInViewCoordinates; |
1167 } | 1191 } |
1168 | 1192 |
1169 bool ScrollAnimatorMac::canUseCoordinatedScrollbar() { | 1193 bool ScrollAnimatorMac::canUseCoordinatedScrollbar() { |
1170 return ScrollbarThemeMacCommon::isOverlayAPIAvailable(); | 1194 return ScrollbarThemeMacCommon::isOverlayAPIAvailable(); |
1171 } | 1195 } |
1172 | 1196 |
1173 } // namespace blink | 1197 } // namespace blink |
OLD | NEW |