Chromium Code Reviews| 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->postDelayedCancellableTask( |
| 1072 BLINK_FROM_HERE, m_initialScrollbarPaintTaskFactory->cancelAndCreate(), | 1066 BLINK_FROM_HERE, WTF::bind(&ScrollAnimatorMac::initialScrollbarPaintTask, |
| 1067 wrapWeakPersistent(this)), | |
|
nhiroki
2016/11/21 05:45:54
Can we make this wrapPersistent(this)? I'm assumin
haraken
2016/11/21 06:42:24
It's called by a pre-finalizer:
https://cs.chromi
nhiroki
2016/11/21 08:15:16
Thank you for the clarification :)
| |
| 1073 0.1); | 1068 0.1); |
|
nhiroki
2016/11/21 05:45:54
This fails compile on Mac bots as follows:
[29712
haraken
2016/11/21 06:42:24
Yeah, 0.1 looks like a random number. +1 to changi
nhiroki
2016/11/21 08:15:16
Done.
| |
| 1074 } | 1069 } |
| 1075 | 1070 |
| 1076 bool ScrollAnimatorMac::scrollbarPaintTimerIsActive() const { | 1071 bool ScrollAnimatorMac::scrollbarPaintTimerIsActive() const { |
| 1077 return m_initialScrollbarPaintTaskFactory->isPending(); | 1072 return m_initialScrollbarPaintTaskHandle.isActive(); |
| 1078 } | 1073 } |
| 1079 | 1074 |
| 1080 void ScrollAnimatorMac::stopScrollbarPaintTimer() { | 1075 void ScrollAnimatorMac::stopScrollbarPaintTimer() { |
| 1081 m_initialScrollbarPaintTaskFactory->cancel(); | 1076 m_initialScrollbarPaintTaskHandle.cancel(); |
| 1082 } | 1077 } |
| 1083 | 1078 |
| 1084 void ScrollAnimatorMac::initialScrollbarPaintTask() { | 1079 void ScrollAnimatorMac::initialScrollbarPaintTask() { |
| 1085 // To force the scrollbars to flash, we have to call hide first. Otherwise, | 1080 // To force the scrollbars to flash, we have to call hide first. Otherwise, |
| 1086 // the ScrollbarPainterController | 1081 // the ScrollbarPainterController |
| 1087 // might think that the scrollbars are already showing and bail early. | 1082 // might think that the scrollbars are already showing and bail early. |
| 1088 [m_scrollbarPainterController.get() hideOverlayScrollers]; | 1083 [m_scrollbarPainterController.get() hideOverlayScrollers]; |
| 1089 [m_scrollbarPainterController.get() flashScrollers]; | 1084 [m_scrollbarPainterController.get() flashScrollers]; |
| 1090 } | 1085 } |
| 1091 | 1086 |
| 1092 void ScrollAnimatorMac::sendContentAreaScrolledSoon(const ScrollOffset& delta) { | 1087 void ScrollAnimatorMac::sendContentAreaScrolledSoon(const ScrollOffset& delta) { |
| 1093 m_contentAreaScrolledTimerScrollDelta = delta; | 1088 m_contentAreaScrolledTimerScrollDelta = delta; |
| 1094 | 1089 |
| 1095 if (!m_sendContentAreaScrolledTaskFactory->isPending()) | 1090 if (m_sendContentAreaScrolledTaskHandle.isActive()) |
| 1096 m_taskRunner->postTask( | 1091 return; |
| 1097 BLINK_FROM_HERE, | 1092 m_sendContentAreaScrolledTaskHandle = m_taskRunner->postCancellableTask( |
| 1098 m_sendContentAreaScrolledTaskFactory->cancelAndCreate()); | 1093 BLINK_FROM_HERE, |
| 1094 WTF::bind(&ScrollAnimatorMac::sendContentAreaScrolledTask, | |
| 1095 wrapWeakPersistent(this))); | |
|
nhiroki
2016/11/21 05:45:54
ditto.
| |
| 1099 } | 1096 } |
| 1100 | 1097 |
| 1101 void ScrollAnimatorMac::sendContentAreaScrolledTask() { | 1098 void ScrollAnimatorMac::sendContentAreaScrolledTask() { |
| 1102 if (supportsContentAreaScrolledInDirection()) { | 1099 if (supportsContentAreaScrolledInDirection()) { |
| 1103 [m_scrollbarPainterController.get() | 1100 [m_scrollbarPainterController.get() |
| 1104 contentAreaScrolledInDirection:NSMakePoint( | 1101 contentAreaScrolledInDirection:NSMakePoint( |
| 1105 m_contentAreaScrolledTimerScrollDelta | 1102 m_contentAreaScrolledTimerScrollDelta |
| 1106 .width(), | 1103 .width(), |
| 1107 m_contentAreaScrolledTimerScrollDelta | 1104 m_contentAreaScrolledTimerScrollDelta |
| 1108 .height())]; | 1105 .height())]; |
| 1109 m_contentAreaScrolledTimerScrollDelta = ScrollOffset(); | 1106 m_contentAreaScrolledTimerScrollDelta = ScrollOffset(); |
| 1110 } else | 1107 } else |
| 1111 [m_scrollbarPainterController.get() contentAreaScrolled]; | 1108 [m_scrollbarPainterController.get() contentAreaScrolled]; |
| 1112 } | 1109 } |
| 1113 | 1110 |
| 1114 void ScrollAnimatorMac::setVisibleScrollerThumbRect( | 1111 void ScrollAnimatorMac::setVisibleScrollerThumbRect( |
| 1115 const IntRect& scrollerThumb) { | 1112 const IntRect& scrollerThumb) { |
| 1116 IntRect rectInViewCoordinates = scrollerThumb; | 1113 IntRect rectInViewCoordinates = scrollerThumb; |
| 1117 if (Scrollbar* verticalScrollbar = m_scrollableArea->verticalScrollbar()) | 1114 if (Scrollbar* verticalScrollbar = m_scrollableArea->verticalScrollbar()) |
| 1118 rectInViewCoordinates = | 1115 rectInViewCoordinates = |
| 1119 verticalScrollbar->convertToContainingWidget(scrollerThumb); | 1116 verticalScrollbar->convertToContainingWidget(scrollerThumb); |
| 1120 | 1117 |
| 1121 if (rectInViewCoordinates == m_visibleScrollerThumbRect) | 1118 if (rectInViewCoordinates == m_visibleScrollerThumbRect) |
| 1122 return; | 1119 return; |
| 1123 | 1120 |
| 1124 m_visibleScrollerThumbRect = rectInViewCoordinates; | 1121 m_visibleScrollerThumbRect = rectInViewCoordinates; |
| 1125 } | 1122 } |
| 1126 | 1123 |
| 1127 } // namespace blink | 1124 } // namespace blink |
| OLD | NEW |