| 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 WTF::WrapUnique(new BlinkScrollbarPartAnimationTimer(self, duration)); | 368 WTF::WrapUnique(new BlinkScrollbarPartAnimationTimer(self, duration)); |
| 369 _scrollbar = scrollbar; | 369 _scrollbar = scrollbar; |
| 370 _featureToAnimate = featureToAnimate; | 370 _featureToAnimate = featureToAnimate; |
| 371 _startValue = startValue; | 371 _startValue = startValue; |
| 372 _endValue = endValue; | 372 _endValue = endValue; |
| 373 | 373 |
| 374 return self; | 374 return self; |
| 375 } | 375 } |
| 376 | 376 |
| 377 - (void)startAnimation { | 377 - (void)startAnimation { |
| 378 ASSERT(_scrollbar); | 378 DCHECK(_scrollbar); |
| 379 | 379 |
| 380 _scrollbarPainter = scrollbarPainterForScrollbar(*_scrollbar); | 380 _scrollbarPainter = scrollbarPainterForScrollbar(*_scrollbar); |
| 381 _timer->Start(); | 381 _timer->Start(); |
| 382 } | 382 } |
| 383 | 383 |
| 384 - (void)stopAnimation { | 384 - (void)stopAnimation { |
| 385 _timer->Stop(); | 385 _timer->Stop(); |
| 386 } | 386 } |
| 387 | 387 |
| 388 - (void)setDuration:(CFTimeInterval)duration { | 388 - (void)setDuration:(CFTimeInterval)duration { |
| 389 _timer->SetDuration(duration); | 389 _timer->SetDuration(duration); |
| 390 } | 390 } |
| 391 | 391 |
| 392 - (void)setStartValue:(CGFloat)startValue { | 392 - (void)setStartValue:(CGFloat)startValue { |
| 393 _startValue = startValue; | 393 _startValue = startValue; |
| 394 } | 394 } |
| 395 | 395 |
| 396 - (void)setEndValue:(CGFloat)endValue { | 396 - (void)setEndValue:(CGFloat)endValue { |
| 397 _endValue = endValue; | 397 _endValue = endValue; |
| 398 } | 398 } |
| 399 | 399 |
| 400 - (void)setCurrentProgress:(NSAnimationProgress)progress { | 400 - (void)setCurrentProgress:(NSAnimationProgress)progress { |
| 401 ASSERT(_scrollbar); | 401 DCHECK(_scrollbar); |
| 402 | 402 |
| 403 CGFloat currentValue; | 403 CGFloat currentValue; |
| 404 if (_startValue > _endValue) | 404 if (_startValue > _endValue) |
| 405 currentValue = 1 - progress; | 405 currentValue = 1 - progress; |
| 406 else | 406 else |
| 407 currentValue = progress; | 407 currentValue = progress; |
| 408 | 408 |
| 409 ScrollbarPart invalidParts = kNoPart; | 409 ScrollbarPart invalidParts = kNoPart; |
| 410 switch (_featureToAnimate) { | 410 switch (_featureToAnimate) { |
| 411 case ThumbAlpha: | 411 case ThumbAlpha: |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 | 795 |
| 796 ScrollOffset delta = adjusted_offset - current_offset_; | 796 ScrollOffset delta = adjusted_offset - current_offset_; |
| 797 | 797 |
| 798 current_offset_ = adjusted_offset; | 798 current_offset_ = adjusted_offset; |
| 799 NotifyContentAreaScrolled(delta, kUserScroll); | 799 NotifyContentAreaScrolled(delta, kUserScroll); |
| 800 NotifyOffsetChanged(); | 800 NotifyOffsetChanged(); |
| 801 } | 801 } |
| 802 | 802 |
| 803 void ScrollAnimatorMac::ImmediateScrollToOffsetForScrollAnimation( | 803 void ScrollAnimatorMac::ImmediateScrollToOffsetForScrollAnimation( |
| 804 const ScrollOffset& new_offset) { | 804 const ScrollOffset& new_offset) { |
| 805 ASSERT(scroll_animation_helper_); | 805 DCHECK(scroll_animation_helper_); |
| 806 ImmediateScrollTo(new_offset); | 806 ImmediateScrollTo(new_offset); |
| 807 } | 807 } |
| 808 | 808 |
| 809 void ScrollAnimatorMac::ContentAreaWillPaint() const { | 809 void ScrollAnimatorMac::ContentAreaWillPaint() const { |
| 810 if (!GetScrollableArea()->ScrollbarsCanBeActive()) | 810 if (!GetScrollableArea()->ScrollbarsCanBeActive()) |
| 811 return; | 811 return; |
| 812 [scrollbar_painter_controller_.Get() contentAreaWillDraw]; | 812 [scrollbar_painter_controller_.Get() contentAreaWillDraw]; |
| 813 } | 813 } |
| 814 | 814 |
| 815 void ScrollAnimatorMac::MouseEnteredContentArea() const { | 815 void ScrollAnimatorMac::MouseEnteredContentArea() const { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 | 870 |
| 871 void ScrollAnimatorMac::FinishCurrentScrollAnimations() { | 871 void ScrollAnimatorMac::FinishCurrentScrollAnimations() { |
| 872 [scrollbar_painter_controller_.Get() hideOverlayScrollers]; | 872 [scrollbar_painter_controller_.Get() hideOverlayScrollers]; |
| 873 } | 873 } |
| 874 | 874 |
| 875 void ScrollAnimatorMac::DidAddVerticalScrollbar(Scrollbar& scrollbar) { | 875 void ScrollAnimatorMac::DidAddVerticalScrollbar(Scrollbar& scrollbar) { |
| 876 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); | 876 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); |
| 877 if (!painter) | 877 if (!painter) |
| 878 return; | 878 return; |
| 879 | 879 |
| 880 ASSERT(!vertical_scrollbar_painter_delegate_); | 880 DCHECK(!vertical_scrollbar_painter_delegate_); |
| 881 vertical_scrollbar_painter_delegate_.AdoptNS( | 881 vertical_scrollbar_painter_delegate_.AdoptNS( |
| 882 [[BlinkScrollbarPainterDelegate alloc] initWithScrollbar:&scrollbar]); | 882 [[BlinkScrollbarPainterDelegate alloc] initWithScrollbar:&scrollbar]); |
| 883 | 883 |
| 884 [painter setDelegate:vertical_scrollbar_painter_delegate_.Get()]; | 884 [painter setDelegate:vertical_scrollbar_painter_delegate_.Get()]; |
| 885 [scrollbar_painter_controller_.Get() setVerticalScrollerImp:painter]; | 885 [scrollbar_painter_controller_.Get() setVerticalScrollerImp:painter]; |
| 886 } | 886 } |
| 887 | 887 |
| 888 void ScrollAnimatorMac::WillRemoveVerticalScrollbar(Scrollbar& scrollbar) { | 888 void ScrollAnimatorMac::WillRemoveVerticalScrollbar(Scrollbar& scrollbar) { |
| 889 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); | 889 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); |
| 890 if (!painter) | 890 if (!painter) |
| 891 return; | 891 return; |
| 892 | 892 |
| 893 ASSERT(vertical_scrollbar_painter_delegate_); | 893 DCHECK(vertical_scrollbar_painter_delegate_); |
| 894 [vertical_scrollbar_painter_delegate_.Get() invalidate]; | 894 [vertical_scrollbar_painter_delegate_.Get() invalidate]; |
| 895 vertical_scrollbar_painter_delegate_ = nullptr; | 895 vertical_scrollbar_painter_delegate_ = nullptr; |
| 896 | 896 |
| 897 [painter setDelegate:nil]; | 897 [painter setDelegate:nil]; |
| 898 [scrollbar_painter_controller_.Get() setVerticalScrollerImp:nil]; | 898 [scrollbar_painter_controller_.Get() setVerticalScrollerImp:nil]; |
| 899 } | 899 } |
| 900 | 900 |
| 901 void ScrollAnimatorMac::DidAddHorizontalScrollbar(Scrollbar& scrollbar) { | 901 void ScrollAnimatorMac::DidAddHorizontalScrollbar(Scrollbar& scrollbar) { |
| 902 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); | 902 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); |
| 903 if (!painter) | 903 if (!painter) |
| 904 return; | 904 return; |
| 905 | 905 |
| 906 ASSERT(!horizontal_scrollbar_painter_delegate_); | 906 DCHECK(!horizontal_scrollbar_painter_delegate_); |
| 907 horizontal_scrollbar_painter_delegate_.AdoptNS( | 907 horizontal_scrollbar_painter_delegate_.AdoptNS( |
| 908 [[BlinkScrollbarPainterDelegate alloc] initWithScrollbar:&scrollbar]); | 908 [[BlinkScrollbarPainterDelegate alloc] initWithScrollbar:&scrollbar]); |
| 909 | 909 |
| 910 [painter setDelegate:horizontal_scrollbar_painter_delegate_.Get()]; | 910 [painter setDelegate:horizontal_scrollbar_painter_delegate_.Get()]; |
| 911 [scrollbar_painter_controller_.Get() setHorizontalScrollerImp:painter]; | 911 [scrollbar_painter_controller_.Get() setHorizontalScrollerImp:painter]; |
| 912 } | 912 } |
| 913 | 913 |
| 914 void ScrollAnimatorMac::WillRemoveHorizontalScrollbar(Scrollbar& scrollbar) { | 914 void ScrollAnimatorMac::WillRemoveHorizontalScrollbar(Scrollbar& scrollbar) { |
| 915 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); | 915 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); |
| 916 if (!painter) | 916 if (!painter) |
| 917 return; | 917 return; |
| 918 | 918 |
| 919 ASSERT(horizontal_scrollbar_painter_delegate_); | 919 DCHECK(horizontal_scrollbar_painter_delegate_); |
| 920 [horizontal_scrollbar_painter_delegate_.Get() invalidate]; | 920 [horizontal_scrollbar_painter_delegate_.Get() invalidate]; |
| 921 horizontal_scrollbar_painter_delegate_ = nullptr; | 921 horizontal_scrollbar_painter_delegate_ = nullptr; |
| 922 | 922 |
| 923 [painter setDelegate:nil]; | 923 [painter setDelegate:nil]; |
| 924 [scrollbar_painter_controller_.Get() setHorizontalScrollerImp:nil]; | 924 [scrollbar_painter_controller_.Get() setHorizontalScrollerImp:nil]; |
| 925 } | 925 } |
| 926 | 926 |
| 927 void ScrollAnimatorMac::NotifyContentAreaScrolled(const ScrollOffset& delta, | 927 void ScrollAnimatorMac::NotifyContentAreaScrolled(const ScrollOffset& delta, |
| 928 ScrollType scrollType) { | 928 ScrollType scrollType) { |
| 929 // This function is called when a page is going into the page cache, but the | 929 // This function is called when a page is going into the page cache, but the |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 rect_in_view_coordinates = | 1083 rect_in_view_coordinates = |
| 1084 vertical_scrollbar->ConvertToContainingFrameViewBase(scroller_thumb); | 1084 vertical_scrollbar->ConvertToContainingFrameViewBase(scroller_thumb); |
| 1085 | 1085 |
| 1086 if (rect_in_view_coordinates == visible_scroller_thumb_rect_) | 1086 if (rect_in_view_coordinates == visible_scroller_thumb_rect_) |
| 1087 return; | 1087 return; |
| 1088 | 1088 |
| 1089 visible_scroller_thumb_rect_ = rect_in_view_coordinates; | 1089 visible_scroller_thumb_rect_ = rect_in_view_coordinates; |
| 1090 } | 1090 } |
| 1091 | 1091 |
| 1092 } // namespace blink | 1092 } // namespace blink |
| OLD | NEW |