Changeset 89066 in webkit
- Timestamp:
- Jun 16, 2011 2:20:52 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r89065 r89066 1 2011-06-16 Sailesh Agrawal <sail@chromium.org> 2 3 Reviewed by Mihai Parparita. 4 5 [Chromium] Update forked ScrollAnimatorChromiumMac.mm/h 6 https://bugs.webkit.org/show_bug.cgi?id=62779 7 8 Updated ScrollAnimatorChromiumMac.mm/h with the latest code in WebCore/platform/mac/ScrollAnimatorMac.mm/h 9 10 * platform/chromium/ScrollAnimatorChromiumMac.h: 11 (WebCore::ScrollAnimatorChromiumMac::setNeedsScrollerStyleUpdate): 12 (WebCore::ScrollAnimatorChromiumMac::needsScrollerStyleUpdate): 13 * platform/chromium/ScrollAnimatorChromiumMac.mm: 14 (-[ScrollAnimationHelperDelegate _immediateScrollToPoint:]): 15 (-[ScrollbarPainterControllerDelegate scrollerImpPair:updateScrollerStyleForNewRecommendedScrollerStyle:]): 16 (WebCore::ScrollAnimatorChromiumMac::ScrollAnimatorChromiumMac): 17 (WebCore::ScrollAnimatorChromiumMac::scroll): 18 (WebCore::ScrollAnimatorChromiumMac::immediateScrollToPointForScrollAnimation): 19 (WebCore::isScrollingLeftAndShouldNotRubberBand): 20 (WebCore::isScrollingRightAndShouldNotRubberBand): 21 (WebCore::ScrollAnimatorChromiumMac::handleWheelEvent): 22 (WebCore::ScrollAnimatorChromiumMac::smoothScrollWithEvent): 23 (WebCore::ScrollAnimatorChromiumMac::beginScrollGesture): 24 (WebCore::ScrollAnimatorChromiumMac::snapRubberBand): 25 (WebCore::ScrollAnimatorChromiumMac::snapRubberBandTimerFired): 26 (WebCore::ScrollAnimatorChromiumMac::setIsActive): 27 (WebCore::ScrollAnimatorChromiumMac::updateScrollerStyle): 28 * platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.h: 29 * platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm: 30 (wkScrollbarPainterControllerStyle): 31 1 32 2011-06-16 Sailesh Agrawal <sail@chromium.org> 2 33 -
trunk/Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.h
r89016 r89066 72 72 void immediateScrollByDeltaY(float deltaY); 73 73 74 void immediateScrollToPointForScrollAnimation(const FloatPoint& newPosition); 75 74 76 void setIsDrawingIntoLayer(bool b) { m_drawingIntoLayer = b; } 75 77 bool isDrawingIntoLayer() const { return m_drawingIntoLayer; } … … 77 79 bool haveScrolledSincePageLoad() const { return m_haveScrolledSincePageLoad; } 78 80 81 virtual void setIsActive(); 82 79 83 #if USE(WK_SCROLLBAR_PAINTER) 84 void updateScrollerStyle(); 85 80 86 bool scrollbarPaintTimerIsActive() const; 81 87 void startScrollbarPaintTimer(); … … 116 122 virtual void willRemoveHorizontalScrollbar(Scrollbar*); 117 123 124 void setNeedsScrollerStyleUpdate(bool needsUpdate) { m_needsScrollerStyleUpdate = needsUpdate; } 125 bool needsScrollerStyleUpdate() const { return m_needsScrollerStyleUpdate; } 126 118 127 float adjustScrollXPositionIfNecessary(float) const; 119 128 float adjustScrollYPositionIfNecessary(float) const; … … 133 142 bool m_momentumScrollInProgress; 134 143 bool m_ignoreMomentumScrolls; 135 136 CFTimeInterval m_lastMomemtumScrollTimestamp; 144 145 bool m_scrollerInitiallyPinnedOnLeft; 146 bool m_scrollerInitiallyPinnedOnRight; 147 int m_cumulativeHorizontalScroll; 148 bool m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin; 149 150 CFTimeInterval m_lastMomentumScrollTimestamp; 137 151 FloatSize m_overflowScrollDelta; 138 152 FloatSize m_stretchScrollForce; … … 148 162 bool m_drawingIntoLayer; 149 163 bool m_haveScrolledSincePageLoad; 164 bool m_needsScrollerStyleUpdate; 150 165 IntRect m_visibleScrollerThumbRect; 151 166 }; -
trunk/Source/WebCore/platform/chromium/ScrollAnimatorChromiumMac.mm
r89016 r89066 57 57 - (BOOL)_isAnimating; 58 58 - (NSPoint)targetOrigin; 59 - (CGFloat)_progress; 59 60 @end 60 61 … … 106 107 if (!_animator) 107 108 return; 108 _animator->immediateScrollToPoint (newPosition);109 _animator->immediateScrollToPointForScrollAnimation(newPosition); 109 110 } 110 111 … … 243 244 return; 244 245 245 WKScrollbarPainterControllerRef painterController = (WKScrollbarPainterControllerRef)scrollerImpPair; 246 WebCore::ScrollbarThemeChromiumMac* macTheme = (WebCore::ScrollbarThemeChromiumMac*)WebCore::ScrollbarTheme::nativeTheme(); 247 248 WKScrollbarPainterRef oldVerticalPainter = wkVerticalScrollbarPainterForController(painterController); 249 if (oldVerticalPainter) { 250 WebCore::Scrollbar* verticalScrollbar = _animator->scrollableArea()->verticalScrollbar(); 251 WKScrollbarPainterRef newVerticalPainter = wkMakeScrollbarReplacementPainter(oldVerticalPainter, 252 newRecommendedScrollerStyle, 253 verticalScrollbar->controlSize(), 254 false); 255 macTheme->setNewPainterForScrollbar(verticalScrollbar, newVerticalPainter); 256 wkSetPainterForPainterController(painterController, newVerticalPainter, false); 257 258 // The different scrollbar styles have different thicknesses, so we must re-set the 259 // frameRect to the new thickness, and the re-layout below will ensure the position 260 // and length are properly updated. 261 int thickness = macTheme->scrollbarThickness(verticalScrollbar->controlSize()); 262 verticalScrollbar->setFrameRect(WebCore::IntRect(0, 0, thickness, thickness)); 263 } 264 265 WKScrollbarPainterRef oldHorizontalPainter = wkHorizontalScrollbarPainterForController(painterController); 266 if (oldHorizontalPainter) { 267 WebCore::Scrollbar* horizontalScrollbar = _animator->scrollableArea()->horizontalScrollbar(); 268 WKScrollbarPainterRef newHorizontalPainter = wkMakeScrollbarReplacementPainter(oldHorizontalPainter, 269 newRecommendedScrollerStyle, 270 horizontalScrollbar->controlSize(), 271 true); 272 macTheme->setNewPainterForScrollbar(horizontalScrollbar, newHorizontalPainter); 273 wkSetPainterForPainterController(painterController, newHorizontalPainter, true); 274 275 // The different scrollbar styles have different thicknesses, so we must re-set the 276 // frameRect to the new thickness, and the re-layout below will ensure the position 277 // and length are properly updated. 278 int thickness = macTheme->scrollbarThickness(horizontalScrollbar->controlSize()); 279 horizontalScrollbar->setFrameRect(WebCore::IntRect(0, 0, thickness, thickness)); 280 } 281 282 wkSetScrollbarPainterControllerStyle(painterController, newRecommendedScrollerStyle); 283 284 // The different scrollbar styles affect layout, so we must re-layout everything. 285 _animator->scrollableArea()->scrollbarStyleChanged(); 246 wkSetScrollbarPainterControllerStyle((WKScrollbarPainterControllerRef)scrollerImpPair, newRecommendedScrollerStyle); 247 _animator->updateScrollerStyle(); 286 248 } 287 249 … … 507 469 , m_momentumScrollInProgress(false) 508 470 , m_ignoreMomentumScrolls(false) 509 , m_lastMome mtumScrollTimestamp(0)471 , m_lastMomentumScrollTimestamp(0) 510 472 , m_startTime(0) 511 473 , m_snapRubberBandTimer(this, &ScrollAnimatorChromiumMac::snapRubberBandTimerFired) … … 513 475 , m_drawingIntoLayer(false) 514 476 , m_haveScrolledSincePageLoad(false) 477 , m_needsScrollerStyleUpdate(false) 515 478 { 516 479 m_scrollAnimationHelperDelegate.adoptNS([[ScrollAnimationHelperDelegate alloc] initWithScrollAnimator:this]); … … 557 520 NSPoint targetOrigin = [m_scrollAnimationHelper.get() targetOrigin]; 558 521 newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, targetOrigin.y) : NSMakePoint(targetOrigin.x, newPos); 559 } else 522 } else { 560 523 newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, m_currentPosY) : NSMakePoint(m_currentPosX, newPos); 561 524 m_scrollableArea->didStartAnimatedScroll(); 525 } 562 526 [m_scrollAnimationHelper.get() scrollToPoint:newPoint]; 563 527 return true; … … 629 593 m_currentPosY = newPosY; 630 594 notityPositionChanged(); 595 } 596 597 void ScrollAnimatorChromiumMac::immediateScrollToPointForScrollAnimation(const FloatPoint& newPosition) 598 { 599 ASSERT(m_scrollAnimationHelper); 600 CGFloat progress = [m_scrollAnimationHelper.get() _progress]; 601 602 immediateScrollToPoint(newPosition); 603 604 if (progress >= 1.0) 605 m_scrollableArea->didCompleteAnimatedScroll(); 631 606 } 632 607 … … 793 768 } 794 769 return multiplier; 770 } 771 772 static inline bool isScrollingLeftAndShouldNotRubberBand(PlatformWheelEvent& wheelEvent, ScrollableArea* scrollableArea) 773 { 774 return wheelEvent.deltaX() > 0 && !scrollableArea->shouldRubberBandInDirection(ScrollLeft); 775 } 776 777 static inline bool isScrollingRightAndShouldNotRubberBand(PlatformWheelEvent& wheelEvent, ScrollableArea* scrollableArea) 778 { 779 return wheelEvent.deltaX() < 0 && !scrollableArea->shouldRubberBandInDirection(ScrollRight); 795 780 } 796 781 … … 818 803 return; 819 804 } 805 806 if (m_scrollableArea->horizontalScrollbar()) { 807 // If there is a scrollbar, we aggregate the wheel events to get an 808 // overall trend of the scroll. If the direction of the scroll is ever 809 // in the opposite direction of the pin location, then we switch the 810 // boolean, and rubber band. That is, if we were pinned to the left, 811 // and we ended up scrolling to the right, we rubber band. 812 m_cumulativeHorizontalScroll += wheelEvent.deltaX(); 813 if (m_scrollerInitiallyPinnedOnLeft && m_cumulativeHorizontalScroll < 0) 814 m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = true; 815 if (m_scrollerInitiallyPinnedOnRight && m_cumulativeHorizontalScroll > 0) 816 m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = true; 817 } 818 819 // After a gesture begins, we go through: 820 // 1+ PlatformWheelEventPhaseNone 821 // 0+ PlatformWheelEventPhaseChanged 822 // 1 PlatformWheelEventPhaseEnded if there was at least one changed event 823 if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseNone && !m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin) { 824 if ((isScrollingLeftAndShouldNotRubberBand(wheelEvent, m_scrollableArea) && 825 m_scrollerInitiallyPinnedOnLeft && 826 m_scrollableArea->isHorizontalScrollerPinnedToMinimumPosition()) || 827 (isScrollingRightAndShouldNotRubberBand(wheelEvent, m_scrollableArea) && 828 m_scrollerInitiallyPinnedOnRight && 829 m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition())) { 830 ScrollAnimator::handleWheelEvent(wheelEvent); 831 return; 832 } 833 } 834 } 835 836 bool isMomentumScrollEvent = (wheelEvent.momentumPhase() != PlatformWheelEventPhaseNone); 837 if (m_ignoreMomentumScrolls && (isMomentumScrollEvent || m_snapRubberBandTimer.isActive())) { 838 if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded) { 839 m_ignoreMomentumScrolls = false; 840 wheelEvent.accept(); 841 } 842 return; 820 843 } 821 844 822 845 wheelEvent.accept(); 823 824 bool isMometumScrollEvent = (wheelEvent.momentumPhase() != PlatformWheelEventPhaseNone);825 if (m_ignoreMomentumScrolls && (isMometumScrollEvent || m_snapRubberBandTimer.isActive())) {826 if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded)827 m_ignoreMomentumScrolls = false;828 return;829 }830 831 846 smoothScrollWithEvent(wheelEvent); 832 847 } … … 912 927 m_overflowScrollDelta = FloatSize(); 913 928 914 float eventCoal lescedDeltaX = -wheelEvent.deltaX();915 float eventCoal lescedDeltaY = -wheelEvent.deltaY();916 917 deltaX += eventCoal lescedDeltaX;918 deltaY += eventCoal lescedDeltaY;929 float eventCoalescedDeltaX = -wheelEvent.deltaX(); 930 float eventCoalescedDeltaY = -wheelEvent.deltaY(); 931 932 deltaX += eventCoalescedDeltaX; 933 deltaY += eventCoalescedDeltaY; 919 934 920 935 // Slightly prefer scrolling vertically by applying the = case to deltaY … … 939 954 m_momentumScrollInProgress = true; 940 955 941 CFTimeInterval timeDelta = wheelEvent.timestamp() - m_lastMome mtumScrollTimestamp;956 CFTimeInterval timeDelta = wheelEvent.timestamp() - m_lastMomentumScrollTimestamp; 942 957 if (m_inScrollGesture || m_momentumScrollInProgress) { 943 if (m_lastMome mtumScrollTimestamp && timeDelta > 0 && timeDelta < scrollVelocityZeroingTimeout) {944 m_momentumVelocity.setWidth(eventCoal lescedDeltaX / (float)timeDelta);945 m_momentumVelocity.setHeight(eventCoal lescedDeltaY / (float)timeDelta);946 m_lastMome mtumScrollTimestamp = wheelEvent.timestamp();958 if (m_lastMomentumScrollTimestamp && timeDelta > 0 && timeDelta < scrollVelocityZeroingTimeout) { 959 m_momentumVelocity.setWidth(eventCoalescedDeltaX / (float)timeDelta); 960 m_momentumVelocity.setHeight(eventCoalescedDeltaY / (float)timeDelta); 961 m_lastMomentumScrollTimestamp = wheelEvent.timestamp(); 947 962 } else { 948 m_lastMome mtumScrollTimestamp = wheelEvent.timestamp();963 m_lastMomentumScrollTimestamp = wheelEvent.timestamp(); 949 964 m_momentumVelocity = FloatSize(); 950 965 } … … 1000 1015 if (!allowsHorizontalStretching()) { 1001 1016 deltaX = 0; 1002 eventCoal lescedDeltaX = 0;1017 eventCoalescedDeltaX = 0; 1003 1018 } else if ((deltaX != 0) && !isHorizontallyStretched && !pinnedInDirection(deltaX, 0)) { 1004 1019 deltaX *= scrollWheelMultiplier(); … … 1013 1028 if (!allowsVerticalStretching()) { 1014 1029 deltaY = 0; 1015 eventCoal lescedDeltaY = 0;1030 eventCoalescedDeltaY = 0; 1016 1031 } else if ((deltaY != 0) && !isVerticallyStretched && !pinnedInDirection(0, deltaY)) { 1017 1032 deltaY *= scrollWheelMultiplier(); … … 1027 1042 1028 1043 if (m_momentumScrollInProgress) { 1029 if ((pinnedInDirection(eventCoal lescedDeltaX, eventCoallescedDeltaY) || (fabsf(eventCoallescedDeltaX) + fabsf(eventCoallescedDeltaY) <= 0)) && m_lastMomemtumScrollTimestamp) {1044 if ((pinnedInDirection(eventCoalescedDeltaX, eventCoalescedDeltaY) || (fabsf(eventCoalescedDeltaX) + fabsf(eventCoalescedDeltaY) <= 0)) && m_lastMomentumScrollTimestamp) { 1030 1045 m_ignoreMomentumScrolls = true; 1031 1046 m_momentumScrollInProgress = false; … … 1052 1067 m_momentumScrollInProgress = false; 1053 1068 m_ignoreMomentumScrolls = false; 1054 m_lastMome mtumScrollTimestamp = 0;1069 m_lastMomentumScrollTimestamp = 0; 1055 1070 } 1056 1071 } … … 1064 1079 m_momentumScrollInProgress = false; 1065 1080 m_ignoreMomentumScrolls = false; 1066 m_lastMome mtumScrollTimestamp = 0;1081 m_lastMomentumScrollTimestamp = 0; 1067 1082 m_momentumVelocity = FloatSize(); 1068 1083 m_scrollerInitiallyPinnedOnLeft = m_scrollableArea->isHorizontalScrollerPinnedToMinimumPosition(); 1084 m_scrollerInitiallyPinnedOnRight = m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition(); 1085 m_cumulativeHorizontalScroll = 0; 1086 m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = false; 1087 1069 1088 IntSize stretchAmount = m_scrollableArea->overhangAmount(); 1070 1089 m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(stretchAmount.width())); … … 1086 1105 void ScrollAnimatorChromiumMac::snapRubberBand() 1087 1106 { 1088 CFTimeInterval timeDelta = [[NSProcessInfo processInfo] systemUptime] - m_lastMome mtumScrollTimestamp;1089 if (m_lastMome mtumScrollTimestamp && timeDelta >= scrollVelocityZeroingTimeout)1107 CFTimeInterval timeDelta = [[NSProcessInfo processInfo] systemUptime] - m_lastMomentumScrollTimestamp; 1108 if (m_lastMomentumScrollTimestamp && timeDelta >= scrollVelocityZeroingTimeout) 1090 1109 m_momentumVelocity = FloatSize(); 1091 1110 … … 1134 1153 return; 1135 1154 } 1155 1156 m_scrollableArea->didStartRubberBand(roundedIntSize(m_startStretch)); 1136 1157 1137 1158 m_origOrigin = (m_scrollableArea->visibleContentRect().location() + m_scrollableArea->scrollOrigin()) - m_startStretch; … … 1187 1208 #endif 1188 1209 1210 void ScrollAnimatorChromiumMac::setIsActive() 1211 { 1212 if (isScrollbarOverlayAPIAvailable()) { 1213 if (needsScrollerStyleUpdate()) 1214 updateScrollerStyle(); 1215 } 1216 } 1217 1189 1218 #if USE(WK_SCROLLBAR_PAINTER) 1219 void ScrollAnimatorChromiumMac::updateScrollerStyle() 1220 { 1221 if (!scrollableArea()->isOnActivePage()) { 1222 setNeedsScrollerStyleUpdate(true); 1223 return; 1224 } 1225 1226 ScrollbarThemeChromiumMac* macTheme = (ScrollbarThemeChromiumMac*)ScrollbarTheme::nativeTheme(); 1227 int newStyle = wkScrollbarPainterControllerStyle(m_scrollbarPainterController.get()); 1228 1229 if (Scrollbar* verticalScrollbar = scrollableArea()->verticalScrollbar()) { 1230 verticalScrollbar->invalidate(); 1231 1232 WKScrollbarPainterRef oldVerticalPainter = wkVerticalScrollbarPainterForController(m_scrollbarPainterController.get()); 1233 WKScrollbarPainterRef newVerticalPainter = wkMakeScrollbarReplacementPainter(oldVerticalPainter, 1234 newStyle, 1235 verticalScrollbar->controlSize(), 1236 false); 1237 macTheme->setNewPainterForScrollbar(verticalScrollbar, newVerticalPainter); 1238 wkSetPainterForPainterController(m_scrollbarPainterController.get(), newVerticalPainter, false); 1239 1240 // The different scrollbar styles have different thicknesses, so we must re-set the 1241 // frameRect to the new thickness, and the re-layout below will ensure the position 1242 // and length are properly updated. 1243 int thickness = macTheme->scrollbarThickness(verticalScrollbar->controlSize()); 1244 verticalScrollbar->setFrameRect(IntRect(0, 0, thickness, thickness)); 1245 } 1246 1247 if (Scrollbar* horizontalScrollbar = scrollableArea()->horizontalScrollbar()) { 1248 horizontalScrollbar->invalidate(); 1249 1250 WKScrollbarPainterRef oldHorizontalPainter = wkHorizontalScrollbarPainterForController(m_scrollbarPainterController.get()); 1251 WKScrollbarPainterRef newHorizontalPainter = wkMakeScrollbarReplacementPainter(oldHorizontalPainter, 1252 newStyle, 1253 horizontalScrollbar->controlSize(), 1254 true); 1255 macTheme->setNewPainterForScrollbar(horizontalScrollbar, newHorizontalPainter); 1256 wkSetPainterForPainterController(m_scrollbarPainterController.get(), newHorizontalPainter, true); 1257 1258 // The different scrollbar styles have different thicknesses, so we must re-set the 1259 // frameRect to the new thickness, and the re-layout below will ensure the position 1260 // and length are properly updated. 1261 int thickness = macTheme->scrollbarThickness(horizontalScrollbar->controlSize()); 1262 horizontalScrollbar->setFrameRect(IntRect(0, 0, thickness, thickness)); 1263 } 1264 1265 // If needsScrollerStyleUpdate() is true, then the page is restoring from the page cache, and 1266 // a relayout will happen on its own. Otherwise, we must initiate a re-layout ourselves. 1267 if (!needsScrollerStyleUpdate()) 1268 scrollableArea()->scrollbarStyleChanged(); 1269 1270 setNeedsScrollerStyleUpdate(false); 1271 } 1272 1190 1273 void ScrollAnimatorChromiumMac::startScrollbarPaintTimer() 1191 1274 { -
trunk/Source/WebCore/platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.h
r89016 r89066 96 96 WKScrollbarPainterRef wkVerticalScrollbarPainterForController(WKScrollbarPainterControllerRef); 97 97 WKScrollbarPainterRef wkHorizontalScrollbarPainterForController(WKScrollbarPainterControllerRef); 98 NSScrollerStyle wkScrollbarPainterControllerStyle(WKScrollbarPainterControllerRef); 98 99 99 100 #endif // USE(WK_SCROLLBAR_PAINTER) -
trunk/Source/WebCore/platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm
r89065 r89066 209 209 } 210 210 211 NSScrollerStyle wkScrollbarPainterControllerStyle(WKScrollbarPainterControllerRef controller) 212 { 213 return [controller scrollerStyle]; 214 } 215 211 216 WKScrollbarPainterRef wkMakeScrollbarReplacementPainter(WKScrollbarPainterRef oldPainter, int newStyle, int controlSize, bool isHorizontal) 212 217 {
Note: See TracChangeset
for help on using the changeset viewer.