<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[181087] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/181087">181087</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2015-03-05 11:32:27 -0800 (Thu, 05 Mar 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Move AxisScrollSnapAnimator logic to ScrollController
https://bugs.webkit.org/show_bug.cgi?id=142293
<rdar://problem/20039867>
Reviewed by Dean Jackson.
No change in function.
Move the animation logic out of 'AxisScrollSnapAnimator' into 'ScrollController'. Rename the remaining
bits of 'AxisScrollSnapAnimator' as 'ScrollSnapAnimatorState'. Remove a number of delegate methods required
by 'AxisScrollSnapAnimatorClient' that are no longer needed.
Also, break up some of the Scroll Snap Point math to be a little easier to understand.
* WebCore.xcodeproj/project.pbxproj: Rename 'platform/mac/AxisScrollSnapAnimator.{h,mm}' -> 'platform/cocoa/ScrollSnapAnimatorState.h'
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h: Mark 'scrollOffsetOnAxis' as const.
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
(WebCore::ScrollingTreeFrameScrollingNodeMac::scrollOffsetOnAxis): Make 'const'
* platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::scrollOffsetOnAxis): Make 'const'
* platform/ScrollAnimator.h:
* platform/cocoa/ScrollController.h: No longer subclass from AxisScrollSnapAnimatorClient.
* platform/cocoa/ScrollController.mm:
(WebCore::ScrollController::scrollSnapPointState): Added accessors (const and non-const) for the individual
Scroll Snap State of each axis.
(WebCore::toWheelEventStatus): Moved from AxisScrollSnapAnimator.
(WebCore::ScrollController::processWheelEventForScrollSnapOnAxis): Added helper function containing the snap wheel handler code
from AxisScrollSnapAnimator.
(WebCore::ScrollController::shouldOverrideWheelEvent): Moved from AxisScrollSnapAnimator.
(WebCore::ScrollController::processWheelEventForScrollSnap): Update to use new methods moved from AxisScrollSnapAnimator.
(WebCore::ScrollController::updateScrollAnimatorsAndTimers): Update for new ScrollSnapAnimatorState class.
(WebCore::ScrollController::updateScrollSnapPoints): Ditto.
(WebCore::ScrollController::startScrollSnapTimer): Call client (delegate) method.
(WebCore::ScrollController::stopScrollSnapTimer): Ditto.
(WebCore::ScrollController::horizontalScrollSnapTimerFired): Call new 'scrollSnapAnimationUpdate' method passing the
correct axis to animate.
(WebCore::ScrollController::verticalScrollSnapTimerFired): Ditto.
(WebCore::ScrollController::scrollSnapAnimationUpdate): Moved from AxisScrollSnapAnimator.
(WebCore::projectedInertialScrollDistance): Moved from AxisScrollSnapAnimator.
(WebCore::ScrollController::initializeGlideParameters): Ditto.
(WebCore::ScrollController::beginScrollSnapAnimation): Ditto.
(WebCore::ScrollController::endScrollSnapAnimation): Ditto.
(WebCore::snapProgress): Created a new function for this calculation to make reasoning about the 'computeSnapDelta' and
'computeGlideDelta' easier.
(WebCore::clampedSnapMagnitude): Ditto.
(WebCore::ScrollController::computeSnapDelta): Moved from AxisScrollSnapAnimator.
(WebCore::snapGlide): Created a new function for this calculation to make reasoning about the 'computeGlideDelta' easier.
(WebCore::ScrollController::computeGlideDelta): Moved from AxisScrollSnapAnimator.
(WebCore::ScrollController::scrollOffsetOnAxis): Deleted.
(WebCore::ScrollController::immediateScrollOnAxis): Deleted.
* platform/cocoa/ScrollSnapAnimatorState.h: Copied from platform/mac/AxisScrollSnapAnimator.h.
(WebCore::AxisScrollSnapAnimatorClient::~AxisScrollSnapAnimatorClient): Deleted.
* platform/cocoa/ScrollSnapAnimatorState.mm: Copied from platform/mac/AxisScrollSnapAnimator.mm.
(WebCore::ScrollSnapAnimatorState::ScrollSnapAnimatorState):
(WebCore::ScrollSnapAnimatorState::pushInitialWheelDelta):
(WebCore::ScrollSnapAnimatorState::averageInitialWheelDelta):
(WebCore::ScrollSnapAnimatorState::clearInitialWheelDeltaWindow):
(WebCore::toWheelEventStatus): Deleted.
(WebCore::projectedInertialScrollDistance): Deleted.
(WebCore::AxisScrollSnapAnimator::AxisScrollSnapAnimator): Deleted.
(WebCore::AxisScrollSnapAnimator::handleWheelEvent): Deleted.
(WebCore::AxisScrollSnapAnimator::shouldOverrideWheelEvent): Deleted.
(WebCore::AxisScrollSnapAnimator::scrollSnapAnimationUpdate): Deleted.
(WebCore::AxisScrollSnapAnimator::beginScrollSnapAnimation): Deleted.
(WebCore::AxisScrollSnapAnimator::endScrollSnapAnimation): Deleted.
(WebCore::AxisScrollSnapAnimator::computeSnapDelta): Deleted.
(WebCore::AxisScrollSnapAnimator::computeGlideDelta): Deleted.
(WebCore::AxisScrollSnapAnimator::initializeGlideParameters): Deleted.
(WebCore::AxisScrollSnapAnimator::pushInitialWheelDelta): Deleted.
(WebCore::AxisScrollSnapAnimator::averageInitialWheelDelta): Deleted.
(WebCore::AxisScrollSnapAnimator::clearInitialWheelDeltaWindow): Deleted.
* platform/mac/AxisScrollSnapAnimator.h: Removed.
* platform/mac/AxisScrollSnapAnimator.mm: Removed.
* platform/mac/ScrollAnimatorMac.h:
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::pinnedInDirection): Removed.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorepagescrollingmacScrollingTreeFrameScrollingNodeMach">trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h</a></li>
<li><a href="#trunkSourceWebCorepagescrollingmacScrollingTreeFrameScrollingNodeMacmm">trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformScrollAnimatorcpp">trunk/Source/WebCore/platform/ScrollAnimator.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformScrollAnimatorh">trunk/Source/WebCore/platform/ScrollAnimator.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaScrollControllerh">trunk/Source/WebCore/platform/cocoa/ScrollController.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaScrollControllermm">trunk/Source/WebCore/platform/cocoa/ScrollController.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmacScrollAnimatorMach">trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacScrollAnimatorMacmm">trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformcocoaScrollSnapAnimatorStateh">trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaScrollSnapAnimatorStatemm">trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.mm</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformmacAxisScrollSnapAnimatorh">trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacAxisScrollSnapAnimatormm">trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (181086 => 181087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-03-05 18:59:57 UTC (rev 181086)
+++ trunk/Source/WebCore/ChangeLog        2015-03-05 19:32:27 UTC (rev 181087)
</span><span class="lines">@@ -1,3 +1,82 @@
</span><ins>+2015-03-05 Brent Fulgham <bfulgham@apple.com>
+
+ Move AxisScrollSnapAnimator logic to ScrollController
+ https://bugs.webkit.org/show_bug.cgi?id=142293
+ <rdar://problem/20039867>
+
+ Reviewed by Dean Jackson.
+
+ No change in function.
+
+ Move the animation logic out of 'AxisScrollSnapAnimator' into 'ScrollController'. Rename the remaining
+ bits of 'AxisScrollSnapAnimator' as 'ScrollSnapAnimatorState'. Remove a number of delegate methods required
+ by 'AxisScrollSnapAnimatorClient' that are no longer needed.
+
+ Also, break up some of the Scroll Snap Point math to be a little easier to understand.
+
+ * WebCore.xcodeproj/project.pbxproj: Rename 'platform/mac/AxisScrollSnapAnimator.{h,mm}' -> 'platform/cocoa/ScrollSnapAnimatorState.h'
+ * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h: Mark 'scrollOffsetOnAxis' as const.
+ * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
+ (WebCore::ScrollingTreeFrameScrollingNodeMac::scrollOffsetOnAxis): Make 'const'
+ * platform/ScrollAnimator.cpp:
+ (WebCore::ScrollAnimator::scrollOffsetOnAxis): Make 'const'
+ * platform/ScrollAnimator.h:
+ * platform/cocoa/ScrollController.h: No longer subclass from AxisScrollSnapAnimatorClient.
+ * platform/cocoa/ScrollController.mm:
+ (WebCore::ScrollController::scrollSnapPointState): Added accessors (const and non-const) for the individual
+ Scroll Snap State of each axis.
+ (WebCore::toWheelEventStatus): Moved from AxisScrollSnapAnimator.
+ (WebCore::ScrollController::processWheelEventForScrollSnapOnAxis): Added helper function containing the snap wheel handler code
+ from AxisScrollSnapAnimator.
+ (WebCore::ScrollController::shouldOverrideWheelEvent): Moved from AxisScrollSnapAnimator.
+ (WebCore::ScrollController::processWheelEventForScrollSnap): Update to use new methods moved from AxisScrollSnapAnimator.
+ (WebCore::ScrollController::updateScrollAnimatorsAndTimers): Update for new ScrollSnapAnimatorState class.
+ (WebCore::ScrollController::updateScrollSnapPoints): Ditto.
+ (WebCore::ScrollController::startScrollSnapTimer): Call client (delegate) method.
+ (WebCore::ScrollController::stopScrollSnapTimer): Ditto.
+ (WebCore::ScrollController::horizontalScrollSnapTimerFired): Call new 'scrollSnapAnimationUpdate' method passing the
+ correct axis to animate.
+ (WebCore::ScrollController::verticalScrollSnapTimerFired): Ditto.
+ (WebCore::ScrollController::scrollSnapAnimationUpdate): Moved from AxisScrollSnapAnimator.
+ (WebCore::projectedInertialScrollDistance): Moved from AxisScrollSnapAnimator.
+ (WebCore::ScrollController::initializeGlideParameters): Ditto.
+ (WebCore::ScrollController::beginScrollSnapAnimation): Ditto.
+ (WebCore::ScrollController::endScrollSnapAnimation): Ditto.
+ (WebCore::snapProgress): Created a new function for this calculation to make reasoning about the 'computeSnapDelta' and
+ 'computeGlideDelta' easier.
+ (WebCore::clampedSnapMagnitude): Ditto.
+ (WebCore::ScrollController::computeSnapDelta): Moved from AxisScrollSnapAnimator.
+ (WebCore::snapGlide): Created a new function for this calculation to make reasoning about the 'computeGlideDelta' easier.
+ (WebCore::ScrollController::computeGlideDelta): Moved from AxisScrollSnapAnimator.
+ (WebCore::ScrollController::scrollOffsetOnAxis): Deleted.
+ (WebCore::ScrollController::immediateScrollOnAxis): Deleted.
+ * platform/cocoa/ScrollSnapAnimatorState.h: Copied from platform/mac/AxisScrollSnapAnimator.h.
+ (WebCore::AxisScrollSnapAnimatorClient::~AxisScrollSnapAnimatorClient): Deleted.
+ * platform/cocoa/ScrollSnapAnimatorState.mm: Copied from platform/mac/AxisScrollSnapAnimator.mm.
+ (WebCore::ScrollSnapAnimatorState::ScrollSnapAnimatorState):
+ (WebCore::ScrollSnapAnimatorState::pushInitialWheelDelta):
+ (WebCore::ScrollSnapAnimatorState::averageInitialWheelDelta):
+ (WebCore::ScrollSnapAnimatorState::clearInitialWheelDeltaWindow):
+ (WebCore::toWheelEventStatus): Deleted.
+ (WebCore::projectedInertialScrollDistance): Deleted.
+ (WebCore::AxisScrollSnapAnimator::AxisScrollSnapAnimator): Deleted.
+ (WebCore::AxisScrollSnapAnimator::handleWheelEvent): Deleted.
+ (WebCore::AxisScrollSnapAnimator::shouldOverrideWheelEvent): Deleted.
+ (WebCore::AxisScrollSnapAnimator::scrollSnapAnimationUpdate): Deleted.
+ (WebCore::AxisScrollSnapAnimator::beginScrollSnapAnimation): Deleted.
+ (WebCore::AxisScrollSnapAnimator::endScrollSnapAnimation): Deleted.
+ (WebCore::AxisScrollSnapAnimator::computeSnapDelta): Deleted.
+ (WebCore::AxisScrollSnapAnimator::computeGlideDelta): Deleted.
+ (WebCore::AxisScrollSnapAnimator::initializeGlideParameters): Deleted.
+ (WebCore::AxisScrollSnapAnimator::pushInitialWheelDelta): Deleted.
+ (WebCore::AxisScrollSnapAnimator::averageInitialWheelDelta): Deleted.
+ (WebCore::AxisScrollSnapAnimator::clearInitialWheelDeltaWindow): Deleted.
+ * platform/mac/AxisScrollSnapAnimator.h: Removed.
+ * platform/mac/AxisScrollSnapAnimator.mm: Removed.
+ * platform/mac/ScrollAnimatorMac.h:
+ * platform/mac/ScrollAnimatorMac.mm:
+ (WebCore::ScrollAnimatorMac::pinnedInDirection): Removed.
+
</ins><span class="cx"> 2015-03-04 Dean Jackson <dino@apple.com>
</span><span class="cx">
</span><span class="cx"> [iOS Media] Small inline controls can clip the time widgets
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (181086 => 181087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-03-05 18:59:57 UTC (rev 181086)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-03-05 19:32:27 UTC (rev 181087)
</span><span class="lines">@@ -6328,8 +6328,8 @@
</span><span class="cx">                 F42FFB461984B71600F6837F /* LengthRepeat.h in Headers */ = {isa = PBXBuildFile; fileRef = F42FFB451984B71600F6837F /* LengthRepeat.h */; };
</span><span class="cx">                 F45C231D1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F45C231B1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp */; };
</span><span class="cx">                 F45C231E1995B73B00A6E2E3 /* AxisScrollSnapOffsets.h in Headers */ = {isa = PBXBuildFile; fileRef = F45C231C1995B73B00A6E2E3 /* AxisScrollSnapOffsets.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-                F478755419983AFF0024A287 /* AxisScrollSnapAnimator.h in Headers */ = {isa = PBXBuildFile; fileRef = F478755219983AFF0024A287 /* AxisScrollSnapAnimator.h */; settings = {ATTRIBUTES = (Private, ); }; };
-                F478755519983AFF0024A287 /* AxisScrollSnapAnimator.mm in Sources */ = {isa = PBXBuildFile; fileRef = F478755319983AFF0024A287 /* AxisScrollSnapAnimator.mm */; };
</del><ins>+                F478755419983AFF0024A287 /* ScrollSnapAnimatorState.h in Headers */ = {isa = PBXBuildFile; fileRef = F478755219983AFF0024A287 /* ScrollSnapAnimatorState.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                F478755519983AFF0024A287 /* ScrollSnapAnimatorState.mm in Sources */ = {isa = PBXBuildFile; fileRef = F478755319983AFF0024A287 /* ScrollSnapAnimatorState.mm */; };
</ins><span class="cx">                 F47A5E3E195B8C8A00483100 /* StyleScrollSnapPoints.h in Headers */ = {isa = PBXBuildFile; fileRef = F47A5E3B195B8C8A00483100 /* StyleScrollSnapPoints.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 F47A5E3F195B8E4800483100 /* StyleScrollSnapPoints.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F47A5E3A195B8C8A00483100 /* StyleScrollSnapPoints.cpp */; };
</span><span class="cx">                 F50664F7157F52DC00AC226F /* FormController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F50664F5157F52DC00AC226F /* FormController.cpp */; };
</span><span class="lines">@@ -13902,8 +13902,8 @@
</span><span class="cx">                 F42FFB451984B71600F6837F /* LengthRepeat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LengthRepeat.h; sourceTree = "<group>"; };
</span><span class="cx">                 F45C231B1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AxisScrollSnapOffsets.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 F45C231C1995B73B00A6E2E3 /* AxisScrollSnapOffsets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AxisScrollSnapOffsets.h; sourceTree = "<group>"; };
</span><del>-                F478755219983AFF0024A287 /* AxisScrollSnapAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AxisScrollSnapAnimator.h; sourceTree = "<group>"; };
-                F478755319983AFF0024A287 /* AxisScrollSnapAnimator.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AxisScrollSnapAnimator.mm; sourceTree = "<group>"; };
</del><ins>+                F478755219983AFF0024A287 /* ScrollSnapAnimatorState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollSnapAnimatorState.h; sourceTree = "<group>"; };
+                F478755319983AFF0024A287 /* ScrollSnapAnimatorState.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollSnapAnimatorState.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 F47A5E3A195B8C8A00483100 /* StyleScrollSnapPoints.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StyleScrollSnapPoints.cpp; path = style/StyleScrollSnapPoints.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 F47A5E3B195B8C8A00483100 /* StyleScrollSnapPoints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleScrollSnapPoints.h; path = style/StyleScrollSnapPoints.h; sourceTree = "<group>"; };
</span><span class="cx">                 F50664F5157F52DC00AC226F /* FormController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormController.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -16577,8 +16577,6 @@
</span><span class="cx">                 6582A14809999D6C00BEEB6D /* mac */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><del>-                                F478755219983AFF0024A287 /* AxisScrollSnapAnimator.h */,
-                                F478755319983AFF0024A287 /* AxisScrollSnapAnimator.mm */,
</del><span class="cx">                                 65A640F00533BB1F0085E777 /* BlockExceptions.h */,
</span><span class="cx">                                 65F80697054D9F86008BF776 /* BlockExceptions.mm */,
</span><span class="cx">                                 06027CB20B1CC03D00884B2D /* ContextMenuItemMac.mm */,
</span><span class="lines">@@ -18715,6 +18713,8 @@
</span><span class="cx">                 A5C974CE11485FDA0066F2AB /* cocoa */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                F478755219983AFF0024A287 /* ScrollSnapAnimatorState.h */,
+                                F478755319983AFF0024A287 /* ScrollSnapAnimatorState.mm */,
</ins><span class="cx">                                 A14090FA1AA51E1D0091191A /* ContentFilterUnblockHandlerCocoa.mm */,
</span><span class="cx">                                 5D8C4DBD1428222C0026CE72 /* DisplaySleepDisablerCocoa.cpp */,
</span><span class="cx">                                 5D8C4DBE1428222C0026CE72 /* DisplaySleepDisablerCocoa.h */,
</span><span class="lines">@@ -23621,7 +23621,7 @@
</span><span class="cx">                                 070363E4181A1CDC00C074A5 /* AVMediaCaptureSource.h in Headers */,
</span><span class="cx">                                 CD336F6217F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h in Headers */,
</span><span class="cx">                                 070363E6181A1CDC00C074A5 /* AVVideoCaptureSource.h in Headers */,
</span><del>-                                F478755419983AFF0024A287 /* AxisScrollSnapAnimator.h in Headers */,
</del><ins>+                                F478755419983AFF0024A287 /* ScrollSnapAnimatorState.h in Headers */,
</ins><span class="cx">                                 F45C231E1995B73B00A6E2E3 /* AxisScrollSnapOffsets.h in Headers */,
</span><span class="cx">                                 29A812380FBB9C1D00510293 /* AXObjectCache.h in Headers */,
</span><span class="cx">                                 51741D0F0B07259A00ED442C /* BackForwardClient.h in Headers */,
</span><span class="lines">@@ -27359,7 +27359,7 @@
</span><span class="cx">                                 070363E5181A1CDC00C074A5 /* AVMediaCaptureSource.mm in Sources */,
</span><span class="cx">                                 CD336F6117F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm in Sources */,
</span><span class="cx">                                 070363E7181A1CDC00C074A5 /* AVVideoCaptureSource.mm in Sources */,
</span><del>-                                F478755519983AFF0024A287 /* AxisScrollSnapAnimator.mm in Sources */,
</del><ins>+                                F478755519983AFF0024A287 /* ScrollSnapAnimatorState.mm in Sources */,
</ins><span class="cx">                                 F45C231D1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp in Sources */,
</span><span class="cx">                                 37F57ACF1A5072DD00876F98 /* AXObjectCache.cpp in Sources */,
</span><span class="cx">                                 AAA728F916D1D8BC00D3BBC6 /* AXObjectCacheIOS.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorepagescrollingmacScrollingTreeFrameScrollingNodeMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h (181086 => 181087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h        2015-03-05 18:59:57 UTC (rev 181086)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h        2015-03-05 19:32:27 UTC (rev 181087)
</span><span class="lines">@@ -80,7 +80,7 @@
</span><span class="cx"> bool isAlreadyPinnedInDirectionOfGesture(const PlatformWheelEvent&, ScrollEventAxis);
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
</span><del>- LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) override;
</del><ins>+ LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) const override;
</ins><span class="cx"> void immediateScrollOnAxis(ScrollEventAxis, float delta) override;
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorepagescrollingmacScrollingTreeFrameScrollingNodeMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm (181086 => 181087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm        2015-03-05 18:59:57 UTC (rev 181086)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm        2015-03-05 19:32:27 UTC (rev 181087)
</span><span class="lines">@@ -541,7 +541,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
</span><del>-LayoutUnit ScrollingTreeFrameScrollingNodeMac::scrollOffsetOnAxis(ScrollEventAxis axis)
</del><ins>+LayoutUnit ScrollingTreeFrameScrollingNodeMac::scrollOffsetOnAxis(ScrollEventAxis axis) const
</ins><span class="cx"> {
</span><span class="cx"> const FloatPoint& currentPosition = scrollPosition();
</span><span class="cx"> return axis == ScrollEventAxis::Horizontal ? currentPosition.x() : currentPosition.y();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScrollAnimatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScrollAnimator.cpp (181086 => 181087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollAnimator.cpp        2015-03-05 18:59:57 UTC (rev 181086)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp        2015-03-05 19:32:27 UTC (rev 181087)
</span><span class="lines">@@ -178,7 +178,7 @@
</span><span class="cx"> m_scrollController.updateScrollAnimatorsAndTimers(m_scrollableArea);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-LayoutUnit ScrollAnimator::scrollOffsetOnAxis(ScrollEventAxis axis)
</del><ins>+LayoutUnit ScrollAnimator::scrollOffsetOnAxis(ScrollEventAxis axis) const
</ins><span class="cx"> {
</span><span class="cx"> return axis == ScrollEventAxis::Horizontal ? m_currentPosX : m_currentPosY;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScrollAnimatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScrollAnimator.h (181086 => 181087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollAnimator.h        2015-03-05 18:59:57 UTC (rev 181086)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h        2015-03-05 19:32:27 UTC (rev 181087)
</span><span class="lines">@@ -120,7 +120,7 @@
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
</span><span class="cx"> bool processWheelEventForScrollSnap(const PlatformWheelEvent&);
</span><span class="cx"> void updateScrollAnimatorsAndTimers();
</span><del>- LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) override;
</del><ins>+ LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) const override;
</ins><span class="cx"> void immediateScrollOnAxis(ScrollEventAxis, float delta) override;
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaScrollControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.h (181086 => 181087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/ScrollController.h        2015-03-05 18:59:57 UTC (rev 181086)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.h        2015-03-05 19:32:27 UTC (rev 181087)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> #include <wtf/RunLoop.h>
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP)
</span><del>-#include "AxisScrollSnapAnimator.h"
</del><ins>+#include "ScrollSnapAnimatorState.h"
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -76,7 +76,7 @@
</span><span class="cx"> virtual void adjustScrollPositionToBoundsIfNecessary() = 0;
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
</span><del>- virtual LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) = 0;
</del><ins>+ virtual LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) const = 0;
</ins><span class="cx"> virtual void immediateScrollOnAxis(ScrollEventAxis, float delta) = 0;
</span><span class="cx"> virtual void startScrollSnapTimer(ScrollEventAxis)
</span><span class="cx"> {
</span><span class="lines">@@ -91,11 +91,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx">
</span><del>-#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
-class ScrollController : public AxisScrollSnapAnimatorClient {
-#else
</del><span class="cx"> class ScrollController {
</span><del>-#endif
</del><span class="cx"> WTF_MAKE_NONCOPYABLE(ScrollController);
</span><span class="cx">
</span><span class="cx"> public:
</span><span class="lines">@@ -122,11 +118,23 @@
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
</span><span class="cx"> void horizontalScrollSnapTimerFired();
</span><span class="cx"> void verticalScrollSnapTimerFired();
</span><del>- void startScrollSnapTimer(ScrollEventAxis) override;
- void stopScrollSnapTimer(ScrollEventAxis) override;
</del><ins>+ void startScrollSnapTimer(ScrollEventAxis);
+ void stopScrollSnapTimer(ScrollEventAxis);
</ins><span class="cx">
</span><del>- LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) override;
- void immediateScrollOnAxis(ScrollEventAxis, float delta) override;
</del><ins>+ LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) const;
+ void processWheelEventForScrollSnapOnAxis(ScrollEventAxis, const PlatformWheelEvent&);
+ bool shouldOverrideWheelEvent(ScrollEventAxis, const PlatformWheelEvent&) const;
+
+ void beginScrollSnapAnimation(ScrollEventAxis, ScrollSnapState);
+ void scrollSnapAnimationUpdate(ScrollEventAxis);
+ void endScrollSnapAnimation(ScrollEventAxis, ScrollSnapState);
+
+ void initializeGlideParameters(ScrollEventAxis, bool);
+ float computeSnapDelta(ScrollEventAxis) const;
+ float computeGlideDelta(ScrollEventAxis) const;
+
+ ScrollSnapAnimatorState& scrollSnapPointState(ScrollEventAxis);
+ const ScrollSnapAnimatorState& scrollSnapPointState(ScrollEventAxis) const;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> ScrollControllerClient* m_client;
</span><span class="lines">@@ -145,8 +153,8 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
</span><span class="cx"> // FIXME: Find a way to consolidate both timers into one variable.
</span><del>- std::unique_ptr<AxisScrollSnapAnimator> m_horizontalScrollSnapAnimator;
- std::unique_ptr<AxisScrollSnapAnimator> m_verticalScrollSnapAnimator;
</del><ins>+ std::unique_ptr<ScrollSnapAnimatorState> m_horizontalScrollSnapState;
+ std::unique_ptr<ScrollSnapAnimatorState> m_verticalScrollSnapState;
</ins><span class="cx"> RunLoop::Timer<ScrollController> m_horizontalScrollSnapTimer;
</span><span class="cx"> RunLoop::Timer<ScrollController> m_verticalScrollSnapTimer;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaScrollControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.mm (181086 => 181087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/ScrollController.mm        2015-03-05 18:59:57 UTC (rev 181086)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.mm        2015-03-05 19:32:27 UTC (rev 181087)
</span><span class="lines">@@ -32,7 +32,7 @@
</span><span class="cx"> #include <sys/time.h>
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP)
</span><del>-#include "AxisScrollSnapAnimator.h"
</del><ins>+#include "ScrollSnapAnimatorState.h"
</ins><span class="cx"> #include "ScrollableArea.h"
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -68,6 +68,31 @@
</span><span class="cx"> static const float rubberbandDirectionLockStretchRatio = 1;
</span><span class="cx"> static const float rubberbandMinimumRequiredDeltaBeforeStretch = 10;
</span><span class="cx">
</span><ins>+#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
+static const float snapMagnitudeMax = 25;
+static const float snapMagnitudeMin = 5;
+static const float snapThresholdHigh = 1000;
+static const float snapThresholdLow = 50;
+
+static const float inertialScrollPredictionFactor = 16.7;
+static const float initialToFinalMomentumFactor = 1.0 / 40.0;
+
+static const float glideBoostMultiplier = 3.5;
+
+static const float maxTargetWheelDelta = 7;
+static const float minTargetWheelDelta = 3.5;
+#endif
+
+enum class WheelEventStatus {
+ UserScrollBegin,
+ UserScrolling,
+ UserScrollEnd,
+ InertialScrollBegin,
+ InertialScrolling,
+ InertialScrollEnd,
+ Unknown
+};
+
</ins><span class="cx"> static float elasticDeltaForTimeDelta(float initialPosition, float initialVelocity, float elapsedTime)
</span><span class="cx"> {
</span><span class="cx"> return wkNSElasticDeltaForTimeDelta(initialPosition, initialVelocity, elapsedTime);
</span><span class="lines">@@ -423,16 +448,123 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
</span><ins>+ScrollSnapAnimatorState& ScrollController::scrollSnapPointState(ScrollEventAxis axis)
+{
+ ASSERT(axis != ScrollEventAxis::Horizontal || m_horizontalScrollSnapState);
+ ASSERT(axis != ScrollEventAxis::Vertical || m_verticalScrollSnapState);
+
+ return (axis == ScrollEventAxis::Horizontal) ? *m_horizontalScrollSnapState : *m_verticalScrollSnapState;
+}
+
+const ScrollSnapAnimatorState& ScrollController::scrollSnapPointState(ScrollEventAxis axis) const
+{
+ ASSERT(axis != ScrollEventAxis::Horizontal || m_horizontalScrollSnapState);
+ ASSERT(axis != ScrollEventAxis::Vertical || m_verticalScrollSnapState);
+
+ return (axis == ScrollEventAxis::Horizontal) ? *m_horizontalScrollSnapState : *m_verticalScrollSnapState;
+}
+
+static inline WheelEventStatus toWheelEventStatus(PlatformWheelEventPhase phase, PlatformWheelEventPhase momentumPhase)
+{
+ if (phase == PlatformWheelEventPhaseNone) {
+ switch (momentumPhase) {
+ case PlatformWheelEventPhaseBegan:
+ return WheelEventStatus::InertialScrollBegin;
+
+ case PlatformWheelEventPhaseChanged:
+ return WheelEventStatus::InertialScrolling;
+
+ case PlatformWheelEventPhaseEnded:
+ return WheelEventStatus::InertialScrollEnd;
+
+ default:
+ return WheelEventStatus::Unknown;
+ }
+ }
+ if (momentumPhase == PlatformWheelEventPhaseNone) {
+ switch (phase) {
+ case PlatformWheelEventPhaseBegan:
+ case PlatformWheelEventPhaseMayBegin:
+ return WheelEventStatus::UserScrollBegin;
+
+ case PlatformWheelEventPhaseChanged:
+ return WheelEventStatus::UserScrolling;
+
+ case PlatformWheelEventPhaseEnded:
+ case PlatformWheelEventPhaseCancelled:
+ return WheelEventStatus::UserScrollEnd;
+
+ default:
+ return WheelEventStatus::Unknown;
+ }
+ }
+ return WheelEventStatus::Unknown;
+}
+
+void ScrollController::processWheelEventForScrollSnapOnAxis(ScrollEventAxis axis, const PlatformWheelEvent& event)
+{
+ ScrollSnapAnimatorState& snapState = scrollSnapPointState(axis);
+
+ float wheelDelta = axis == ScrollEventAxis::Horizontal ? -event.deltaX() : -event.deltaY();
+ WheelEventStatus wheelStatus = toWheelEventStatus(event.phase(), event.momentumPhase());
+
+ switch (wheelStatus) {
+ case WheelEventStatus::UserScrollBegin:
+ case WheelEventStatus::UserScrolling:
+ endScrollSnapAnimation(axis, ScrollSnapState::UserInteraction);
+ break;
+
+ case WheelEventStatus::UserScrollEnd:
+ beginScrollSnapAnimation(axis, ScrollSnapState::Snapping);
+ break;
+
+ case WheelEventStatus::InertialScrollBegin:
+ // Begin tracking wheel deltas for glide prediction.
+ endScrollSnapAnimation(axis, ScrollSnapState::UserInteraction);
+ snapState.pushInitialWheelDelta(wheelDelta);
+ snapState.m_beginTrackingWheelDeltaOffset = m_client->scrollOffsetOnAxis(axis);
+ break;
+
+ case WheelEventStatus::InertialScrolling:
+ // This check for DestinationReached ensures that we don't receive another set of momentum events after ending the last glide.
+ if (snapState.m_currentState != ScrollSnapState::Gliding && snapState.m_currentState != ScrollSnapState::DestinationReached) {
+ if (snapState.m_numWheelDeltasTracked < snapState.wheelDeltaWindowSize)
+ snapState.pushInitialWheelDelta(wheelDelta);
+
+ if (snapState.m_numWheelDeltasTracked == snapState.wheelDeltaWindowSize)
+ beginScrollSnapAnimation(axis, ScrollSnapState::Gliding);
+ }
+ break;
+
+ case WheelEventStatus::InertialScrollEnd:
+ beginScrollSnapAnimation(axis, ScrollSnapState::Snapping);
+ snapState.clearInitialWheelDeltaWindow();
+ snapState.m_shouldOverrideWheelEvent = false;
+ break;
+
+ case WheelEventStatus::Unknown:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+}
+
+bool ScrollController::shouldOverrideWheelEvent(ScrollEventAxis axis, const PlatformWheelEvent& event) const
+{
+ const ScrollSnapAnimatorState& snapState = scrollSnapPointState(axis);
+
+ return snapState.m_shouldOverrideWheelEvent && toWheelEventStatus(event.phase(), event.momentumPhase()) == WheelEventStatus::InertialScrolling;
+}
+
</ins><span class="cx"> bool ScrollController::processWheelEventForScrollSnap(const PlatformWheelEvent& wheelEvent)
</span><span class="cx"> {
</span><del>- if (m_verticalScrollSnapAnimator) {
- m_verticalScrollSnapAnimator->handleWheelEvent(wheelEvent);
- if (m_verticalScrollSnapAnimator->shouldOverrideWheelEvent(wheelEvent))
</del><ins>+ if (m_verticalScrollSnapState) {
+ processWheelEventForScrollSnapOnAxis(ScrollEventAxis::Vertical, wheelEvent);
+ if (shouldOverrideWheelEvent(ScrollEventAxis::Vertical, wheelEvent))
</ins><span class="cx"> return false;
</span><span class="cx"> }
</span><del>- if (m_horizontalScrollSnapAnimator) {
- m_horizontalScrollSnapAnimator->handleWheelEvent(wheelEvent);
- if (m_horizontalScrollSnapAnimator->shouldOverrideWheelEvent(wheelEvent))
</del><ins>+ if (m_horizontalScrollSnapState) {
+ processWheelEventForScrollSnapOnAxis(ScrollEventAxis::Horizontal, wheelEvent);
+ if (shouldOverrideWheelEvent(ScrollEventAxis::Horizontal, wheelEvent))
</ins><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -443,60 +575,224 @@
</span><span class="cx"> {
</span><span class="cx"> // FIXME: Currently, scroll snap animators are recreated even though the snap offsets alone can be updated.
</span><span class="cx"> if (scrollableArea.horizontalSnapOffsets())
</span><del>- m_horizontalScrollSnapAnimator = std::make_unique<AxisScrollSnapAnimator>(this, *scrollableArea.horizontalSnapOffsets(), ScrollEventAxis::Horizontal);
- else if (m_horizontalScrollSnapAnimator)
- m_horizontalScrollSnapAnimator = nullptr;
</del><ins>+ m_horizontalScrollSnapState = std::make_unique<ScrollSnapAnimatorState>(ScrollEventAxis::Horizontal, *scrollableArea.horizontalSnapOffsets());
+ else if (m_horizontalScrollSnapState)
+ m_horizontalScrollSnapState = nullptr;
</ins><span class="cx">
</span><span class="cx"> if (scrollableArea.verticalSnapOffsets())
</span><del>- m_verticalScrollSnapAnimator = std::make_unique<AxisScrollSnapAnimator>(this, *scrollableArea.verticalSnapOffsets(), ScrollEventAxis::Vertical);
- else if (m_verticalScrollSnapAnimator)
- m_verticalScrollSnapAnimator = nullptr;
</del><ins>+ m_verticalScrollSnapState = std::make_unique<ScrollSnapAnimatorState>(ScrollEventAxis::Vertical, *scrollableArea.verticalSnapOffsets());
+ else if (m_verticalScrollSnapState)
+ m_verticalScrollSnapState = nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void ScrollController::updateScrollSnapPoints(ScrollEventAxis axis, const Vector<LayoutUnit>& snapPoints)
</span><span class="cx"> {
</span><span class="cx"> // FIXME: Currently, scroll snap animators are recreated even though the snap offsets alone can be updated.
</span><span class="cx"> if (axis == ScrollEventAxis::Horizontal)
</span><del>- m_horizontalScrollSnapAnimator = std::make_unique<AxisScrollSnapAnimator>(this, snapPoints, ScrollEventAxis::Horizontal);
</del><ins>+ m_horizontalScrollSnapState = std::make_unique<ScrollSnapAnimatorState>(ScrollEventAxis::Horizontal, snapPoints);
</ins><span class="cx">
</span><span class="cx"> if (axis == ScrollEventAxis::Vertical)
</span><del>- m_verticalScrollSnapAnimator = std::make_unique<AxisScrollSnapAnimator>(this, snapPoints, ScrollEventAxis::Vertical);
</del><ins>+ m_verticalScrollSnapState = std::make_unique<ScrollSnapAnimatorState>(ScrollEventAxis::Vertical, snapPoints);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void ScrollController::startScrollSnapTimer(ScrollEventAxis axis)
</span><span class="cx"> {
</span><span class="cx"> RunLoop::Timer<ScrollController>& scrollSnapTimer = axis == ScrollEventAxis::Horizontal ? m_horizontalScrollSnapTimer : m_verticalScrollSnapTimer;
</span><del>- if (!scrollSnapTimer.isActive())
</del><ins>+ if (!scrollSnapTimer.isActive()) {
+ m_client->startScrollSnapTimer(axis);
</ins><span class="cx"> scrollSnapTimer.startRepeating(1.0 / 60.0);
</span><ins>+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void ScrollController::stopScrollSnapTimer(ScrollEventAxis axis)
</span><span class="cx"> {
</span><ins>+ m_client->stopScrollSnapTimer(axis);
</ins><span class="cx"> RunLoop::Timer<ScrollController>& scrollSnapTimer = axis == ScrollEventAxis::Horizontal ? m_horizontalScrollSnapTimer : m_verticalScrollSnapTimer;
</span><span class="cx"> scrollSnapTimer.stop();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void ScrollController::horizontalScrollSnapTimerFired()
</span><span class="cx"> {
</span><del>- if (m_horizontalScrollSnapAnimator)
- m_horizontalScrollSnapAnimator->scrollSnapAnimationUpdate();
</del><ins>+ scrollSnapAnimationUpdate(ScrollEventAxis::Horizontal);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void ScrollController::verticalScrollSnapTimerFired()
</span><span class="cx"> {
</span><del>- if (m_verticalScrollSnapAnimator)
- m_verticalScrollSnapAnimator->scrollSnapAnimationUpdate();
</del><ins>+ scrollSnapAnimationUpdate(ScrollEventAxis::Vertical);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-LayoutUnit ScrollController::scrollOffsetOnAxis(ScrollEventAxis axis)
</del><ins>+void ScrollController::scrollSnapAnimationUpdate(ScrollEventAxis axis)
</ins><span class="cx"> {
</span><del>- return m_client->scrollOffsetOnAxis(axis);
</del><ins>+ if (axis == ScrollEventAxis::Horizontal && !m_horizontalScrollSnapState)
+ return;
+
+ if (axis == ScrollEventAxis::Vertical && !m_verticalScrollSnapState)
+ return;
+
+ ScrollSnapAnimatorState& snapState = scrollSnapPointState(axis);
+ if (snapState.m_currentState == ScrollSnapState::DestinationReached)
+ return;
+
+ ASSERT(snapState.m_currentState == ScrollSnapState::Gliding || snapState.m_currentState == ScrollSnapState::Snapping);
+ float delta = snapState.m_currentState == ScrollSnapState::Snapping ? computeSnapDelta(axis) : computeGlideDelta(axis);
+ if (delta)
+ m_client->immediateScrollOnAxis(axis, delta);
+ else
+ endScrollSnapAnimation(axis, ScrollSnapState::DestinationReached);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void ScrollController::immediateScrollOnAxis(ScrollEventAxis axis, float delta)
</del><ins>+static inline float projectedInertialScrollDistance(float initialWheelDelta)
</ins><span class="cx"> {
</span><del>- m_client->immediateScrollOnAxis(axis, delta);
</del><ins>+ // FIXME: Experiments with inertial scrolling show a fairly consistent linear relationship between initial wheel delta and total distance scrolled.
+ // In the future, we'll want to find a more accurate way of inertial scroll prediction.
+ return inertialScrollPredictionFactor * initialWheelDelta;
</ins><span class="cx"> }
</span><ins>+
+void ScrollController::initializeGlideParameters(ScrollEventAxis axis, bool shouldIncreaseInitialWheelDelta)
+{
+ ScrollSnapAnimatorState& snapState = scrollSnapPointState(axis);
+
+ // FIXME: Glide boost is a hacky way to speed up natural scrolling velocity. We should find a better way to accomplish this.
+ if (shouldIncreaseInitialWheelDelta)
+ snapState.m_glideInitialWheelDelta *= glideBoostMultiplier;
+
+ // FIXME: There must be a better way to determine a good target delta than multiplying by a factor and clamping to min/max values.
+ float targetFinalWheelDelta = initialToFinalMomentumFactor * (snapState.m_glideInitialWheelDelta < 0 ? -snapState.m_glideInitialWheelDelta : snapState.m_glideInitialWheelDelta);
+ targetFinalWheelDelta = (snapState.m_glideInitialWheelDelta > 0 ? 1 : -1) * std::min(std::max(targetFinalWheelDelta, minTargetWheelDelta), maxTargetWheelDelta);
+ snapState.m_glideMagnitude = (snapState.m_glideInitialWheelDelta + targetFinalWheelDelta) / 2;
+ snapState.m_glidePhaseShift = acos((snapState.m_glideInitialWheelDelta - targetFinalWheelDelta) / (snapState.m_glideInitialWheelDelta + targetFinalWheelDelta));
+}
+
+void ScrollController::beginScrollSnapAnimation(ScrollEventAxis axis, ScrollSnapState newState)
+{
+ ASSERT(newState == ScrollSnapState::Gliding || newState == ScrollSnapState::Snapping);
+
+ ScrollSnapAnimatorState& snapState = scrollSnapPointState(axis);
+
+ LayoutUnit offset = m_client->scrollOffsetOnAxis(axis);
+ float initialWheelDelta = newState == ScrollSnapState::Gliding ? snapState.averageInitialWheelDelta() : 0;
+ LayoutUnit projectedScrollDestination = newState == ScrollSnapState::Gliding ? snapState.m_beginTrackingWheelDeltaOffset + LayoutUnit(projectedInertialScrollDistance(initialWheelDelta)) : offset;
+ if (snapState.m_snapOffsets.isEmpty())
+ return;
+
+ projectedScrollDestination = std::min(std::max(projectedScrollDestination, snapState.m_snapOffsets.first()), snapState.m_snapOffsets.last());
+ snapState.m_initialOffset = offset;
+ snapState.m_targetOffset = closestSnapOffset<LayoutUnit, float>(snapState.m_snapOffsets, projectedScrollDestination, initialWheelDelta);
+ if (snapState.m_initialOffset == snapState.m_targetOffset)
+ return;
+
+ snapState.m_currentState = newState;
+ if (newState == ScrollSnapState::Gliding) {
+ snapState.m_shouldOverrideWheelEvent = true;
+ snapState.m_glideInitialWheelDelta = initialWheelDelta;
+ bool glideRequiresBoost;
+ if (initialWheelDelta > 0)
+ glideRequiresBoost = projectedScrollDestination - offset < snapState.m_targetOffset - projectedScrollDestination;
+ else
+ glideRequiresBoost = offset - projectedScrollDestination < projectedScrollDestination - snapState.m_targetOffset;
+
+ initializeGlideParameters(axis, glideRequiresBoost);
+ snapState.clearInitialWheelDeltaWindow();
+ }
+ startScrollSnapTimer(axis);
+}
+
+void ScrollController::endScrollSnapAnimation(ScrollEventAxis axis, ScrollSnapState newState)
+{
+ ASSERT(newState == ScrollSnapState::DestinationReached || newState == ScrollSnapState::UserInteraction);
+
+ ScrollSnapAnimatorState& snapState = scrollSnapPointState(axis);
+
+ if (snapState.m_currentState == ScrollSnapState::Gliding)
+ snapState.clearInitialWheelDeltaWindow();
+
+ snapState.m_currentState = newState;
+ stopScrollSnapTimer(axis);
+}
+
+static inline float snapProgress(const LayoutUnit& offset, const ScrollSnapAnimatorState& snapState)
+{
+ const float distanceTraveled = static_cast<float>(offset - snapState.m_initialOffset);
+ const float totalDistance = static_cast<float>(snapState.m_targetOffset - snapState.m_initialOffset);
+
+ return distanceTraveled / totalDistance;
+}
+
+static inline float clampedSnapMagnitude(float thresholdedDistance)
+{
+ return snapMagnitudeMin + (snapMagnitudeMax - snapMagnitudeMin) * (thresholdedDistance - snapThresholdLow) / (snapThresholdHigh - snapThresholdLow);
+}
+
+// Computes the amount to scroll by when performing a "snap" operation, i.e. when a user releases the trackpad without flicking. The snap delta
+// is a function of progress t, where t is equal to DISTANCE_TRAVELED / TOTAL_DISTANCE, DISTANCE_TRAVELED is the distance from the initialOffset
+// to the current offset, and TOTAL_DISTANCE is the distance from initialOffset to targetOffset. The snapping equation is as follows:
+// delta(t) = MAGNITUDE * sin(PI * t). MAGNITUDE indicates the top speed reached near the middle of the animation (t = 0.5), and is a linear
+// relationship of the distance traveled, clamped by arbitrary min and max values.
+float ScrollController::computeSnapDelta(ScrollEventAxis axis) const
+{
+ const ScrollSnapAnimatorState& snapState = scrollSnapPointState(axis);
+
+ LayoutUnit offset = m_client->scrollOffsetOnAxis(axis);
+ bool canComputeSnap = (snapState.m_initialOffset <= offset && offset < snapState.m_targetOffset) || (snapState.m_targetOffset < offset && offset <= snapState.m_initialOffset);
+ if (snapState.m_currentState != ScrollSnapState::Snapping || !canComputeSnap)
+ return 0;
+
+ float progress = snapProgress(offset, snapState);
+
+ // Threshold the distance before computing magnitude, so only distances within a certain range are considered.
+ int sign = snapState.m_initialOffset < snapState.m_targetOffset ? 1 : -1;
+ float thresholdedDistance = std::min(std::max<float>((snapState.m_targetOffset - snapState.m_initialOffset) * sign, snapThresholdLow), snapThresholdHigh);
+
+ float magnitude = clampedSnapMagnitude(thresholdedDistance);
+
+ float rawSnapDelta = std::max<float>(1, magnitude * std::sin(piFloat * progress));
+ if ((snapState.m_targetOffset < offset && offset - rawSnapDelta < snapState.m_targetOffset) || (snapState.m_targetOffset > offset && offset + rawSnapDelta > snapState.m_targetOffset))
+ return snapState.m_targetOffset - offset;
+
+ return sign * rawSnapDelta;
+}
+
+static inline float snapGlide(float progress, const ScrollSnapAnimatorState& snapState)
+{
+ // FIXME: We might want to investigate why -m_glidePhaseShift results in the behavior we want.
+ return ceil(snapState.m_glideMagnitude * (1.0f + std::cos(piFloat * progress - snapState.m_glidePhaseShift)));
+}
+
+// Computes the amount to scroll by when performing a "glide" operation, i.e. when a user releases the trackpad with an initial velocity. Here,
+// we want the scroll offset to animate directly to the snap point.
+//
+// The snap delta is a function of progress t, where: (1) t is equal to DISTANCE_TRAVELED / TOTAL_DISTANCE, (2) DISTANCE_TRAVELED is the distance
+// from the initialOffset to the current offset, and (3) TOTAL_DISTANCE is the distance from initialOffset to targetOffset.
+//
+// The general model of our gliding equation is delta(t) = MAGNITUDE * (1 + cos(PI * t + PHASE_SHIFT)). This was determined after examining the
+// momentum velocity curve as a function of progress. To compute MAGNITUDE and PHASE_SHIFT, we use initial velocity V0 and the final velocity VF,
+// both as wheel deltas (pixels per timestep). VF should be a small value (< 10) chosen based on the initial velocity and TOTAL_DISTANCE.
+// We also enforce the following constraints for the gliding equation:
+// 1. delta(0) = V0, since we want the initial velocity of the gliding animation to match the user's scroll velocity. The exception to this is
+// when the glide velocity is not enough to naturally reach the next snap point, and thus requires a boost (see initializeGlideParameters)
+// 2. delta(1) = VF, since at t=1, the animation has completed and we want the last wheel delta to match the final velocity VF. Note that this
+// doesn't guarantee that the final velocity will be exactly VF. However, assuming that the initial velocity is much less than TOTAL_DISTANCE,
+// the last wheel delta will be very close, if not the same, as VF.
+// For MAGNITUDE = (V0 + VF) / 2 and PHASE_SHIFT = arccos((V0 - VF) / (V0 + VF)), observe that delta(0) and delta(1) evaluate respectively to V0
+// and VF. Thus, we can express our gliding equation all in terms of V0, VF and t.
+float ScrollController::computeGlideDelta(ScrollEventAxis axis) const
+{
+ const ScrollSnapAnimatorState& snapState = scrollSnapPointState(axis);
+
+ LayoutUnit offset = m_client->scrollOffsetOnAxis(axis);
+ bool canComputeGlide = (snapState.m_initialOffset <= offset && offset < snapState.m_targetOffset) || (snapState.m_targetOffset < offset && offset <= snapState.m_initialOffset);
+ if (snapState.m_currentState != ScrollSnapState::Gliding || !canComputeGlide)
+ return 0;
+
+ const float progress = snapProgress(offset, snapState);
+ const float rawGlideDelta = snapGlide(progress, snapState);
+
+ float glideDelta = snapState.m_initialOffset < snapState.m_targetOffset ? std::max<float>(rawGlideDelta, 1) : std::min<float>(rawGlideDelta, -1);
+ if ((snapState.m_initialOffset < snapState.m_targetOffset && offset + glideDelta > snapState.m_targetOffset) || (snapState.m_initialOffset > snapState.m_targetOffset && offset + glideDelta < snapState.m_targetOffset))
+ return snapState.m_targetOffset - offset;
+
+ return glideDelta;
+}
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaScrollSnapAnimatorStatehfromrev181001trunkSourceWebCoreplatformmacAxisScrollSnapAnimatorh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.h (from rev 181001, trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.h) (0 => 181087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.h         (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.h        2015-03-05 19:32:27 UTC (rev 181087)
</span><span class="lines">@@ -0,0 +1,74 @@
</span><ins>+/*
+ * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ScrollSnapAnimatorState_h
+#define ScrollSnapAnimatorState_h
+
+#if ENABLE(CSS_SCROLL_SNAP)
+
+#include "AxisScrollSnapOffsets.h"
+#include "LayoutUnit.h"
+#include "PlatformWheelEvent.h"
+#include "ScrollTypes.h"
+
+namespace WebCore {
+
+enum class ScrollSnapState {
+ Snapping,
+ Gliding,
+ DestinationReached,
+ UserInteraction
+};
+
+struct ScrollSnapAnimatorState {
+ ScrollSnapAnimatorState(ScrollEventAxis, const Vector<LayoutUnit>&);
+
+ void pushInitialWheelDelta(float);
+ float averageInitialWheelDelta() const;
+ void clearInitialWheelDeltaWindow();
+
+ static const int wheelDeltaWindowSize = 3;
+
+ Vector<LayoutUnit> m_snapOffsets;
+ ScrollEventAxis m_axis;
+ // Used to track both snapping and gliding behaviors.
+ ScrollSnapState m_currentState;
+ LayoutUnit m_initialOffset;
+ LayoutUnit m_targetOffset;
+ // Used to track gliding behavior.
+ LayoutUnit m_beginTrackingWheelDeltaOffset;
+ int m_numWheelDeltasTracked;
+ float m_wheelDeltaWindow[wheelDeltaWindowSize];
+ float m_glideMagnitude;
+ float m_glidePhaseShift;
+ float m_glideInitialWheelDelta;
+ bool m_shouldOverrideWheelEvent;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(CSS_SCROLL_SNAP)
+
+#endif // ScrollSnapAnimatorState_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaScrollSnapAnimatorStatemmfromrev181001trunkSourceWebCoreplatformmacAxisScrollSnapAnimatormm"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.mm (from rev 181001, trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.mm) (0 => 181087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.mm         (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.mm        2015-03-05 19:32:27 UTC (rev 181087)
</span><span class="lines">@@ -0,0 +1,76 @@
</span><ins>+/*
+ * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ScrollSnapAnimatorState.h"
+
+#if ENABLE(CSS_SCROLL_SNAP)
+
+namespace WebCore {
+
+ScrollSnapAnimatorState::ScrollSnapAnimatorState(ScrollEventAxis axis, const Vector<LayoutUnit>& snapOffsets)
+ : m_snapOffsets(snapOffsets)
+ , m_axis(axis)
+ , m_currentState(ScrollSnapState::DestinationReached)
+ , m_initialOffset(0)
+ , m_targetOffset(0)
+ , m_beginTrackingWheelDeltaOffset(0)
+ , m_numWheelDeltasTracked(0)
+ , m_glideMagnitude(0)
+ , m_glidePhaseShift(0)
+ , m_glideInitialWheelDelta(0)
+ , m_shouldOverrideWheelEvent(false)
+{
+}
+
+void ScrollSnapAnimatorState::pushInitialWheelDelta(float wheelDelta)
+{
+ if (m_numWheelDeltasTracked < wheelDeltaWindowSize)
+ m_wheelDeltaWindow[m_numWheelDeltasTracked++] = wheelDelta;
+}
+
+float ScrollSnapAnimatorState::averageInitialWheelDelta() const
+{
+ if (!m_numWheelDeltasTracked)
+ return 0;
+
+ float sum = 0;
+ for (int i = 0; i < m_numWheelDeltasTracked; i++)
+ sum += m_wheelDeltaWindow[i];
+
+ return sum / m_numWheelDeltasTracked;
+}
+
+void ScrollSnapAnimatorState::clearInitialWheelDeltaWindow()
+{
+ for (int i = 0; i < m_numWheelDeltasTracked; i++)
+ m_wheelDeltaWindow[i] = 0;
+
+ m_numWheelDeltasTracked = 0;
+}
+
+} // namespace WebCore
+
+#endif // CSS_SCROLL_SNAP
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmacAxisScrollSnapAnimatorh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.h (181086 => 181087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.h        2015-03-05 18:59:57 UTC (rev 181086)
+++ trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.h        2015-03-05 19:32:27 UTC (rev 181087)
</span><span class="lines">@@ -1,108 +0,0 @@
</span><del>-/*
- * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef AxisScrollSnapAnimator_h
-#define AxisScrollSnapAnimator_h
-
-#if ENABLE(CSS_SCROLL_SNAP)
-
-#include "AxisScrollSnapOffsets.h"
-#include "LayoutUnit.h"
-#include "PlatformWheelEvent.h"
-#include "ScrollTypes.h"
-
-namespace WebCore {
-
-enum class ScrollSnapState {
- Snapping,
- Gliding,
- DestinationReached,
- UserInteraction
-};
-
-enum class WheelEventStatus {
- UserScrollBegin,
- UserScrolling,
- UserScrollEnd,
- InertialScrollBegin,
- InertialScrolling,
- InertialScrollEnd,
- Unknown
-};
-
-class AxisScrollSnapAnimatorClient {
-protected:
- virtual ~AxisScrollSnapAnimatorClient() { }
-
-public:
- virtual LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) = 0;
- virtual void immediateScrollOnAxis(ScrollEventAxis, float velocity) = 0;
- virtual void startScrollSnapTimer(ScrollEventAxis) = 0;
- virtual void stopScrollSnapTimer(ScrollEventAxis) = 0;
-};
-
-class AxisScrollSnapAnimator {
-public:
- AxisScrollSnapAnimator(AxisScrollSnapAnimatorClient*, const Vector<LayoutUnit>&, ScrollEventAxis);
- void handleWheelEvent(const PlatformWheelEvent&);
- bool shouldOverrideWheelEvent(const PlatformWheelEvent&) const;
- void scrollSnapAnimationUpdate();
-
-private:
- void beginScrollSnapAnimation(ScrollSnapState);
- void endScrollSnapAnimation(ScrollSnapState);
-
- float computeSnapDelta() const;
- float computeGlideDelta() const;
-
- void initializeGlideParameters(bool);
- void pushInitialWheelDelta(float);
- float averageInitialWheelDelta() const;
- void clearInitialWheelDeltaWindow();
-
- static const int wheelDeltaWindowSize = 3;
-
- AxisScrollSnapAnimatorClient* m_client;
- Vector<LayoutUnit> m_snapOffsets;
- ScrollEventAxis m_axis;
- // Used to track both snapping and gliding behaviors.
- ScrollSnapState m_currentState;
- LayoutUnit m_initialOffset;
- LayoutUnit m_targetOffset;
- // Used to track gliding behavior.
- LayoutUnit m_beginTrackingWheelDeltaOffset;
- int m_numWheelDeltasTracked;
- float m_wheelDeltaWindow[wheelDeltaWindowSize];
- float m_glideMagnitude;
- float m_glidePhaseShift;
- float m_glideInitialWheelDelta;
- bool m_shouldOverrideWheelEvent;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(CSS_SCROLL_SNAP)
-
-#endif // AxisScrollSnapAnimator_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformmacAxisScrollSnapAnimatormm"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.mm (181086 => 181087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.mm        2015-03-05 18:59:57 UTC (rev 181086)
+++ trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.mm        2015-03-05 19:32:27 UTC (rev 181087)
</span><span class="lines">@@ -1,304 +0,0 @@
</span><del>-/*
- * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "AxisScrollSnapAnimator.h"
-
-#if ENABLE(CSS_SCROLL_SNAP)
-
-namespace WebCore {
-
-const float inertialScrollPredictionFactor = 16.7;
-const float snapMagnitudeMax = 25;
-const float snapMagnitudeMin = 5;
-const float snapThresholdHigh = 1000;
-const float snapThresholdLow = 50;
-const float glideBoostMultiplier = 3.5;
-const float maxTargetWheelDelta = 7;
-const float minTargetWheelDelta = 3.5;
-const float initialToFinalMomentumFactor = 1.0 / 40.0;
-
-static inline WheelEventStatus toWheelEventStatus(PlatformWheelEventPhase phase, PlatformWheelEventPhase momentumPhase)
-{
- if (phase == PlatformWheelEventPhaseNone) {
- switch (momentumPhase) {
- case PlatformWheelEventPhaseBegan:
- return WheelEventStatus::InertialScrollBegin;
-
- case PlatformWheelEventPhaseChanged:
- return WheelEventStatus::InertialScrolling;
-
- case PlatformWheelEventPhaseEnded:
- return WheelEventStatus::InertialScrollEnd;
-
- default:
- return WheelEventStatus::Unknown;
- }
- }
- if (momentumPhase == PlatformWheelEventPhaseNone) {
- switch (phase) {
- case PlatformWheelEventPhaseBegan:
- case PlatformWheelEventPhaseMayBegin:
- return WheelEventStatus::UserScrollBegin;
-
- case PlatformWheelEventPhaseChanged:
- return WheelEventStatus::UserScrolling;
-
- case PlatformWheelEventPhaseEnded:
- case PlatformWheelEventPhaseCancelled:
- return WheelEventStatus::UserScrollEnd;
-
- default:
- return WheelEventStatus::Unknown;
- }
- }
- return WheelEventStatus::Unknown;
-}
-
-static inline float projectedInertialScrollDistance(float initialWheelDelta)
-{
- // FIXME: Experiments with inertial scrolling show a fairly consistent linear relationship between initial wheel delta and total distance scrolled.
- // In the future, we'll want to find a more accurate way of inertial scroll prediction.
- return inertialScrollPredictionFactor * initialWheelDelta;
-}
-
-AxisScrollSnapAnimator::AxisScrollSnapAnimator(AxisScrollSnapAnimatorClient* client, const Vector<LayoutUnit>& snapOffsets, ScrollEventAxis axis)
- : m_client(client)
- , m_snapOffsets(snapOffsets)
- , m_axis(axis)
- , m_currentState(ScrollSnapState::DestinationReached)
- , m_initialOffset(0)
- , m_targetOffset(0)
- , m_beginTrackingWheelDeltaOffset(0)
- , m_numWheelDeltasTracked(0)
- , m_glideMagnitude(0)
- , m_glidePhaseShift(0)
- , m_glideInitialWheelDelta(0)
- , m_shouldOverrideWheelEvent(false)
-{
-}
-
-void AxisScrollSnapAnimator::handleWheelEvent(const PlatformWheelEvent& event)
-{
- float wheelDelta = m_axis == ScrollEventAxis::Horizontal ? -event.deltaX() : -event.deltaY();
- WheelEventStatus wheelStatus = toWheelEventStatus(event.phase(), event.momentumPhase());
-
- switch (wheelStatus) {
- case WheelEventStatus::UserScrollBegin:
- case WheelEventStatus::UserScrolling:
- endScrollSnapAnimation(ScrollSnapState::UserInteraction);
- break;
-
- case WheelEventStatus::UserScrollEnd:
- beginScrollSnapAnimation(ScrollSnapState::Snapping);
- break;
-
- case WheelEventStatus::InertialScrollBegin:
- // Begin tracking wheel deltas for glide prediction.
- endScrollSnapAnimation(ScrollSnapState::UserInteraction);
- pushInitialWheelDelta(wheelDelta);
- m_beginTrackingWheelDeltaOffset = m_client->scrollOffsetOnAxis(m_axis);
- break;
-
- case WheelEventStatus::InertialScrolling:
- // 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)
- beginScrollSnapAnimation(ScrollSnapState::Gliding);
- }
- break;
-
- case WheelEventStatus::InertialScrollEnd:
- beginScrollSnapAnimation(ScrollSnapState::Snapping);
- clearInitialWheelDeltaWindow();
- m_shouldOverrideWheelEvent = false;
- break;
-
- case WheelEventStatus::Unknown:
- ASSERT_NOT_REACHED();
- break;
- }
-}
-
-bool AxisScrollSnapAnimator::shouldOverrideWheelEvent(const PlatformWheelEvent& event) const
-{
- return m_shouldOverrideWheelEvent && toWheelEventStatus(event.phase(), event.momentumPhase()) == WheelEventStatus::InertialScrolling;
-}
-
-void AxisScrollSnapAnimator::scrollSnapAnimationUpdate()
-{
- if (m_currentState == ScrollSnapState::DestinationReached)
- return;
-
- ASSERT(m_currentState == ScrollSnapState::Gliding || m_currentState == ScrollSnapState::Snapping);
- float delta = m_currentState == ScrollSnapState::Snapping ? computeSnapDelta() : computeGlideDelta();
- if (delta)
- m_client->immediateScrollOnAxis(m_axis, delta);
- else
- endScrollSnapAnimation(ScrollSnapState::DestinationReached);
-}
-
-void AxisScrollSnapAnimator::beginScrollSnapAnimation(ScrollSnapState newState)
-{
- ASSERT(newState == ScrollSnapState::Gliding || newState == ScrollSnapState::Snapping);
- LayoutUnit offset = m_client->scrollOffsetOnAxis(m_axis);
- float initialWheelDelta = newState == ScrollSnapState::Gliding ? averageInitialWheelDelta() : 0;
- LayoutUnit projectedScrollDestination = newState == ScrollSnapState::Gliding ? m_beginTrackingWheelDeltaOffset + LayoutUnit(projectedInertialScrollDistance(initialWheelDelta)) : offset;
- if (m_snapOffsets.isEmpty())
- return;
-
- projectedScrollDestination = std::min(std::max(projectedScrollDestination, m_snapOffsets.first()), m_snapOffsets.last());
- m_initialOffset = offset;
- m_targetOffset = closestSnapOffset<LayoutUnit, float>(m_snapOffsets, projectedScrollDestination, initialWheelDelta);
- if (m_initialOffset == m_targetOffset)
- return;
-
- m_currentState = newState;
- if (newState == ScrollSnapState::Gliding) {
- m_shouldOverrideWheelEvent = true;
- m_glideInitialWheelDelta = initialWheelDelta;
- bool glideRequiresBoost;
- if (initialWheelDelta > 0)
- glideRequiresBoost = projectedScrollDestination - offset < m_targetOffset - projectedScrollDestination;
- else
- glideRequiresBoost = offset - projectedScrollDestination < projectedScrollDestination - m_targetOffset;
-
- initializeGlideParameters(glideRequiresBoost);
- clearInitialWheelDeltaWindow();
- }
- m_client->startScrollSnapTimer(m_axis);
-}
-
-void AxisScrollSnapAnimator::endScrollSnapAnimation(ScrollSnapState newState)
-{
- ASSERT(newState == ScrollSnapState::DestinationReached || newState == ScrollSnapState::UserInteraction);
- if (m_currentState == ScrollSnapState::Gliding)
- clearInitialWheelDeltaWindow();
-
- m_currentState = newState;
- m_client->stopScrollSnapTimer(m_axis);
-}
-
-// Computes the amount to scroll by when performing a "snap" operation, i.e. when a user releases the trackpad without flicking. The snap delta
-// is a function of progress t, where t is equal to DISTANCE_TRAVELED / TOTAL_DISTANCE, DISTANCE_TRAVELED is the distance from the initialOffset
-// to the current offset, and TOTAL_DISTANCE is the distance from initialOffset to targetOffset. The snapping equation is as follows:
-// delta(t) = MAGNITUDE * sin(PI * t). MAGNITUDE indicates the top speed reached near the middle of the animation (t = 0.5), and is a linear
-// relationship of the distance traveled, clamped by arbitrary min and max values.
-float AxisScrollSnapAnimator::computeSnapDelta() const
-{
- LayoutUnit offset = m_client->scrollOffsetOnAxis(m_axis);
- bool canComputeSnap = (m_initialOffset <= offset && offset < m_targetOffset) || (m_targetOffset < offset && offset <= m_initialOffset);
- if (m_currentState != ScrollSnapState::Snapping || !canComputeSnap)
- return 0;
-
- int sign = m_initialOffset < m_targetOffset ? 1 : -1;
- float progress = ((float)(offset - m_initialOffset)) / (m_targetOffset - m_initialOffset);
- // Threshold the distance before computing magnitude, so only distances within a certain range are considered.
- float thresholdedDistance = std::min(std::max<float>((m_targetOffset - m_initialOffset) * sign, snapThresholdLow), snapThresholdHigh);
- float magnitude = snapMagnitudeMin + (snapMagnitudeMax - snapMagnitudeMin) * (thresholdedDistance - snapThresholdLow) / (snapThresholdHigh - snapThresholdLow);
- float rawSnapAmount = std::max<float>(1, magnitude * sin(piFloat * progress));
- if ((m_targetOffset < offset && offset - rawSnapAmount < m_targetOffset) || (m_targetOffset > offset && offset + rawSnapAmount > m_targetOffset))
- return m_targetOffset - offset;
-
- return sign * rawSnapAmount;
-}
-
-// Computes the amount to scroll by when performing a "glide" operation, i.e. when a user releases the trackpad with an initial velocity. Here,
-// we want the scroll offset to animate directly to the snap point. The snap delta is a function of progress t, where t is equal to
-// DISTANCE_TRAVELED / TOTAL_DISTANCE, DISTANCE_TRAVELED is the distance from the initialOffset to the current offset, and TOTAL_DISTANCE is
-// the distance from initialOffset to targetOffset.
-// The general model of our gliding equation is delta(t) = MAGNITUDE * (1 + cos(PI * t + PHASE_SHIFT)). This was determined after examining the
-// momentum velocity curve as a function of progress. To compute MAGNITUDE and PHASE_SHIFT, we use initial velocity V0 and the final velocity VF,
-// both as wheel deltas (pixels per timestep). VF should be a small value (< 10) chosen based on the initial velocity and TOTAL_DISTANCE.
-// We also enforce the following constraints for the gliding equation:
-// 1. delta(0) = V0, since we want the initial velocity of the gliding animation to match the user's scroll velocity. The exception to this is
-// when the glide velocity is not enough to naturally reach the next snap point, and thus requires a boost (see initializeGlideParameters)
-// 2. delta(1) = VF, since at t=1, the animation has completed and we want the last wheel delta to match the final velocity VF. Note that this
-// doesn't guarantee that the final velocity will be exactly VF. However, assuming that the initial velocity is much less than TOTAL_DISTANCE,
-// the last wheel delta will be very close, if not the same, as VF.
-// For MAGNITUDE = (V0 + VF) / 2 and PHASE_SHIFT = arccos((V0 - VF) / (V0 + VF)), observe that delta(0) and delta(1) evaluate respectively to V0
-// and VF. Thus, we can express our gliding equation all in terms of V0, VF and t.
-float AxisScrollSnapAnimator::computeGlideDelta() const
-{
- LayoutUnit offset = m_client->scrollOffsetOnAxis(m_axis);
- bool canComputeGlide = (m_initialOffset <= offset && offset < m_targetOffset) || (m_targetOffset < offset && offset <= m_initialOffset);
- if (m_currentState != ScrollSnapState::Gliding || !canComputeGlide)
- return 0;
-
- float progress = ((float)(offset - m_initialOffset)) / (m_targetOffset - m_initialOffset);
- // 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;
-
- return shift;
-}
-
-void AxisScrollSnapAnimator::initializeGlideParameters(bool shouldIncreaseInitialWheelDelta)
-{
- // FIXME: Glide boost is a hacky way to speed up natural scrolling velocity. We should find a better way to accomplish this.
- if (shouldIncreaseInitialWheelDelta)
- m_glideInitialWheelDelta *= glideBoostMultiplier;
-
- // FIXME: There must be a better way to determine a good target delta than multiplying by a factor and clamping to min/max values.
- float targetFinalWheelDelta = initialToFinalMomentumFactor * (m_glideInitialWheelDelta < 0 ? -m_glideInitialWheelDelta : m_glideInitialWheelDelta);
- targetFinalWheelDelta = (m_glideInitialWheelDelta > 0 ? 1 : -1) * std::min(std::max(targetFinalWheelDelta, minTargetWheelDelta), maxTargetWheelDelta);
- m_glideMagnitude = (m_glideInitialWheelDelta + targetFinalWheelDelta) / 2;
- m_glidePhaseShift = acos((m_glideInitialWheelDelta - targetFinalWheelDelta) / (m_glideInitialWheelDelta + targetFinalWheelDelta));
-}
-
-void AxisScrollSnapAnimator::pushInitialWheelDelta(float wheelDelta)
-{
- if (m_numWheelDeltasTracked < wheelDeltaWindowSize)
- m_wheelDeltaWindow[m_numWheelDeltasTracked++] = wheelDelta;
-}
-
-float AxisScrollSnapAnimator::averageInitialWheelDelta() const
-{
- if (!m_numWheelDeltasTracked)
- return 0;
-
- float sum = 0;
- for (int i = 0; i < m_numWheelDeltasTracked; i++)
- sum += m_wheelDeltaWindow[i];
-
- return sum / m_numWheelDeltasTracked;
-}
-
-void AxisScrollSnapAnimator::clearInitialWheelDeltaWindow()
-{
- for (int i = 0; i < m_numWheelDeltasTracked; i++)
- m_wheelDeltaWindow[i] = 0;
-
- m_numWheelDeltasTracked = 0;
-}
-
-} // namespace WebCore
-
-#endif // CSS_SCROLL_SNAP
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformmacScrollAnimatorMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h (181086 => 181087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h        2015-03-05 18:59:57 UTC (rev 181086)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h        2015-03-05 19:32:27 UTC (rev 181087)
</span><span class="lines">@@ -147,8 +147,6 @@
</span><span class="cx"> virtual void immediateScrollBy(const FloatSize&) override;
</span><span class="cx"> virtual void adjustScrollPositionToBoundsIfNecessary() override;
</span><span class="cx">
</span><del>- bool pinnedInDirection(float deltaX, float deltaY);
-
</del><span class="cx"> bool isAlreadyPinnedInDirectionOfGesture(const PlatformWheelEvent&, ScrollEventAxis);
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacScrollAnimatorMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (181086 => 181087)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm        2015-03-05 18:59:57 UTC (rev 181086)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm        2015-03-05 19:32:27 UTC (rev 181087)
</span><span class="lines">@@ -1102,19 +1102,19 @@
</span><span class="cx"> return didHandleEvent;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool ScrollAnimatorMac::pinnedInDirection(float deltaX, float deltaY)
</del><ins>+bool ScrollAnimatorMac::pinnedInDirection(const FloatSize& direction)
</ins><span class="cx"> {
</span><span class="cx"> FloatSize limitDelta;
</span><del>- if (std::fabsf(deltaY) >= fabsf(deltaX)) {
- if (deltaY < 0) {
</del><ins>+ if (fabsf(direction.height()) >= fabsf(direction.width())) {
+ if (direction.height() < 0) {
</ins><span class="cx"> // We are trying to scroll up. Make sure we are not pinned to the top
</span><span class="cx"> limitDelta.setHeight(m_scrollableArea.visibleContentRect().y() + m_scrollableArea.scrollOrigin().y());
</span><span class="cx"> } else {
</span><span class="cx"> // We are trying to scroll down. Make sure we are not pinned to the bottom
</span><span class="cx"> limitDelta.setHeight(m_scrollableArea.totalContentsSize().height() - (m_scrollableArea.visibleContentRect().maxY() + m_scrollableArea.scrollOrigin().y()));
</span><span class="cx"> }
</span><del>- } else if (deltaX != 0) {
- if (deltaX < 0) {
</del><ins>+ } else if (direction.width()) {
+ if (direction.width() < 0) {
</ins><span class="cx"> // We are trying to scroll left. Make sure we are not pinned to the left
</span><span class="cx"> limitDelta.setWidth(m_scrollableArea.visibleContentRect().x() + m_scrollableArea.scrollOrigin().x());
</span><span class="cx"> } else {
</span><span class="lines">@@ -1123,7 +1123,7 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if ((deltaX != 0 || deltaY != 0) && (limitDelta.width() < 1 && limitDelta.height() < 1))
</del><ins>+ if ((direction.width() || direction.height()) && (limitDelta.width() < 1 && limitDelta.height() < 1))
</ins><span class="cx"> return true;
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="lines">@@ -1216,11 +1216,6 @@
</span><span class="cx"> return m_scrollableArea.overhangAmount();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool ScrollAnimatorMac::pinnedInDirection(const FloatSize& direction)
-{
- return pinnedInDirection(direction.width(), direction.height());
-}
-
</del><span class="cx"> bool ScrollAnimatorMac::canScrollHorizontally()
</span><span class="cx"> {
</span><span class="cx"> Scrollbar* scrollbar = m_scrollableArea.horizontalScrollbar();
</span></span></pre>
</div>
</div>
</body>
</html>