Changeset 96644 in webkit
- Timestamp:
- Oct 4, 2011 2:18:53 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r96643 r96644 1 2011-10-04 Anders Carlsson <andersca@apple.com> 2 3 Add a ScrollElasticityController class and move some members over from ScrollAnimatorMac 4 https://bugs.webkit.org/show_bug.cgi?id=69373 5 6 Reviewed by David Hyatt. 7 8 ScrollElasticityController is a new class that will handle the rubber-banding when handling scroll events. 9 10 * WebCore.xcodeproj/project.pbxproj: 11 * platform/mac/ScrollAnimatorMac.h: 12 * platform/mac/ScrollAnimatorMac.mm: 13 (WebCore::ScrollAnimatorMac::ScrollAnimatorMac): 14 (WebCore::ScrollAnimatorMac::handleWheelEvent): 15 (WebCore::ScrollAnimatorMac::smoothScrollWithEvent): 16 (WebCore::ScrollAnimatorMac::beginScrollGesture): 17 (WebCore::ScrollAnimatorMac::snapRubberBand): 18 (WebCore::ScrollAnimatorMac::snapRubberBandTimerFired): 19 * platform/mac/ScrollElasticityController.h: Added. 20 (WebCore::ScrollElasticityControllerClient::~ScrollElasticityControllerClient): 21 * platform/mac/ScrollElasticityController.mm: Added. 22 (WebCore::ScrollElasticityController::ScrollElasticityController): 23 1 24 2011-10-04 David Hyatt <hyatt@apple.com> 2 25 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r96545 r96644 444 444 1A927FD41416A15B003A83C8 /* nptypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A927FD11416A15B003A83C8 /* nptypes.h */; settings = {ATTRIBUTES = (Private, ); }; }; 445 445 1A98956B0AA78F80005EF5EF /* KURLCFNet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A98956A0AA78F80005EF5EF /* KURLCFNet.cpp */; }; 446 1AA84F04143BA7BD0051D153 /* ScrollElasticityController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA84F02143BA7BD0051D153 /* ScrollElasticityController.mm */; }; 447 1AA84F05143BA7BD0051D153 /* ScrollElasticityController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA84F03143BA7BD0051D153 /* ScrollElasticityController.h */; }; 446 448 1AA8799011CBE846003C664F /* PluginStrategy.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA8798F11CBE846003C664F /* PluginStrategy.h */; settings = {ATTRIBUTES = (Private, ); }; }; 447 449 1AB1AE7A0C051FDE00139F4F /* zoomInCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AB1AE780C051FDE00139F4F /* zoomInCursor.png */; }; … … 6986 6988 1A927FD11416A15B003A83C8 /* nptypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nptypes.h; sourceTree = "<group>"; }; 6987 6989 1A98956A0AA78F80005EF5EF /* KURLCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = KURLCFNet.cpp; sourceTree = "<group>"; }; 6990 1AA84F02143BA7BD0051D153 /* ScrollElasticityController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollElasticityController.mm; sourceTree = "<group>"; }; 6991 1AA84F03143BA7BD0051D153 /* ScrollElasticityController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollElasticityController.h; sourceTree = "<group>"; }; 6988 6992 1AA8798F11CBE846003C664F /* PluginStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginStrategy.h; sourceTree = "<group>"; }; 6989 6993 1AB1AE780C051FDE00139F4F /* zoomInCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = zoomInCursor.png; sourceTree = "<group>"; }; … … 14602 14606 BCAE1FA512939DB7004CB026 /* ScrollAnimatorMac.h */, 14603 14607 BC51156D12B1749C00C96754 /* ScrollAnimatorMac.mm */, 14608 1AA84F03143BA7BD0051D153 /* ScrollElasticityController.h */, 14609 1AA84F02143BA7BD0051D153 /* ScrollElasticityController.mm */, 14604 14610 BC8B853C0E7C7F1100AB6984 /* ScrollbarThemeMac.h */, 14605 14611 BCEF869E0E844E9D00A85CD5 /* ScrollbarThemeMac.mm */, … … 23549 23555 BCEB179C143379F50052EAE9 /* RenderBoxRegionInfo.h in Headers */, 23550 23556 59102FBC14327D3B003C9D04 /* ContentSearchUtils.h in Headers */, 23557 1AA84F05143BA7BD0051D153 /* ScrollElasticityController.h in Headers */, 23551 23558 ); 23552 23559 runOnlyForDeploymentPostprocessing = 0; … … 26389 26396 319AE069142D78DD006563A1 /* FilterOperations.cpp in Sources */, 26390 26397 59102FBB14327D3B003C9D04 /* ContentSearchUtils.cpp in Sources */, 26398 1AA84F04143BA7BD0051D153 /* ScrollElasticityController.mm in Sources */, 26391 26399 ); 26392 26400 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h
r96639 r96644 33 33 #include "FloatSize.h" 34 34 #include "ScrollAnimator.h" 35 #include "ScrollElasticityController.h" 35 36 #include "Timer.h" 36 37 #include <wtf/RetainPtr.h> … … 50 51 #endif 51 52 53 #if !ENABLE(RUBBER_BANDING) 54 class ScrollElasticityControllerClient { }; 55 #endif 56 52 57 namespace WebCore { 53 58 54 59 class Scrollbar; 55 60 56 class ScrollAnimatorMac : public ScrollAnimator { 61 class ScrollAnimatorMac : public ScrollAnimator, private ScrollElasticityControllerClient { 62 57 63 public: 58 64 ScrollAnimatorMac(ScrollableArea*); … … 142 148 void endScrollGesture(); 143 149 144 bool m_inScrollGesture; 145 bool m_momentumScrollInProgress; 146 bool m_ignoreMomentumScrolls; 147 bool m_scrollerInitiallyPinnedOnLeft; 148 bool m_scrollerInitiallyPinnedOnRight; 150 ScrollElasticityController m_scrollElasticityController; 151 149 152 int m_cumulativeHorizontalScroll; 150 153 bool m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin; -
trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm
r96639 r96644 459 459 #endif 460 460 #if ENABLE(RUBBER_BANDING) 461 , m_inScrollGesture(false) 462 , m_momentumScrollInProgress(false) 463 , m_ignoreMomentumScrolls(false) 461 , m_scrollElasticityController(this) 464 462 , m_lastMomentumScrollTimestamp(0) 465 463 , m_startTime(0) … … 819 817 // and we ended up scrolling to the right, we rubber band. 820 818 m_cumulativeHorizontalScroll += wheelEvent.deltaX(); 821 if (m_scroll erInitiallyPinnedOnLeft && m_cumulativeHorizontalScroll < 0)819 if (m_scrollElasticityController.m_scrollerInitiallyPinnedOnLeft && m_cumulativeHorizontalScroll < 0) 822 820 m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = true; 823 if (m_scroll erInitiallyPinnedOnRight && m_cumulativeHorizontalScroll > 0)821 if (m_scrollElasticityController.m_scrollerInitiallyPinnedOnRight && m_cumulativeHorizontalScroll > 0) 824 822 m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = true; 825 823 } … … 831 829 if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseNone && !m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin) { 832 830 if ((isScrollingLeftAndShouldNotRubberBand(wheelEvent, m_scrollableArea) && 833 m_scroll erInitiallyPinnedOnLeft &&831 m_scrollElasticityController.m_scrollerInitiallyPinnedOnLeft && 834 832 m_scrollableArea->isHorizontalScrollerPinnedToMinimumPosition()) || 835 833 (isScrollingRightAndShouldNotRubberBand(wheelEvent, m_scrollableArea) && 836 m_scroll erInitiallyPinnedOnRight &&834 m_scrollElasticityController.m_scrollerInitiallyPinnedOnRight && 837 835 m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition())) { 838 836 return ScrollAnimator::handleWheelEvent(wheelEvent); … … 842 840 843 841 bool isMomentumScrollEvent = (wheelEvent.momentumPhase() != PlatformWheelEventPhaseNone); 844 if (m_ ignoreMomentumScrolls && (isMomentumScrollEvent || m_snapRubberBandTimer.isActive())) {842 if (m_scrollElasticityController.m_ignoreMomentumScrolls && (isMomentumScrollEvent || m_snapRubberBandTimer.isActive())) { 845 843 if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded) { 846 m_ ignoreMomentumScrolls = false;844 m_scrollElasticityController.m_ignoreMomentumScrolls = false; 847 845 return true; 848 846 } … … 958 956 959 957 // If we are starting momentum scrolling then do some setup. 960 if (!m_ momentumScrollInProgress && (phase == PlatformWheelEventPhaseBegan || phase == PlatformWheelEventPhaseChanged))961 m_ momentumScrollInProgress = true;958 if (!m_scrollElasticityController.m_momentumScrollInProgress && (phase == PlatformWheelEventPhaseBegan || phase == PlatformWheelEventPhaseChanged)) 959 m_scrollElasticityController.m_momentumScrollInProgress = true; 962 960 963 961 CFTimeInterval timeDelta = wheelEvent.timestamp() - m_lastMomentumScrollTimestamp; 964 if (m_ inScrollGesture ||m_momentumScrollInProgress) {962 if (m_scrollElasticityController.m_inScrollGesture || m_scrollElasticityController.m_momentumScrollInProgress) { 965 963 if (m_lastMomentumScrollTimestamp && timeDelta > 0 && timeDelta < scrollVelocityZeroingTimeout) { 966 964 m_momentumVelocity.setWidth(eventCoalescedDeltaX / (float)timeDelta); … … 1048 1046 IntSize stretchAmount = m_scrollableArea->overhangAmount(); 1049 1047 1050 if (m_ momentumScrollInProgress) {1048 if (m_scrollElasticityController.m_momentumScrollInProgress) { 1051 1049 if ((pinnedInDirection(eventCoalescedDeltaX, eventCoalescedDeltaY) || (fabsf(eventCoalescedDeltaX) + fabsf(eventCoalescedDeltaY) <= 0)) && m_lastMomentumScrollTimestamp) { 1052 m_ ignoreMomentumScrolls = true;1053 m_ momentumScrollInProgress = false;1050 m_scrollElasticityController.m_ignoreMomentumScrolls = true; 1051 m_scrollElasticityController.m_momentumScrollInProgress = false; 1054 1052 snapRubberBand(); 1055 1053 } … … 1071 1069 } 1072 1070 1073 if (m_ momentumScrollInProgress && phase == PlatformWheelEventPhaseEnded) {1074 m_ momentumScrollInProgress = false;1075 m_ ignoreMomentumScrolls = false;1071 if (m_scrollElasticityController.m_momentumScrollInProgress && phase == PlatformWheelEventPhaseEnded) { 1072 m_scrollElasticityController.m_momentumScrollInProgress = false; 1073 m_scrollElasticityController.m_ignoreMomentumScrolls = false; 1076 1074 m_lastMomentumScrollTimestamp = 0; 1077 1075 } … … 1083 1081 1084 1082 m_haveScrolledSincePageLoad = true; 1085 m_ inScrollGesture = true;1086 m_ momentumScrollInProgress = false;1087 m_ ignoreMomentumScrolls = false;1083 m_scrollElasticityController.m_inScrollGesture = true; 1084 m_scrollElasticityController.m_momentumScrollInProgress = false; 1085 m_scrollElasticityController.m_ignoreMomentumScrolls = false; 1088 1086 m_lastMomentumScrollTimestamp = 0; 1089 1087 m_momentumVelocity = FloatSize(); 1090 m_scroll erInitiallyPinnedOnLeft = m_scrollableArea->isHorizontalScrollerPinnedToMinimumPosition();1091 m_scroll erInitiallyPinnedOnRight = m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition();1088 m_scrollElasticityController.m_scrollerInitiallyPinnedOnLeft = m_scrollableArea->isHorizontalScrollerPinnedToMinimumPosition(); 1089 m_scrollElasticityController.m_scrollerInitiallyPinnedOnRight = m_scrollableArea->isHorizontalScrollerPinnedToMaximumPosition(); 1092 1090 m_cumulativeHorizontalScroll = 0; 1093 1091 m_didCumulativeHorizontalScrollEverSwitchToOppositeDirectionOfPin = false; … … 1116 1114 m_momentumVelocity = FloatSize(); 1117 1115 1118 m_ inScrollGesture = false;1116 m_scrollElasticityController.m_inScrollGesture = false; 1119 1117 1120 1118 if (m_snapRubberBandTimer.isActive()) … … 1145 1143 void ScrollAnimatorMac::snapRubberBandTimerFired(Timer<ScrollAnimatorMac>*) 1146 1144 { 1147 if (!m_ momentumScrollInProgress ||m_ignoreMomentumScrolls) {1145 if (!m_scrollElasticityController.m_momentumScrollInProgress || m_scrollElasticityController.m_ignoreMomentumScrolls) { 1148 1146 CFTimeInterval timeDelta = [NSDate timeIntervalSinceReferenceDate] - m_startTime; 1149 1147
Note: See TracChangeset
for help on using the changeset viewer.