| 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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 @end | 685 @end |
| 686 | 686 |
| 687 namespace blink { | 687 namespace blink { |
| 688 | 688 |
| 689 ScrollAnimatorBase* ScrollAnimatorBase::create(ScrollableArea* scrollableArea) { | 689 ScrollAnimatorBase* ScrollAnimatorBase::create(ScrollableArea* scrollableArea) { |
| 690 return new ScrollAnimatorMac(scrollableArea); | 690 return new ScrollAnimatorMac(scrollableArea); |
| 691 } | 691 } |
| 692 | 692 |
| 693 ScrollAnimatorMac::ScrollAnimatorMac(ScrollableArea* scrollableArea) | 693 ScrollAnimatorMac::ScrollAnimatorMac(ScrollableArea* scrollableArea) |
| 694 : ScrollAnimatorBase(scrollableArea), | 694 : ScrollAnimatorBase(scrollableArea), |
| 695 m_initialScrollbarPaintTaskFactory(CancellableTaskFactory::create( | |
| 696 this, | |
| 697 &ScrollAnimatorMac::initialScrollbarPaintTask)), | |
| 698 m_sendContentAreaScrolledTaskFactory(CancellableTaskFactory::create( | |
| 699 this, | |
| 700 &ScrollAnimatorMac::sendContentAreaScrolledTask)), | |
| 701 m_taskRunner(Platform::current() | 695 m_taskRunner(Platform::current() |
| 702 ->currentThread() | 696 ->currentThread() |
| 703 ->scheduler() | 697 ->scheduler() |
| 704 ->timerTaskRunner() | 698 ->timerTaskRunner() |
| 705 ->clone()), | 699 ->clone()), |
| 706 m_haveScrolledSincePageLoad(false), | 700 m_haveScrolledSincePageLoad(false), |
| 707 m_needsScrollerStyleUpdate(false) { | 701 m_needsScrollerStyleUpdate(false) { |
| 708 ThreadState::current()->registerPreFinalizer(this); | 702 ThreadState::current()->registerPreFinalizer(this); |
| 709 | 703 |
| 710 m_scrollAnimationHelperDelegate.adoptNS( | 704 m_scrollAnimationHelperDelegate.adoptNS( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 729 | 723 |
| 730 void ScrollAnimatorMac::dispose() { | 724 void ScrollAnimatorMac::dispose() { |
| 731 BEGIN_BLOCK_OBJC_EXCEPTIONS; | 725 BEGIN_BLOCK_OBJC_EXCEPTIONS; |
| 732 [m_scrollbarPainterControllerDelegate.get() invalidate]; | 726 [m_scrollbarPainterControllerDelegate.get() invalidate]; |
| 733 [m_scrollbarPainterController.get() setDelegate:nil]; | 727 [m_scrollbarPainterController.get() setDelegate:nil]; |
| 734 [m_horizontalScrollbarPainterDelegate.get() invalidate]; | 728 [m_horizontalScrollbarPainterDelegate.get() invalidate]; |
| 735 [m_verticalScrollbarPainterDelegate.get() invalidate]; | 729 [m_verticalScrollbarPainterDelegate.get() invalidate]; |
| 736 [m_scrollAnimationHelperDelegate.get() invalidate]; | 730 [m_scrollAnimationHelperDelegate.get() invalidate]; |
| 737 END_BLOCK_OBJC_EXCEPTIONS; | 731 END_BLOCK_OBJC_EXCEPTIONS; |
| 738 | 732 |
| 739 m_initialScrollbarPaintTaskFactory->cancel(); | 733 m_initialScrollbarPaintTaskHandle.cancel(); |
| 740 m_sendContentAreaScrolledTaskFactory->cancel(); | 734 m_sendContentAreaScrolledTaskHandle.cancel(); |
| 741 } | 735 } |
| 742 | 736 |
| 743 ScrollResult ScrollAnimatorMac::userScroll(ScrollGranularity granularity, | 737 ScrollResult ScrollAnimatorMac::userScroll(ScrollGranularity granularity, |
| 744 const ScrollOffset& delta) { | 738 const ScrollOffset& delta) { |
| 745 m_haveScrolledSincePageLoad = true; | 739 m_haveScrolledSincePageLoad = true; |
| 746 | 740 |
| 747 if (!m_scrollableArea->scrollAnimatorEnabled()) | 741 if (!m_scrollableArea->scrollAnimatorEnabled()) |
| 748 return ScrollAnimatorBase::userScroll(granularity, delta); | 742 return ScrollAnimatorBase::userScroll(granularity, delta); |
| 749 | 743 |
| 750 if (granularity == ScrollByPixel || granularity == ScrollByPrecisePixel) | 744 if (granularity == ScrollByPixel || granularity == ScrollByPrecisePixel) |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 // page cache, and | 1055 // page cache, and |
| 1062 // a relayout will happen on its own. Otherwise, we must initiate a re-layout | 1056 // a relayout will happen on its own. Otherwise, we must initiate a re-layout |
| 1063 // ourselves. | 1057 // ourselves. |
| 1064 if (!m_needsScrollerStyleUpdate) | 1058 if (!m_needsScrollerStyleUpdate) |
| 1065 getScrollableArea()->scrollbarStyleChanged(); | 1059 getScrollableArea()->scrollbarStyleChanged(); |
| 1066 | 1060 |
| 1067 m_needsScrollerStyleUpdate = false; | 1061 m_needsScrollerStyleUpdate = false; |
| 1068 } | 1062 } |
| 1069 | 1063 |
| 1070 void ScrollAnimatorMac::startScrollbarPaintTimer() { | 1064 void ScrollAnimatorMac::startScrollbarPaintTimer() { |
| 1071 m_taskRunner->postDelayedTask( | 1065 m_initialScrollbarPaintTaskHandle = m_taskRunner->postCancellableTask( |
| 1072 BLINK_FROM_HERE, m_initialScrollbarPaintTaskFactory->cancelAndCreate(), | 1066 BLINK_FROM_HERE, WTF::bind(&ScrollAnimatorMac::initialScrollbarPaintTask, |
| 1073 0.1); | 1067 wrapWeakPersistent(this))); |
| 1074 } | 1068 } |
| 1075 | 1069 |
| 1076 bool ScrollAnimatorMac::scrollbarPaintTimerIsActive() const { | 1070 bool ScrollAnimatorMac::scrollbarPaintTimerIsActive() const { |
| 1077 return m_initialScrollbarPaintTaskFactory->isPending(); | 1071 return m_initialScrollbarPaintTaskHandle.isActive(); |
| 1078 } | 1072 } |
| 1079 | 1073 |
| 1080 void ScrollAnimatorMac::stopScrollbarPaintTimer() { | 1074 void ScrollAnimatorMac::stopScrollbarPaintTimer() { |
| 1081 m_initialScrollbarPaintTaskFactory->cancel(); | 1075 m_initialScrollbarPaintTaskHandle.cancel(); |
| 1082 } | 1076 } |
| 1083 | 1077 |
| 1084 void ScrollAnimatorMac::initialScrollbarPaintTask() { | 1078 void ScrollAnimatorMac::initialScrollbarPaintTask() { |
| 1085 // To force the scrollbars to flash, we have to call hide first. Otherwise, | 1079 // To force the scrollbars to flash, we have to call hide first. Otherwise, |
| 1086 // the ScrollbarPainterController | 1080 // the ScrollbarPainterController |
| 1087 // might think that the scrollbars are already showing and bail early. | 1081 // might think that the scrollbars are already showing and bail early. |
| 1088 [m_scrollbarPainterController.get() hideOverlayScrollers]; | 1082 [m_scrollbarPainterController.get() hideOverlayScrollers]; |
| 1089 [m_scrollbarPainterController.get() flashScrollers]; | 1083 [m_scrollbarPainterController.get() flashScrollers]; |
| 1090 } | 1084 } |
| 1091 | 1085 |
| 1092 void ScrollAnimatorMac::sendContentAreaScrolledSoon(const ScrollOffset& delta) { | 1086 void ScrollAnimatorMac::sendContentAreaScrolledSoon(const ScrollOffset& delta) { |
| 1093 m_contentAreaScrolledTimerScrollDelta = delta; | 1087 m_contentAreaScrolledTimerScrollDelta = delta; |
| 1094 | 1088 |
| 1095 if (!m_sendContentAreaScrolledTaskFactory->isPending()) | 1089 if (m_sendContentAreaScrolledTaskHandle.isActive()) |
| 1096 m_taskRunner->postTask( | 1090 return; |
| 1097 BLINK_FROM_HERE, | 1091 m_sendContentAreaScrolledTaskHandle = m_taskRunner->postCancellableTask( |
| 1098 m_sendContentAreaScrolledTaskFactory->cancelAndCreate()); | 1092 BLINK_FROM_HERE, |
| 1093 WTF::bind(&ScrollAnimatorMac::sendContentAreaScrolledTask, |
| 1094 wrapWeakPersistent(this))); |
| 1099 } | 1095 } |
| 1100 | 1096 |
| 1101 void ScrollAnimatorMac::sendContentAreaScrolledTask() { | 1097 void ScrollAnimatorMac::sendContentAreaScrolledTask() { |
| 1102 if (supportsContentAreaScrolledInDirection()) { | 1098 if (supportsContentAreaScrolledInDirection()) { |
| 1103 [m_scrollbarPainterController.get() | 1099 [m_scrollbarPainterController.get() |
| 1104 contentAreaScrolledInDirection:NSMakePoint( | 1100 contentAreaScrolledInDirection:NSMakePoint( |
| 1105 m_contentAreaScrolledTimerScrollDelta | 1101 m_contentAreaScrolledTimerScrollDelta |
| 1106 .width(), | 1102 .width(), |
| 1107 m_contentAreaScrolledTimerScrollDelta | 1103 m_contentAreaScrolledTimerScrollDelta |
| 1108 .height())]; | 1104 .height())]; |
| 1109 m_contentAreaScrolledTimerScrollDelta = ScrollOffset(); | 1105 m_contentAreaScrolledTimerScrollDelta = ScrollOffset(); |
| 1110 } else | 1106 } else |
| 1111 [m_scrollbarPainterController.get() contentAreaScrolled]; | 1107 [m_scrollbarPainterController.get() contentAreaScrolled]; |
| 1112 } | 1108 } |
| 1113 | 1109 |
| 1114 void ScrollAnimatorMac::setVisibleScrollerThumbRect( | 1110 void ScrollAnimatorMac::setVisibleScrollerThumbRect( |
| 1115 const IntRect& scrollerThumb) { | 1111 const IntRect& scrollerThumb) { |
| 1116 IntRect rectInViewCoordinates = scrollerThumb; | 1112 IntRect rectInViewCoordinates = scrollerThumb; |
| 1117 if (Scrollbar* verticalScrollbar = m_scrollableArea->verticalScrollbar()) | 1113 if (Scrollbar* verticalScrollbar = m_scrollableArea->verticalScrollbar()) |
| 1118 rectInViewCoordinates = | 1114 rectInViewCoordinates = |
| 1119 verticalScrollbar->convertToContainingWidget(scrollerThumb); | 1115 verticalScrollbar->convertToContainingWidget(scrollerThumb); |
| 1120 | 1116 |
| 1121 if (rectInViewCoordinates == m_visibleScrollerThumbRect) | 1117 if (rectInViewCoordinates == m_visibleScrollerThumbRect) |
| 1122 return; | 1118 return; |
| 1123 | 1119 |
| 1124 m_visibleScrollerThumbRect = rectInViewCoordinates; | 1120 m_visibleScrollerThumbRect = rectInViewCoordinates; |
| 1125 } | 1121 } |
| 1126 | 1122 |
| 1127 } // namespace blink | 1123 } // namespace blink |
| OLD | NEW |