Changeset 172659 in webkit
- Timestamp:
- Aug 15, 2014 4:35:21 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r172657 r172659 1 2014-08-15 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Fix gliding in AxisScrollSnapAnimator for Mac 4 https://bugs.webkit.org/show_bug.cgi?id=135971 5 6 Reviewed by Dean Jackson. 7 8 Previously, momentum events that are handled immediately after finishing a glide animation cause a second, extremely 9 slow glide animation to trigger. To fix this, I added a new state DestinationReached. During this state, additional 10 momentum events that are handled after the glide animation completes will not fill up the momentum window and trigger 11 a second glide event. 12 13 * platform/mac/AxisScrollSnapAnimator.h: 14 * platform/mac/AxisScrollSnapAnimator.mm: 15 (WebCore::AxisScrollSnapAnimator::AxisScrollSnapAnimator): 16 (WebCore::AxisScrollSnapAnimator::handleWheelEvent): 17 (WebCore::AxisScrollSnapAnimator::scrollSnapAnimationUpdate): 18 (WebCore::AxisScrollSnapAnimator::endScrollSnapAnimation): 19 (WebCore::AxisScrollSnapAnimator::computeGlideDelta): 20 1 21 2014-08-15 Eric Carlson <eric.carlson@apple.com> 2 22 -
trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.h
r172616 r172659 39 39 Snapping, 40 40 Gliding, 41 Idle 41 DestinationReached, 42 UserInteraction 42 43 }; 43 44 … … 72 73 private: 73 74 void beginScrollSnapAnimation(ScrollSnapState); 74 void endScrollSnapAnimation( );75 void endScrollSnapAnimation(ScrollSnapState); 75 76 76 77 float computeSnapDelta() const; -
trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.mm
r172649 r172659 87 87 , m_snapOffsets(snapOffsets) 88 88 , m_axis(axis) 89 , m_currentState(ScrollSnapState:: Idle)89 , m_currentState(ScrollSnapState::DestinationReached) 90 90 , m_initialOffset(0) 91 91 , m_targetOffset(0) … … 109 109 case WheelEventStatus::UserScrollBegin: 110 110 case WheelEventStatus::UserScrolling: 111 endScrollSnapAnimation( );111 endScrollSnapAnimation(ScrollSnapState::UserInteraction); 112 112 break; 113 113 … … 118 118 case WheelEventStatus::InertialScrollBegin: 119 119 // Begin tracking wheel deltas for glide prediction. 120 endScrollSnapAnimation( );120 endScrollSnapAnimation(ScrollSnapState::UserInteraction); 121 121 pushInitialWheelDelta(wheelDelta); 122 122 m_beginTrackingWheelDeltaOffset = m_client->scrollOffsetInAxis(m_axis); … … 124 124 125 125 case WheelEventStatus::InertialScrolling: 126 if (m_currentState != ScrollSnapState::Gliding) {127 // FIXME: Investigate why small wheel deltas pushed into the window without the < -1, > 1 check.128 if (m_numWheelDeltasTracked < wheelDeltaWindowSize && (wheelDelta < -1 || wheelDelta > 1))126 // This check for DestinationReached ensures that we don't receive another set of momentum events after ending the last glide. 127 if (m_currentState != ScrollSnapState::Gliding && m_currentState != ScrollSnapState::DestinationReached) { 128 if (m_numWheelDeltasTracked < wheelDeltaWindowSize) 129 129 pushInitialWheelDelta(wheelDelta); 130 130 … … 156 156 if (delta) 157 157 m_client->immediateScrollInAxis(m_axis, delta); 158 else { 159 endScrollSnapAnimation(); 160 m_currentState = ScrollSnapState::Idle; 161 } 158 else 159 endScrollSnapAnimation(ScrollSnapState::DestinationReached); 162 160 } 163 161 … … 190 188 } 191 189 192 void AxisScrollSnapAnimator::endScrollSnapAnimation() 193 { 190 void AxisScrollSnapAnimator::endScrollSnapAnimation(ScrollSnapState newState) 191 { 192 ASSERT(newState == ScrollSnapState::DestinationReached || newState == ScrollSnapState::UserInteraction); 194 193 if (m_currentState == ScrollSnapState::Gliding) 195 194 clearInitialWheelDeltaWindow(); 196 195 197 m_currentState = ScrollSnapState::Idle;196 m_currentState = newState; 198 197 m_client->stopScrollSnapTimer(); 199 198 } … … 246 245 247 246 float progress = ((float)(offset - m_initialOffset)) / (m_targetOffset - m_initialOffset); 248 float shift = ceil(m_glideMagnitude * (1 + cos(piFloat * progress + m_glidePhaseShift))); 247 // FIXME: We might want to investigate why -m_glidePhaseShift results in the behavior we want. 248 float shift = ceil(m_glideMagnitude * (1 + cos(piFloat * progress - m_glidePhaseShift))); 249 249 shift = m_initialOffset < m_targetOffset ? std::max<float>(shift, 1) : std::min<float>(shift, -1); 250 250 if ((m_initialOffset < m_targetOffset && offset + shift > m_targetOffset) || (m_initialOffset > m_targetOffset && offset + shift < m_targetOffset))
Note: See TracChangeset
for help on using the changeset viewer.