Title: [172659] trunk/Source/WebCore
- Revision
- 172659
- Author
- commit-qu...@webkit.org
- Date
- 2014-08-15 16:35:21 -0700 (Fri, 15 Aug 2014)
Log Message
Fix gliding in AxisScrollSnapAnimator for Mac
https://bugs.webkit.org/show_bug.cgi?id=135971
Patch by Wenson Hsieh <wenson_hs...@apple.com> on 2014-08-15
Reviewed by Dean Jackson.
Previously, momentum events that are handled immediately after finishing a glide animation cause a second, extremely
slow glide animation to trigger. To fix this, I added a new state DestinationReached. During this state, additional
momentum events that are handled after the glide animation completes will not fill up the momentum window and trigger
a second glide event.
* platform/mac/AxisScrollSnapAnimator.h:
* platform/mac/AxisScrollSnapAnimator.mm:
(WebCore::AxisScrollSnapAnimator::AxisScrollSnapAnimator):
(WebCore::AxisScrollSnapAnimator::handleWheelEvent):
(WebCore::AxisScrollSnapAnimator::scrollSnapAnimationUpdate):
(WebCore::AxisScrollSnapAnimator::endScrollSnapAnimation):
(WebCore::AxisScrollSnapAnimator::computeGlideDelta):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (172658 => 172659)
--- trunk/Source/WebCore/ChangeLog 2014-08-15 23:19:44 UTC (rev 172658)
+++ trunk/Source/WebCore/ChangeLog 2014-08-15 23:35:21 UTC (rev 172659)
@@ -1,3 +1,23 @@
+2014-08-15 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Fix gliding in AxisScrollSnapAnimator for Mac
+ https://bugs.webkit.org/show_bug.cgi?id=135971
+
+ Reviewed by Dean Jackson.
+
+ Previously, momentum events that are handled immediately after finishing a glide animation cause a second, extremely
+ slow glide animation to trigger. To fix this, I added a new state DestinationReached. During this state, additional
+ momentum events that are handled after the glide animation completes will not fill up the momentum window and trigger
+ a second glide event.
+
+ * platform/mac/AxisScrollSnapAnimator.h:
+ * platform/mac/AxisScrollSnapAnimator.mm:
+ (WebCore::AxisScrollSnapAnimator::AxisScrollSnapAnimator):
+ (WebCore::AxisScrollSnapAnimator::handleWheelEvent):
+ (WebCore::AxisScrollSnapAnimator::scrollSnapAnimationUpdate):
+ (WebCore::AxisScrollSnapAnimator::endScrollSnapAnimation):
+ (WebCore::AxisScrollSnapAnimator::computeGlideDelta):
+
2014-08-15 Eric Carlson <eric.carl...@apple.com>
[MSE] Implement a maximum buffer size for SourceBuffer
Modified: trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.h (172658 => 172659)
--- trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.h 2014-08-15 23:19:44 UTC (rev 172658)
+++ trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.h 2014-08-15 23:35:21 UTC (rev 172659)
@@ -38,7 +38,8 @@
enum class ScrollSnapState {
Snapping,
Gliding,
- Idle
+ DestinationReached,
+ UserInteraction
};
enum class WheelEventStatus {
@@ -71,7 +72,7 @@
private:
void beginScrollSnapAnimation(ScrollSnapState);
- void endScrollSnapAnimation();
+ void endScrollSnapAnimation(ScrollSnapState);
float computeSnapDelta() const;
float computeGlideDelta() const;
Modified: trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.mm (172658 => 172659)
--- trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.mm 2014-08-15 23:19:44 UTC (rev 172658)
+++ trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.mm 2014-08-15 23:35:21 UTC (rev 172659)
@@ -86,7 +86,7 @@
: m_client(client)
, m_snapOffsets(snapOffsets)
, m_axis(axis)
- , m_currentState(ScrollSnapState::Idle)
+ , m_currentState(ScrollSnapState::DestinationReached)
, m_initialOffset(0)
, m_targetOffset(0)
, m_beginTrackingWheelDeltaOffset(0)
@@ -108,7 +108,7 @@
switch (wheelStatus) {
case WheelEventStatus::UserScrollBegin:
case WheelEventStatus::UserScrolling:
- endScrollSnapAnimation();
+ endScrollSnapAnimation(ScrollSnapState::UserInteraction);
break;
case WheelEventStatus::UserScrollEnd:
@@ -117,15 +117,15 @@
case WheelEventStatus::InertialScrollBegin:
// Begin tracking wheel deltas for glide prediction.
- endScrollSnapAnimation();
+ endScrollSnapAnimation(ScrollSnapState::UserInteraction);
pushInitialWheelDelta(wheelDelta);
m_beginTrackingWheelDeltaOffset = m_client->scrollOffsetInAxis(m_axis);
break;
case WheelEventStatus::InertialScrolling:
- if (m_currentState != ScrollSnapState::Gliding) {
- // FIXME: Investigate why small wheel deltas pushed into the window without the < -1, > 1 check.
- if (m_numWheelDeltasTracked < wheelDeltaWindowSize && (wheelDelta < -1 || wheelDelta > 1))
+ // This check for DestinationReached ensures that we don't receive another set of momentum events after ending the last glide.
+ if (m_currentState != ScrollSnapState::Gliding && m_currentState != ScrollSnapState::DestinationReached) {
+ if (m_numWheelDeltasTracked < wheelDeltaWindowSize)
pushInitialWheelDelta(wheelDelta);
if (m_numWheelDeltasTracked == wheelDeltaWindowSize)
@@ -155,10 +155,8 @@
float delta = m_currentState == ScrollSnapState::Snapping ? computeSnapDelta() : computeGlideDelta();
if (delta)
m_client->immediateScrollInAxis(m_axis, delta);
- else {
- endScrollSnapAnimation();
- m_currentState = ScrollSnapState::Idle;
- }
+ else
+ endScrollSnapAnimation(ScrollSnapState::DestinationReached);
}
void AxisScrollSnapAnimator::beginScrollSnapAnimation(ScrollSnapState newState)
@@ -189,12 +187,13 @@
m_client->startScrollSnapTimer();
}
-void AxisScrollSnapAnimator::endScrollSnapAnimation()
+void AxisScrollSnapAnimator::endScrollSnapAnimation(ScrollSnapState newState)
{
+ ASSERT(newState == ScrollSnapState::DestinationReached || newState == ScrollSnapState::UserInteraction);
if (m_currentState == ScrollSnapState::Gliding)
clearInitialWheelDeltaWindow();
- m_currentState = ScrollSnapState::Idle;
+ m_currentState = newState;
m_client->stopScrollSnapTimer();
}
@@ -245,7 +244,8 @@
return 0;
float progress = ((float)(offset - m_initialOffset)) / (m_targetOffset - m_initialOffset);
- float shift = ceil(m_glideMagnitude * (1 + cos(piFloat * progress + m_glidePhaseShift)));
+ // FIXME: We might want to investigate why -m_glidePhaseShift results in the behavior we want.
+ float shift = ceil(m_glideMagnitude * (1 + cos(piFloat * progress - m_glidePhaseShift)));
shift = m_initialOffset < m_targetOffset ? std::max<float>(shift, 1) : std::min<float>(shift, -1);
if ((m_initialOffset < m_targetOffset && offset + shift > m_targetOffset) || (m_initialOffset > m_targetOffset && offset + shift < m_targetOffset))
return m_targetOffset - offset;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes