<!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>[180915] 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/180915">180915</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-03-02 19:29:41 -0800 (Mon, 02 Mar 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Unreviewed, rolling out <a href="http://trac.webkit.org/projects/webkit/changeset/180902">r180902</a>.
https://bugs.webkit.org/show_bug.cgi?id=142205
It broke scrolling in some cases. See bug 142202 for details.
(Requested by bdash on #webkit).
Reverted changeset:
"Move scroll animating functions from ScrollAnimator to
ScrollController"
https://bugs.webkit.org/show_bug.cgi?id=142102
http://trac.webkit.org/changeset/180902</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="#trunkSourceWebCorepagemacEventHandlerMacmm">trunk/Source/WebCore/page/mac/EventHandlerMac.mm</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="#trunkSourceWebCoreplatformmacAxisScrollSnapAnimatorh">trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacAxisScrollSnapAnimatormm">trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.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="#trunkSourceWebCoreplatformmacScrollControllerh">trunk/Source/WebCore/platform/mac/ScrollController.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacScrollControllermm">trunk/Source/WebCore/platform/mac/ScrollController.mm</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<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>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (180914 => 180915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-03-03 03:25:21 UTC (rev 180914)
+++ trunk/Source/WebCore/ChangeLog        2015-03-03 03:29:41 UTC (rev 180915)
</span><span class="lines">@@ -1,5 +1,20 @@
</span><span class="cx"> 2015-03-02 Commit Queue <commit-queue@webkit.org>
</span><span class="cx">
</span><ins>+ Unreviewed, rolling out r180902.
+ https://bugs.webkit.org/show_bug.cgi?id=142205
+
+ It broke scrolling in some cases. See bug 142202 for details.
+ (Requested by bdash on #webkit).
+
+ Reverted changeset:
+
+ "Move scroll animating functions from ScrollAnimator to
+ ScrollController"
+ https://bugs.webkit.org/show_bug.cgi?id=142102
+ http://trac.webkit.org/changeset/180902
+
+2015-03-02 Commit Queue <commit-queue@webkit.org>
+
</ins><span class="cx"> Unreviewed, rolling out r180911.
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=142204
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (180914 => 180915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-03-03 03:25:21 UTC (rev 180914)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-03-03 03:29:41 UTC (rev 180915)
</span><span class="lines">@@ -786,6 +786,8 @@
</span><span class="cx">                 1A927FD31416A15B003A83C8 /* npruntime.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A927FD01416A15B003A83C8 /* npruntime.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 1A927FD41416A15B003A83C8 /* nptypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A927FD11416A15B003A83C8 /* nptypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 1A98956B0AA78F80005EF5EF /* URLCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A98956A0AA78F80005EF5EF /* URLCF.cpp */; };
</span><ins>+                1AA84F04143BA7BD0051D153 /* ScrollController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA84F02143BA7BD0051D153 /* ScrollController.mm */; };
+                1AA84F05143BA7BD0051D153 /* ScrollController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA84F03143BA7BD0051D153 /* ScrollController.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 1AA8799011CBE846003C664F /* PluginStrategy.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA8798F11CBE846003C664F /* PluginStrategy.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 1AAADDA314DB409F00AF64B3 /* ScrollingTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAADDA114DB409F00AF64B3 /* ScrollingTree.cpp */; };
</span><span class="cx">                 1AAADDA414DB409F00AF64B3 /* ScrollingTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAADDA214DB409F00AF64B3 /* ScrollingTree.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -2443,8 +2445,6 @@
</span><span class="cx">                 7A74ECBD101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A74ECBC101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp */; };
</span><span class="cx">                 7A93868518DCC14500B8263D /* VTTScanner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A93868218DCC14500B8263D /* VTTScanner.cpp */; };
</span><span class="cx">                 7A93868618DCC14500B8263D /* VTTScanner.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A93868318DCC14500B8263D /* VTTScanner.h */; };
</span><del>-                7A9ADFF31AA1163800D2733C /* ScrollController.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AFFA4111AA1039D00F0125B /* ScrollController.h */; settings = {ATTRIBUTES = (Private, ); }; };
-                7A9ADFF41AA1163B00D2733C /* ScrollController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFA4121AA1039D00F0125B /* ScrollController.mm */; };
</del><span class="cx">                 7AA3A699194A64E7001CBD24 /* TileController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AA3A695194A64E7001CBD24 /* TileController.cpp */; };
</span><span class="cx">                 7AA3A69A194A64E7001CBD24 /* TileController.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AA3A696194A64E7001CBD24 /* TileController.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 7AA3A69B194A64E7001CBD24 /* TileGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AA3A697194A64E7001CBD24 /* TileGrid.cpp */; };
</span><span class="lines">@@ -7809,6 +7809,8 @@
</span><span class="cx">                 1A927FD01416A15B003A83C8 /* npruntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = npruntime.h; sourceTree = "<group>"; };
</span><span class="cx">                 1A927FD11416A15B003A83C8 /* nptypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nptypes.h; sourceTree = "<group>"; };
</span><span class="cx">                 1A98956A0AA78F80005EF5EF /* URLCF.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = URLCF.cpp; sourceTree = "<group>"; };
</span><ins>+                1AA84F02143BA7BD0051D153 /* ScrollController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollController.mm; sourceTree = "<group>"; };
+                1AA84F03143BA7BD0051D153 /* ScrollController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollController.h; sourceTree = "<group>"; };
</ins><span class="cx">                 1AA8798F11CBE846003C664F /* PluginStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginStrategy.h; sourceTree = "<group>"; };
</span><span class="cx">                 1AAADDA114DB409F00AF64B3 /* ScrollingTree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingTree.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 1AAADDA214DB409F00AF64B3 /* ScrollingTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingTree.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -9665,8 +9667,6 @@
</span><span class="cx">                 7AF9B20918CFB5F200C64BEF /* JSVTTRegion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSVTTRegion.h; sourceTree = "<group>"; };
</span><span class="cx">                 7AF9B20A18CFB5F300C64BEF /* JSVTTRegionList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSVTTRegionList.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7AF9B20B18CFB5F300C64BEF /* JSVTTRegionList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSVTTRegionList.h; sourceTree = "<group>"; };
</span><del>-                7AFFA4111AA1039D00F0125B /* ScrollController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollController.h; sourceTree = "<group>"; };
-                7AFFA4121AA1039D00F0125B /* ScrollController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollController.mm; sourceTree = "<group>"; };
</del><span class="cx">                 7C2BDD3B17C7F98B0038FF15 /* JSDOMGlobalObjectTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMGlobalObjectTask.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7C2BDD3C17C7F98B0038FF15 /* JSDOMGlobalObjectTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMGlobalObjectTask.h; sourceTree = "<group>"; };
</span><span class="cx">                 7C3B796F1908757B00B47A2D /* UserMessageHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMessageHandler.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -16587,6 +16587,8 @@
</span><span class="cx">                                 BC51156D12B1749C00C96754 /* ScrollAnimatorMac.mm */,
</span><span class="cx">                                 BC8B853C0E7C7F1100AB6984 /* ScrollbarThemeMac.h */,
</span><span class="cx">                                 BCEF869E0E844E9D00A85CD5 /* ScrollbarThemeMac.mm */,
</span><ins>+                                1AA84F03143BA7BD0051D153 /* ScrollController.h */,
+                                1AA84F02143BA7BD0051D153 /* ScrollController.mm */,
</ins><span class="cx">                                 9353676A09AED88B00D35CD6 /* ScrollViewMac.mm */,
</span><span class="cx">                                 077AF14118F4B1BB0001ED61 /* SerializedPlatformRepresentationMac.h */,
</span><span class="cx">                                 077AF14218F4B1BB0001ED61 /* SerializedPlatformRepresentationMac.mm */,
</span><span class="lines">@@ -18696,8 +18698,6 @@
</span><span class="cx">                                 1A0409F21A43675C009E47F3 /* MachSendRight.cpp */,
</span><span class="cx">                                 1A0409DB1A4360B5009E47F3 /* MachSendRight.h */,
</span><span class="cx">                                 ADB6B29718FB90240081963E /* MemoryPressureHandlerCocoa.mm */,
</span><del>-                                7AFFA4111AA1039D00F0125B /* ScrollController.h */,
-                                7AFFA4121AA1039D00F0125B /* ScrollController.mm */,
</del><span class="cx">                                 5D5975B119635F1100D00878 /* SystemVersion.h */,
</span><span class="cx">                                 5D5975B219635F1100D00878 /* SystemVersion.mm */,
</span><span class="cx">                                 7CC564B918BAC720001B9652 /* TelephoneNumberDetectorCocoa.cpp */,
</span><span class="lines">@@ -24648,7 +24648,6 @@
</span><span class="cx">                                 A8EA7CB50A192B9C00A8EF5F /* HTMLParagraphElement.h in Headers */,
</span><span class="cx">                                 A871D4580A127CBC00B12A68 /* HTMLParamElement.h in Headers */,
</span><span class="cx">                                 93E2A307123E9DC0009FE12A /* HTMLParserIdioms.h in Headers */,
</span><del>-                                7A9ADFF31AA1163800D2733C /* ScrollController.h in Headers */,
</del><span class="cx">                                 973F418A169B95FF0006BF60 /* HTMLParserOptions.h in Headers */,
</span><span class="cx">                                 977B3871122883E900B81FF8 /* HTMLParserScheduler.h in Headers */,
</span><span class="cx">                                 A871D4560A127CBC00B12A68 /* HTMLPlugInElement.h in Headers */,
</span><span class="lines">@@ -26102,6 +26101,7 @@
</span><span class="cx">                                 BC8B853E0E7C7F1100AB6984 /* ScrollbarThemeMac.h in Headers */,
</span><span class="cx">                                 0FE71406142170B800DB33BA /* ScrollbarThemeMock.h in Headers */,
</span><span class="cx">                                 5D925B680F64D4DD00B847F0 /* ScrollBehavior.h in Headers */,
</span><ins>+                                1AA84F05143BA7BD0051D153 /* ScrollController.h in Headers */,
</ins><span class="cx">                                 0F605AED15F94848004DF0C0 /* ScrollingConstraints.h in Headers */,
</span><span class="cx">                                 1AF62EE814DA22A70041556C /* ScrollingCoordinator.h in Headers */,
</span><span class="cx">                                 0FC4E40D187F82E10045882C /* ScrollingCoordinatorIOS.h in Headers */,
</span><span class="lines">@@ -27496,7 +27496,6 @@
</span><span class="cx">                                 E19AC3F41824DC7900349426 /* CryptoAlgorithmSHA512.cpp in Sources */,
</span><span class="cx">                                 E1FE13641834351100892F13 /* CryptoDigestMac.cpp in Sources */,
</span><span class="cx">                                 E157A8E418173A3A009F821D /* CryptoKey.cpp in Sources */,
</span><del>-                                7A9ADFF41AA1163B00D2733C /* ScrollController.mm in Sources */,
</del><span class="cx">                                 E125F84D1824289D00D84CD9 /* CryptoKeyAES.cpp in Sources */,
</span><span class="cx">                                 E125F863182C303A00D84CD9 /* CryptoKeyDataOctetSequence.cpp in Sources */,
</span><span class="cx">                                 E1C266DE18319F31003F8B33 /* CryptoKeyDataRSAComponents.cpp in Sources */,
</span><span class="lines">@@ -29509,6 +29508,7 @@
</span><span class="cx">                                 BCEF869F0E844E9D00A85CD5 /* ScrollbarThemeMac.mm in Sources */,
</span><span class="cx">                                 0FE71405142170B800DB33BA /* ScrollbarThemeMock.cpp in Sources */,
</span><span class="cx">                                 5D925B670F64D4DD00B847F0 /* ScrollBehavior.cpp in Sources */,
</span><ins>+                                1AA84F04143BA7BD0051D153 /* ScrollController.mm in Sources */,
</ins><span class="cx">                                 0F605AEC15F94848004DF0C0 /* ScrollingConstraints.cpp in Sources */,
</span><span class="cx">                                 1AF62EE714DA22A70041556C /* ScrollingCoordinator.cpp in Sources */,
</span><span class="cx">                                 0FC4E40E187F82E10045882C /* ScrollingCoordinatorIOS.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorepagemacEventHandlerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/mac/EventHandlerMac.mm (180914 => 180915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/mac/EventHandlerMac.mm        2015-03-03 03:25:21 UTC (rev 180914)
+++ trunk/Source/WebCore/page/mac/EventHandlerMac.mm        2015-03-03 03:29:41 UTC (rev 180915)
</span><span class="lines">@@ -961,12 +961,6 @@
</span><span class="cx">
</span><span class="cx"> bool didHandleEvent = view ? view->wheelEvent(wheelEvent) : false;
</span><span class="cx"> m_isHandlingWheelEvent = false;
</span><del>-
-#if ENABLE(CSS_SCROLL_SNAP)
- if (scrollableArea)
- platformNotifySnapIfNecessary(wheelEvent, *scrollableArea);
-#endif
-
</del><span class="cx"> return didHandleEvent;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorepagescrollingmacScrollingTreeFrameScrollingNodeMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h (180914 => 180915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h        2015-03-03 03:25:21 UTC (rev 180914)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h        2015-03-03 03:29:41 UTC (rev 180915)
</span><span class="lines">@@ -61,6 +61,8 @@
</span><span class="cx"> virtual IntPoint absoluteScrollPosition() override;
</span><span class="cx"> virtual void immediateScrollBy(const FloatSize&) override;
</span><span class="cx"> virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) override;
</span><ins>+ virtual void startSnapRubberbandTimer() override;
+ virtual void stopSnapRubberbandTimer() override;
</ins><span class="cx"> virtual void adjustScrollPositionToBoundsIfNecessary() override;
</span><span class="cx">
</span><span class="cx"> virtual FloatPoint scrollPosition() const override;
</span><span class="lines">@@ -78,14 +80,10 @@
</span><span class="cx">
</span><span class="cx"> bool isAlreadyPinnedInDirectionOfGesture(const PlatformWheelEvent&, ScrollEventAxis);
</span><span class="cx">
</span><del>-#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
- LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) override;
- void immediateScrollOnAxis(ScrollEventAxis, float delta) override;
-#endif
-
</del><span class="cx"> void logExposedUnfilledArea();
</span><span class="cx">
</span><span class="cx"> ScrollController m_scrollController;
</span><ins>+ RetainPtr<CFRunLoopTimerRef> m_snapRubberbandTimer;
</ins><span class="cx">
</span><span class="cx"> RetainPtr<CALayer> m_scrollLayer;
</span><span class="cx"> RetainPtr<CALayer> m_scrolledContentsLayer;
</span></span></pre></div>
<a id="trunkSourceWebCorepagescrollingmacScrollingTreeFrameScrollingNodeMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm (180914 => 180915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm        2015-03-03 03:25:21 UTC (rev 180914)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm        2015-03-03 03:29:41 UTC (rev 180915)
</span><span class="lines">@@ -66,6 +66,8 @@
</span><span class="cx">
</span><span class="cx"> ScrollingTreeFrameScrollingNodeMac::~ScrollingTreeFrameScrollingNodeMac()
</span><span class="cx"> {
</span><ins>+ if (m_snapRubberbandTimer)
+ CFRunLoopTimerInvalidate(m_snapRubberbandTimer.get());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void ScrollingTreeFrameScrollingNodeMac::updateBeforeChildren(const ScrollingStateNode& stateNode)
</span><span class="lines">@@ -294,6 +296,32 @@
</span><span class="cx"> scrollByWithoutContentEdgeConstraints(offset);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void ScrollingTreeFrameScrollingNodeMac::startSnapRubberbandTimer()
+{
+ ASSERT(!m_snapRubberbandTimer);
+
+ CFTimeInterval timerInterval = 1.0 / 60.0;
+
+ m_snapRubberbandTimer = adoptCF(CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + timerInterval, timerInterval, 0, 0, ^(CFRunLoopTimerRef) {
+ m_scrollController.snapRubberBandTimerFired();
+ }));
+ CFRunLoopAddTimer(CFRunLoopGetCurrent(), m_snapRubberbandTimer.get(), kCFRunLoopDefaultMode);
+}
+
+void ScrollingTreeFrameScrollingNodeMac::stopSnapRubberbandTimer()
+{
+ if (!m_snapRubberbandTimer)
+ return;
+
+ scrollingTree().setMainFrameIsRubberBanding(false);
+
+ // Since the rubberband timer has stopped, totalContentsSizeForRubberBand can be synchronized with totalContentsSize.
+ setTotalContentsSizeForRubberBand(totalContentsSize());
+
+ CFRunLoopTimerInvalidate(m_snapRubberbandTimer.get());
+ m_snapRubberbandTimer = nullptr;
+}
+
</ins><span class="cx"> void ScrollingTreeFrameScrollingNodeMac::adjustScrollPositionToBoundsIfNecessary()
</span><span class="cx"> {
</span><span class="cx"> FloatPoint currentScrollPosition = absoluteScrollPosition();
</span><span class="lines">@@ -512,19 +540,6 @@
</span><span class="cx"> WTFLogAlways("SCROLLING: Wheel event handler count changed. Time: %f Count: %u\n", WTF::monotonicallyIncreasingTime(), count);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
-LayoutUnit ScrollingTreeFrameScrollingNodeMac::scrollOffsetOnAxis(ScrollEventAxis)
-{
- // Temporary stub until http://webkit.org/b/141973.
- return 0;
-}
-
-void ScrollingTreeFrameScrollingNodeMac::immediateScrollOnAxis(ScrollEventAxis, float)
-{
- // Temporary stub until http://webkit.org/b/141973.
-}
-#endif
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(ASYNC_SCROLLING) && PLATFORM(MAC)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScrollAnimatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScrollAnimator.cpp (180914 => 180915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollAnimator.cpp        2015-03-03 03:25:21 UTC (rev 180914)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp        2015-03-03 03:29:41 UTC (rev 180915)
</span><span class="lines">@@ -49,9 +49,6 @@
</span><span class="cx">
</span><span class="cx"> ScrollAnimator::ScrollAnimator(ScrollableArea& scrollableArea)
</span><span class="cx"> : m_scrollableArea(scrollableArea)
</span><del>-#if (ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)) && PLATFORM(MAC)
- , m_scrollController(this)
-#endif
</del><span class="cx"> , m_currentPosX(0)
</span><span class="cx"> , m_currentPosY(0)
</span><span class="cx"> {
</span><span class="lines">@@ -84,16 +81,28 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
</span><del>-bool ScrollAnimator::processWheelEventForScrollSnap(const PlatformWheelEvent& wheelEvent)
</del><ins>+void ScrollAnimator::processWheelEventForScrollSnap(const PlatformWheelEvent& wheelEvent)
</ins><span class="cx"> {
</span><del>- return m_scrollController.processWheelEventForScrollSnap(wheelEvent);
</del><ins>+ if (m_verticalScrollSnapAnimator)
+ m_verticalScrollSnapAnimator->handleWheelEvent(wheelEvent);
+ if (m_horizontalScrollSnapAnimator)
+ m_horizontalScrollSnapAnimator->handleWheelEvent(wheelEvent);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> bool ScrollAnimator::handleWheelEvent(const PlatformWheelEvent& e)
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
</span><del>- m_scrollController.processWheelEventForScrollSnap(e);
</del><ins>+ if (m_verticalScrollSnapAnimator) {
+ m_verticalScrollSnapAnimator->handleWheelEvent(e);
+ if (m_verticalScrollSnapAnimator->shouldOverrideWheelEvent(e))
+ return false;
+ }
+ if (m_horizontalScrollSnapAnimator) {
+ m_horizontalScrollSnapAnimator->handleWheelEvent(e);
+ if (m_horizontalScrollSnapAnimator->shouldOverrideWheelEvent(e))
+ return false;
+ }
</ins><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx"> // Events in the PlatformWheelEventPhaseMayBegin phase have no deltas, and therefore never passes through the scroll handling logic below.
</span><span class="lines">@@ -174,15 +183,30 @@
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
</span><span class="cx"> void ScrollAnimator::updateScrollAnimatorsAndTimers()
</span><span class="cx"> {
</span><del>- m_scrollController.updateScrollAnimatorsAndTimers(m_scrollableArea);
</del><ins>+ // FIXME: Currently, scroll snap animators are recreated even though the snap offsets alone can be updated.
+ if (m_scrollableArea.horizontalSnapOffsets()) {
+ m_horizontalScrollSnapAnimator = std::make_unique<AxisScrollSnapAnimator>(this, m_scrollableArea.horizontalSnapOffsets(), ScrollEventAxis::Horizontal);
+ m_horizontalScrollSnapTimer = std::make_unique<Timer>(*this, &ScrollAnimator::horizontalScrollSnapTimerFired);
+ } else if (m_horizontalScrollSnapAnimator) {
+ m_horizontalScrollSnapAnimator = nullptr;
+ m_horizontalScrollSnapTimer = nullptr;
+ }
+ if (m_scrollableArea.verticalSnapOffsets()) {
+ m_verticalScrollSnapAnimator = std::make_unique<AxisScrollSnapAnimator>(this, m_scrollableArea.verticalSnapOffsets(), ScrollEventAxis::Vertical);
+ m_verticalScrollSnapTimer = std::make_unique<Timer>(*this, &ScrollAnimator::verticalScrollSnapTimerFired);
+ } else if (m_verticalScrollSnapAnimator) {
+ m_verticalScrollSnapAnimator = nullptr;
+ m_verticalScrollSnapTimer = nullptr;
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-LayoutUnit ScrollAnimator::scrollOffsetOnAxis(ScrollEventAxis axis)
</del><ins>+LayoutUnit ScrollAnimator::scrollOffsetInAxis(ScrollEventAxis axis)
</ins><span class="cx"> {
</span><del>- return axis == ScrollEventAxis::Horizontal ? m_currentPosX : m_currentPosY;
</del><ins>+ FloatPoint currentPosition = this->currentPosition();
+ return axis == ScrollEventAxis::Horizontal ? currentPosition.x() : currentPosition.y();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void ScrollAnimator::immediateScrollOnAxis(ScrollEventAxis axis, float delta)
</del><ins>+void ScrollAnimator::immediateScrollInAxis(ScrollEventAxis axis, float delta)
</ins><span class="cx"> {
</span><span class="cx"> FloatPoint currentPosition = this->currentPosition();
</span><span class="cx"> if (axis == ScrollEventAxis::Horizontal)
</span><span class="lines">@@ -190,6 +214,30 @@
</span><span class="cx"> else
</span><span class="cx"> scrollToOffsetWithoutAnimation(FloatPoint(currentPosition.x(), currentPosition.y() + delta));
</span><span class="cx"> }
</span><ins>+
+void ScrollAnimator::startScrollSnapTimer(ScrollEventAxis axis)
+{
+ Timer* scrollSnapTimer = axis == ScrollEventAxis::Horizontal ? m_horizontalScrollSnapTimer.get() : m_verticalScrollSnapTimer.get();
+ if (!scrollSnapTimer->isActive())
+ scrollSnapTimer->startRepeating(1.0 / 60.0);
+}
+
+void ScrollAnimator::stopScrollSnapTimer(ScrollEventAxis axis)
+{
+ Timer* scrollSnapTimer = axis == ScrollEventAxis::Horizontal ? m_horizontalScrollSnapTimer.get() : m_verticalScrollSnapTimer.get();
+ if (scrollSnapTimer->isActive())
+ scrollSnapTimer->stop();
+}
+
+void ScrollAnimator::horizontalScrollSnapTimerFired()
+{
+ m_horizontalScrollSnapAnimator->scrollSnapAnimationUpdate();
+}
+
+void ScrollAnimator::verticalScrollSnapTimerFired()
+{
+ m_verticalScrollSnapAnimator->scrollSnapAnimationUpdate();
+}
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScrollAnimatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScrollAnimator.h (180914 => 180915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollAnimator.h        2015-03-03 03:25:21 UTC (rev 180914)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h        2015-03-03 03:29:41 UTC (rev 180915)
</span><span class="lines">@@ -33,14 +33,14 @@
</span><span class="cx"> #define ScrollAnimator_h
</span><span class="cx">
</span><span class="cx"> #include "FloatSize.h"
</span><del>-#include "LayoutUnit.h"
</del><span class="cx"> #include "PlatformWheelEvent.h"
</span><span class="cx"> #include "ScrollTypes.h"
</span><span class="cx"> #include <wtf/FastMalloc.h>
</span><span class="cx"> #include <wtf/Forward.h>
</span><span class="cx">
</span><del>-#if (ENABLE(RUBBER_BANDING) || ENABLE(CSS_SCROLL_SNAP)) && PLATFORM(MAC)
-#include "ScrollController.h"
</del><ins>+#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
+#include "AxisScrollSnapAnimator.h"
+#include "Timer.h"
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -50,8 +50,8 @@
</span><span class="cx"> class ScrollableArea;
</span><span class="cx"> class Scrollbar;
</span><span class="cx">
</span><del>-#if (ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)) && PLATFORM(MAC)
-class ScrollAnimator : private ScrollControllerClient {
</del><ins>+#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
+class ScrollAnimator : public AxisScrollSnapAnimatorClient {
</ins><span class="cx"> #else
</span><span class="cx"> class ScrollAnimator {
</span><span class="cx"> #endif
</span><span class="lines">@@ -118,22 +118,33 @@
</span><span class="cx"> virtual bool isRubberBandInProgress() const { return false; }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
</span><del>- bool processWheelEventForScrollSnap(const PlatformWheelEvent&);
-
</del><ins>+ void processWheelEventForScrollSnap(const PlatformWheelEvent&);
</ins><span class="cx"> void updateScrollAnimatorsAndTimers();
</span><del>- LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) override;
- void immediateScrollOnAxis(ScrollEventAxis, float delta) override;
</del><ins>+ virtual LayoutUnit scrollOffsetInAxis(ScrollEventAxis) override;
+ virtual void immediateScrollInAxis(ScrollEventAxis, float delta) override;
+ virtual void startScrollSnapTimer(ScrollEventAxis) override;
+ virtual void stopScrollSnapTimer(ScrollEventAxis) override;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> protected:
</span><span class="cx"> virtual void notifyPositionChanged(const FloatSize& delta);
</span><span class="cx">
</span><ins>+#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
+ // Trivial wrappers around the actual update loop in AxisScrollSnapAnimator, since WebCore Timer requires a Timer argument.
+ void horizontalScrollSnapTimerFired();
+ void verticalScrollSnapTimerFired();
+#endif
+
</ins><span class="cx"> ScrollableArea& m_scrollableArea;
</span><del>-#if (ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)) && PLATFORM(MAC)
- ScrollController m_scrollController;
-#endif
</del><span class="cx"> float m_currentPosX; // We avoid using a FloatPoint in order to reduce
</span><span class="cx"> float m_currentPosY; // subclass code complexity.
</span><ins>+#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
+ std::unique_ptr<AxisScrollSnapAnimator> m_horizontalScrollSnapAnimator;
+ std::unique_ptr<Timer> m_horizontalScrollSnapTimer;
+ // FIXME: Find a way to consolidate both timers into one variable.
+ std::unique_ptr<AxisScrollSnapAnimator> m_verticalScrollSnapAnimator;
+ std::unique_ptr<Timer> m_verticalScrollSnapTimer;
+#endif
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaScrollControllerh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/cocoa/ScrollController.h (180914 => 180915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/ScrollController.h        2015-03-03 03:25:21 UTC (rev 180914)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.h        2015-03-03 03:29:41 UTC (rev 180915)
</span><span class="lines">@@ -1,144 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011, 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 ScrollController_h
-#define ScrollController_h
-
-#if ENABLE(RUBBER_BANDING)
-
-#include "FloatPoint.h"
-#include "FloatSize.h"
-#include "ScrollTypes.h"
-#include <wtf/Noncopyable.h>
-#include <wtf/RunLoop.h>
-
-#if ENABLE(CSS_SCROLL_SNAP)
-#include "AxisScrollSnapAnimator.h"
-#endif
-
-namespace WebCore {
-
-class PlatformWheelEvent;
-class ScrollableArea;
-
-class ScrollControllerClient {
-protected:
- virtual ~ScrollControllerClient() { }
-
-public:
- virtual bool allowsHorizontalStretching(const PlatformWheelEvent&) = 0;
- virtual bool allowsVerticalStretching(const PlatformWheelEvent&) = 0;
- virtual IntSize stretchAmount() = 0;
- virtual bool pinnedInDirection(const FloatSize&) = 0;
- virtual bool canScrollHorizontally() = 0;
- virtual bool canScrollVertically() = 0;
- virtual bool shouldRubberBandInDirection(ScrollDirection) = 0;
-
- // Return the absolute scroll position, not relative to the scroll origin.
- virtual WebCore::IntPoint absoluteScrollPosition() = 0;
-
- virtual void immediateScrollBy(const FloatSize&) = 0;
- virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) = 0;
-
- // If the current scroll position is within the overhang area, this function will cause
- // the page to scroll to the nearest boundary point.
- virtual void adjustScrollPositionToBoundsIfNecessary() = 0;
-
-#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
- virtual LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) = 0;
- virtual void immediateScrollOnAxis(ScrollEventAxis, float delta) = 0;
-#endif
-};
-
-#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
-class ScrollController : public AxisScrollSnapAnimatorClient {
-#else
-class ScrollController {
-#endif
- WTF_MAKE_NONCOPYABLE(ScrollController);
-
-public:
- explicit ScrollController(ScrollControllerClient*);
-
- bool handleWheelEvent(const PlatformWheelEvent&);
-
- bool isRubberBandInProgress() const;
-
-#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
- bool processWheelEventForScrollSnap(const PlatformWheelEvent&);
- void updateScrollAnimatorsAndTimers(const ScrollableArea&);
-#endif
-
-private:
- void startSnapRubberbandTimer();
- void stopSnapRubberbandTimer();
- void snapRubberBand();
- void snapRubberBandTimerFired();
-
- bool shouldRubberBandInHorizontalDirection(const PlatformWheelEvent&);
-
-#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
- void horizontalScrollSnapTimerFired();
- void verticalScrollSnapTimerFired();
- void startScrollSnapTimer(ScrollEventAxis);
- void stopScrollSnapTimer(ScrollEventAxis);
-
- LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) override;
- void immediateScrollOnAxis(ScrollEventAxis, float delta) override;
-#endif
-
- ScrollControllerClient* m_client;
-
- CFTimeInterval m_lastMomentumScrollTimestamp;
- FloatSize m_overflowScrollDelta;
- FloatSize m_stretchScrollForce;
- FloatSize m_momentumVelocity;
-
- // Rubber band state.
- CFTimeInterval m_startTime;
- FloatSize m_startStretch;
- FloatPoint m_origOrigin;
- FloatSize m_origVelocity;
- RunLoop::Timer<ScrollController> m_snapRubberbandTimer;
-
-#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
- // FIXME: Find a way to consolidate both timers into one variable.
- std::unique_ptr<AxisScrollSnapAnimator> m_horizontalScrollSnapAnimator;
- std::unique_ptr<AxisScrollSnapAnimator> m_verticalScrollSnapAnimator;
- RunLoop::Timer<ScrollController> m_horizontalScrollSnapTimer;
- RunLoop::Timer<ScrollController> m_verticalScrollSnapTimer;
-#endif
-
- bool m_inScrollGesture;
- bool m_momentumScrollInProgress;
- bool m_ignoreMomentumScrolls;
- bool m_snapRubberbandTimerIsActive;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(RUBBER_BANDING)
-
-#endif // ScrollController_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaScrollControllermm"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/cocoa/ScrollController.mm (180914 => 180915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/ScrollController.mm        2015-03-03 03:25:21 UTC (rev 180914)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.mm        2015-03-03 03:29:41 UTC (rev 180915)
</span><span class="lines">@@ -1,492 +0,0 @@
</span><del>-/*
- * Copyright (C) 2011, 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 "ScrollController.h"
-
-#include "PlatformWheelEvent.h"
-#include "WebCoreSystemInterface.h"
-#include <sys/sysctl.h>
-#include <sys/time.h>
-
-#if ENABLE(CSS_SCROLL_SNAP)
-#include "AxisScrollSnapAnimator.h"
-#include "ScrollableArea.h"
-#endif
-
-#if ENABLE(RUBBER_BANDING)
-
-static NSTimeInterval systemUptime()
-{
- if ([[NSProcessInfo processInfo] respondsToSelector:@selector(systemUptime)])
- return [[NSProcessInfo processInfo] systemUptime];
-
- // Get how long system has been up. Found by looking getting "boottime" from the kernel.
- static struct timeval boottime = {0, 0};
- if (!boottime.tv_sec) {
- int mib[2] = {CTL_KERN, KERN_BOOTTIME};
- size_t size = sizeof(boottime);
- if (-1 == sysctl(mib, 2, &boottime, &size, 0, 0))
- boottime.tv_sec = 0;
- }
- struct timeval now;
- if (boottime.tv_sec && -1 != gettimeofday(&now, 0)) {
- struct timeval uptime;
- timersub(&now, &boottime, &uptime);
- NSTimeInterval result = uptime.tv_sec + (uptime.tv_usec / 1E+6);
- return result;
- }
- return 0;
-}
-
-
-namespace WebCore {
-
-static const float scrollVelocityZeroingTimeout = 0.10f;
-static const float rubberbandDirectionLockStretchRatio = 1;
-static const float rubberbandMinimumRequiredDeltaBeforeStretch = 10;
-
-static float elasticDeltaForTimeDelta(float initialPosition, float initialVelocity, float elapsedTime)
-{
- return wkNSElasticDeltaForTimeDelta(initialPosition, initialVelocity, elapsedTime);
-}
-
-static float elasticDeltaForReboundDelta(float delta)
-{
- return wkNSElasticDeltaForReboundDelta(delta);
-}
-
-static float reboundDeltaForElasticDelta(float delta)
-{
- return wkNSReboundDeltaForElasticDelta(delta);
-}
-
-static float scrollWheelMultiplier()
-{
- static float multiplier = -1;
- if (multiplier < 0) {
- multiplier = [[NSUserDefaults standardUserDefaults] floatForKey:@"NSScrollWheelMultiplier"];
- if (multiplier <= 0)
- multiplier = 1;
- }
- return multiplier;
-}
-
-ScrollController::ScrollController(ScrollControllerClient* client)
- : m_client(client)
- , m_lastMomentumScrollTimestamp(0)
- , m_startTime(0)
- , m_snapRubberbandTimer(RunLoop::current(), this, &ScrollController::snapRubberBandTimerFired)
-#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
- , m_horizontalScrollSnapTimer(RunLoop::current(), this, &ScrollController::horizontalScrollSnapTimerFired)
- , m_verticalScrollSnapTimer(RunLoop::current(), this, &ScrollController::verticalScrollSnapTimerFired)
-#endif
- , m_inScrollGesture(false)
- , m_momentumScrollInProgress(false)
- , m_ignoreMomentumScrolls(false)
- , m_snapRubberbandTimerIsActive(false)
-{
-}
-
-bool ScrollController::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
-{
-#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
- if (!processWheelEventForScrollSnap(wheelEvent))
- return false;
-#endif
- if (wheelEvent.phase() == PlatformWheelEventPhaseBegan) {
- // First, check if we should rubber-band at all.
- if (m_client->pinnedInDirection(FloatSize(-wheelEvent.deltaX(), 0))
- && !shouldRubberBandInHorizontalDirection(wheelEvent))
- return false;
-
- m_inScrollGesture = true;
- m_momentumScrollInProgress = false;
- m_ignoreMomentumScrolls = false;
- m_lastMomentumScrollTimestamp = 0;
- m_momentumVelocity = FloatSize();
-
- IntSize stretchAmount = m_client->stretchAmount();
- m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(stretchAmount.width()));
- m_stretchScrollForce.setHeight(reboundDeltaForElasticDelta(stretchAmount.height()));
- m_overflowScrollDelta = FloatSize();
-
- stopSnapRubberbandTimer();
-
- return true;
- }
-
- if (wheelEvent.phase() == PlatformWheelEventPhaseEnded) {
- snapRubberBand();
- return true;
- }
-
- bool isMomentumScrollEvent = (wheelEvent.momentumPhase() != PlatformWheelEventPhaseNone);
- if (m_ignoreMomentumScrolls && (isMomentumScrollEvent || m_snapRubberbandTimerIsActive)) {
- if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded) {
- m_ignoreMomentumScrolls = false;
- return true;
- }
- return false;
- }
-
- float deltaX = m_overflowScrollDelta.width();
- float deltaY = m_overflowScrollDelta.height();
-
- // Reset overflow values because we may decide to remove delta at various points and put it into overflow.
- m_overflowScrollDelta = FloatSize();
-
- IntSize stretchAmount = m_client->stretchAmount();
- bool isVerticallyStretched = stretchAmount.height();
- bool isHorizontallyStretched = stretchAmount.width();
-
- float eventCoalescedDeltaX;
- float eventCoalescedDeltaY;
-
- if (isVerticallyStretched || isHorizontallyStretched) {
- eventCoalescedDeltaX = -wheelEvent.unacceleratedScrollingDeltaX();
- eventCoalescedDeltaY = -wheelEvent.unacceleratedScrollingDeltaY();
- } else {
- eventCoalescedDeltaX = -wheelEvent.deltaX();
- eventCoalescedDeltaY = -wheelEvent.deltaY();
- }
-
- deltaX += eventCoalescedDeltaX;
- deltaY += eventCoalescedDeltaY;
-
- // Slightly prefer scrolling vertically by applying the = case to deltaY
- if (fabsf(deltaY) >= fabsf(deltaX))
- deltaX = 0;
- else
- deltaY = 0;
-
- bool shouldStretch = false;
-
- PlatformWheelEventPhase momentumPhase = wheelEvent.momentumPhase();
-
- // If we are starting momentum scrolling then do some setup.
- if (!m_momentumScrollInProgress && (momentumPhase == PlatformWheelEventPhaseBegan || momentumPhase == PlatformWheelEventPhaseChanged))
- m_momentumScrollInProgress = true;
-
- CFTimeInterval timeDelta = wheelEvent.timestamp() - m_lastMomentumScrollTimestamp;
- if (m_inScrollGesture || m_momentumScrollInProgress) {
- if (m_lastMomentumScrollTimestamp && timeDelta > 0 && timeDelta < scrollVelocityZeroingTimeout) {
- m_momentumVelocity.setWidth(eventCoalescedDeltaX / (float)timeDelta);
- m_momentumVelocity.setHeight(eventCoalescedDeltaY / (float)timeDelta);
- m_lastMomentumScrollTimestamp = wheelEvent.timestamp();
- } else {
- m_lastMomentumScrollTimestamp = wheelEvent.timestamp();
- m_momentumVelocity = FloatSize();
- }
-
- if (isVerticallyStretched) {
- if (!isHorizontallyStretched && m_client->pinnedInDirection(FloatSize(deltaX, 0))) {
- // Stretching only in the vertical.
- if (deltaY && (fabsf(deltaX / deltaY) < rubberbandDirectionLockStretchRatio))
- deltaX = 0;
- else if (fabsf(deltaX) < rubberbandMinimumRequiredDeltaBeforeStretch) {
- m_overflowScrollDelta.setWidth(m_overflowScrollDelta.width() + deltaX);
- deltaX = 0;
- } else
- m_overflowScrollDelta.setWidth(m_overflowScrollDelta.width() + deltaX);
- }
- } else if (isHorizontallyStretched) {
- // Stretching only in the horizontal.
- if (m_client->pinnedInDirection(FloatSize(0, deltaY))) {
- if (deltaX && (fabsf(deltaY / deltaX) < rubberbandDirectionLockStretchRatio))
- deltaY = 0;
- else if (fabsf(deltaY) < rubberbandMinimumRequiredDeltaBeforeStretch) {
- m_overflowScrollDelta.setHeight(m_overflowScrollDelta.height() + deltaY);
- deltaY = 0;
- } else
- m_overflowScrollDelta.setHeight(m_overflowScrollDelta.height() + deltaY);
- }
- } else {
- // Not stretching at all yet.
- if (m_client->pinnedInDirection(FloatSize(deltaX, deltaY))) {
- if (fabsf(deltaY) >= fabsf(deltaX)) {
- if (fabsf(deltaX) < rubberbandMinimumRequiredDeltaBeforeStretch) {
- m_overflowScrollDelta.setWidth(m_overflowScrollDelta.width() + deltaX);
- deltaX = 0;
- } else
- m_overflowScrollDelta.setWidth(m_overflowScrollDelta.width() + deltaX);
- }
- shouldStretch = true;
- }
- }
- }
-
- if (deltaX || deltaY) {
- if (!(shouldStretch || isVerticallyStretched || isHorizontallyStretched)) {
- if (deltaY) {
- deltaY *= scrollWheelMultiplier();
- m_client->immediateScrollBy(FloatSize(0, deltaY));
- }
- if (deltaX) {
- deltaX *= scrollWheelMultiplier();
- m_client->immediateScrollBy(FloatSize(deltaX, 0));
- }
- } else {
- if (!m_client->allowsHorizontalStretching(wheelEvent)) {
- deltaX = 0;
- eventCoalescedDeltaX = 0;
- } else if (deltaX && !isHorizontallyStretched && !m_client->pinnedInDirection(FloatSize(deltaX, 0))) {
- deltaX *= scrollWheelMultiplier();
-
- m_client->immediateScrollByWithoutContentEdgeConstraints(FloatSize(deltaX, 0));
- deltaX = 0;
- }
-
- if (!m_client->allowsVerticalStretching(wheelEvent)) {
- deltaY = 0;
- eventCoalescedDeltaY = 0;
- } else if (deltaY && !isVerticallyStretched && !m_client->pinnedInDirection(FloatSize(0, deltaY))) {
- deltaY *= scrollWheelMultiplier();
-
- m_client->immediateScrollByWithoutContentEdgeConstraints(FloatSize(0, deltaY));
- deltaY = 0;
- }
-
- IntSize stretchAmount = m_client->stretchAmount();
-
- if (m_momentumScrollInProgress) {
- if ((m_client->pinnedInDirection(FloatSize(eventCoalescedDeltaX, eventCoalescedDeltaY)) || (fabsf(eventCoalescedDeltaX) + fabsf(eventCoalescedDeltaY) <= 0)) && m_lastMomentumScrollTimestamp) {
- m_ignoreMomentumScrolls = true;
- m_momentumScrollInProgress = false;
- snapRubberBand();
- }
- }
-
- m_stretchScrollForce.setWidth(m_stretchScrollForce.width() + deltaX);
- m_stretchScrollForce.setHeight(m_stretchScrollForce.height() + deltaY);
-
- FloatSize dampedDelta(ceilf(elasticDeltaForReboundDelta(m_stretchScrollForce.width())), ceilf(elasticDeltaForReboundDelta(m_stretchScrollForce.height())));
-
- m_client->immediateScrollByWithoutContentEdgeConstraints(dampedDelta - stretchAmount);
- }
- }
-
- if (m_momentumScrollInProgress && momentumPhase == PlatformWheelEventPhaseEnded) {
- m_momentumScrollInProgress = false;
- m_ignoreMomentumScrolls = false;
- m_lastMomentumScrollTimestamp = 0;
- }
-
- return true;
-}
-
-static inline float roundTowardZero(float num)
-{
- return num > 0 ? ceilf(num - 0.5f) : floorf(num + 0.5f);
-}
-
-static inline float roundToDevicePixelTowardZero(float num)
-{
- float roundedNum = roundf(num);
- if (fabs(num - roundedNum) < 0.125)
- num = roundedNum;
-
- return roundTowardZero(num);
-}
-
-void ScrollController::snapRubberBandTimerFired()
-{
- if (!m_momentumScrollInProgress || m_ignoreMomentumScrolls) {
- CFTimeInterval timeDelta = [NSDate timeIntervalSinceReferenceDate] - m_startTime;
-
- if (m_startStretch == FloatSize()) {
- m_startStretch = m_client->stretchAmount();
- if (m_startStretch == FloatSize()) {
- stopSnapRubberbandTimer();
-
- m_stretchScrollForce = FloatSize();
- m_startTime = 0;
- m_startStretch = FloatSize();
- m_origOrigin = FloatPoint();
- m_origVelocity = FloatSize();
- return;
- }
-
- m_origOrigin = m_client->absoluteScrollPosition() - m_startStretch;
- m_origVelocity = m_momentumVelocity;
-
- // Just like normal scrolling, prefer vertical rubberbanding
- if (fabsf(m_origVelocity.height()) >= fabsf(m_origVelocity.width()))
- m_origVelocity.setWidth(0);
-
- // Don't rubber-band horizontally if it's not possible to scroll horizontally
- if (!m_client->canScrollHorizontally())
- m_origVelocity.setWidth(0);
-
- // Don't rubber-band vertically if it's not possible to scroll vertically
- if (!m_client->canScrollVertically())
- m_origVelocity.setHeight(0);
- }
-
- FloatPoint delta(roundToDevicePixelTowardZero(elasticDeltaForTimeDelta(m_startStretch.width(), -m_origVelocity.width(), (float)timeDelta)),
- roundToDevicePixelTowardZero(elasticDeltaForTimeDelta(m_startStretch.height(), -m_origVelocity.height(), (float)timeDelta)));
-
- if (fabs(delta.x()) >= 1 || fabs(delta.y()) >= 1) {
- m_client->immediateScrollByWithoutContentEdgeConstraints(FloatSize(delta.x(), delta.y()) - m_client->stretchAmount());
-
- FloatSize newStretch = m_client->stretchAmount();
-
- m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(newStretch.width()));
- m_stretchScrollForce.setHeight(reboundDeltaForElasticDelta(newStretch.height()));
- } else {
- m_client->adjustScrollPositionToBoundsIfNecessary();
-
- stopSnapRubberbandTimer();
- m_stretchScrollForce = FloatSize();
- m_startTime = 0;
- m_startStretch = FloatSize();
- m_origOrigin = FloatPoint();
- m_origVelocity = FloatSize();
- }
- } else {
- m_startTime = [NSDate timeIntervalSinceReferenceDate];
- m_startStretch = FloatSize();
- }
-}
-
-bool ScrollController::isRubberBandInProgress() const
-{
- if (!m_inScrollGesture && !m_momentumScrollInProgress && !m_snapRubberbandTimerIsActive)
- return false;
-
- return !m_client->stretchAmount().isZero();
-}
-
-void ScrollController::startSnapRubberbandTimer()
-{
- m_snapRubberbandTimer.startRepeating(1.0 / 60.0);
-}
-
-void ScrollController::stopSnapRubberbandTimer()
-{
- m_snapRubberbandTimer.stop();
- m_snapRubberbandTimerIsActive = false;
-}
-
-void ScrollController::snapRubberBand()
-{
- CFTimeInterval timeDelta = systemUptime() - m_lastMomentumScrollTimestamp;
- if (m_lastMomentumScrollTimestamp && timeDelta >= scrollVelocityZeroingTimeout)
- m_momentumVelocity = FloatSize();
-
- m_inScrollGesture = false;
-
- if (m_snapRubberbandTimerIsActive)
- return;
-
- m_startTime = [NSDate timeIntervalSinceReferenceDate];
- m_startStretch = FloatSize();
- m_origOrigin = FloatPoint();
- m_origVelocity = FloatSize();
-
- startSnapRubberbandTimer();
- m_snapRubberbandTimerIsActive = true;
-}
-
-bool ScrollController::shouldRubberBandInHorizontalDirection(const PlatformWheelEvent& wheelEvent)
-{
- if (wheelEvent.deltaX() > 0)
- return m_client->shouldRubberBandInDirection(ScrollLeft);
- if (wheelEvent.deltaX() < 0)
- return m_client->shouldRubberBandInDirection(ScrollRight);
-
- return true;
-}
-
-#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
-bool ScrollController::processWheelEventForScrollSnap(const PlatformWheelEvent& wheelEvent)
-{
- if (m_verticalScrollSnapAnimator) {
- m_verticalScrollSnapAnimator->handleWheelEvent(wheelEvent);
- if (m_verticalScrollSnapAnimator->shouldOverrideWheelEvent(wheelEvent))
- return false;
- }
- if (m_horizontalScrollSnapAnimator) {
- m_horizontalScrollSnapAnimator->handleWheelEvent(wheelEvent);
- if (m_horizontalScrollSnapAnimator->shouldOverrideWheelEvent(wheelEvent))
- return false;
- }
-
- return true;
-}
-
-void ScrollController::updateScrollAnimatorsAndTimers(const ScrollableArea& scrollableArea)
-{
- // FIXME: Currently, scroll snap animators are recreated even though the snap offsets alone can be updated.
- if (scrollableArea.horizontalSnapOffsets())
- m_horizontalScrollSnapAnimator = std::make_unique<AxisScrollSnapAnimator>(this, scrollableArea.horizontalSnapOffsets(), ScrollEventAxis::Horizontal);
- else if (m_horizontalScrollSnapAnimator)
- m_horizontalScrollSnapAnimator = nullptr;
-
- if (scrollableArea.verticalSnapOffsets())
- m_verticalScrollSnapAnimator = std::make_unique<AxisScrollSnapAnimator>(this, scrollableArea.verticalSnapOffsets(), ScrollEventAxis::Vertical);
- else if (m_verticalScrollSnapAnimator)
- m_verticalScrollSnapAnimator = nullptr;
-}
-
-void ScrollController::startScrollSnapTimer(ScrollEventAxis axis)
-{
- RunLoop::Timer<ScrollController>& scrollSnapTimer = axis == ScrollEventAxis::Horizontal ? m_horizontalScrollSnapTimer : m_verticalScrollSnapTimer;
- if (!scrollSnapTimer.isActive())
- scrollSnapTimer.startRepeating(1.0 / 60.0);
-}
-
-void ScrollController::stopScrollSnapTimer(ScrollEventAxis axis)
-{
- RunLoop::Timer<ScrollController>& scrollSnapTimer = axis == ScrollEventAxis::Horizontal ? m_horizontalScrollSnapTimer : m_verticalScrollSnapTimer;
- scrollSnapTimer.stop();
-}
-
-void ScrollController::horizontalScrollSnapTimerFired()
-{
- if (m_horizontalScrollSnapAnimator)
- m_horizontalScrollSnapAnimator->scrollSnapAnimationUpdate();
-}
-
-void ScrollController::verticalScrollSnapTimerFired()
-{
- if (m_verticalScrollSnapAnimator)
- m_verticalScrollSnapAnimator->scrollSnapAnimationUpdate();
-}
-
-LayoutUnit ScrollController::scrollOffsetOnAxis(ScrollEventAxis axis)
-{
- return m_client->scrollOffsetOnAxis(axis);
-}
-
-void ScrollController::immediateScrollOnAxis(ScrollEventAxis axis, float delta)
-{
- m_client->immediateScrollOnAxis(axis, delta);
-}
-#endif
-
-} // namespace WebCore
-
-#endif // ENABLE(RUBBER_BANDING)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformmacAxisScrollSnapAnimatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.h (180914 => 180915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.h        2015-03-03 03:25:21 UTC (rev 180914)
+++ trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.h        2015-03-03 03:29:41 UTC (rev 180915)
</span><span class="lines">@@ -57,8 +57,8 @@
</span><span class="cx"> virtual ~AxisScrollSnapAnimatorClient() { }
</span><span class="cx">
</span><span class="cx"> public:
</span><del>- virtual LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) = 0;
- virtual void immediateScrollOnAxis(ScrollEventAxis, float velocity) = 0;
</del><ins>+ virtual LayoutUnit scrollOffsetInAxis(ScrollEventAxis) = 0;
+ virtual void immediateScrollInAxis(ScrollEventAxis, float velocity) = 0;
</ins><span class="cx"> virtual void startScrollSnapTimer(ScrollEventAxis) = 0;
</span><span class="cx"> virtual void stopScrollSnapTimer(ScrollEventAxis) = 0;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacAxisScrollSnapAnimatormm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.mm (180914 => 180915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.mm        2015-03-03 03:25:21 UTC (rev 180914)
+++ trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.mm        2015-03-03 03:29:41 UTC (rev 180915)
</span><span class="lines">@@ -117,7 +117,7 @@
</span><span class="cx"> // Begin tracking wheel deltas for glide prediction.
</span><span class="cx"> endScrollSnapAnimation(ScrollSnapState::UserInteraction);
</span><span class="cx"> pushInitialWheelDelta(wheelDelta);
</span><del>- m_beginTrackingWheelDeltaOffset = m_client->scrollOffsetOnAxis(m_axis);
</del><ins>+ m_beginTrackingWheelDeltaOffset = m_client->scrollOffsetInAxis(m_axis);
</ins><span class="cx"> break;
</span><span class="cx">
</span><span class="cx"> case WheelEventStatus::InertialScrolling:
</span><span class="lines">@@ -153,7 +153,7 @@
</span><span class="cx"> ASSERT(m_currentState == ScrollSnapState::Gliding || m_currentState == ScrollSnapState::Snapping);
</span><span class="cx"> float delta = m_currentState == ScrollSnapState::Snapping ? computeSnapDelta() : computeGlideDelta();
</span><span class="cx"> if (delta)
</span><del>- m_client->immediateScrollOnAxis(m_axis, delta);
</del><ins>+ m_client->immediateScrollInAxis(m_axis, delta);
</ins><span class="cx"> else
</span><span class="cx"> endScrollSnapAnimation(ScrollSnapState::DestinationReached);
</span><span class="cx"> }
</span><span class="lines">@@ -161,7 +161,7 @@
</span><span class="cx"> void AxisScrollSnapAnimator::beginScrollSnapAnimation(ScrollSnapState newState)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(newState == ScrollSnapState::Gliding || newState == ScrollSnapState::Snapping);
</span><del>- LayoutUnit offset = m_client->scrollOffsetOnAxis(m_axis);
</del><ins>+ LayoutUnit offset = m_client->scrollOffsetInAxis(m_axis);
</ins><span class="cx"> float initialWheelDelta = newState == ScrollSnapState::Gliding ? averageInitialWheelDelta() : 0;
</span><span class="cx"> LayoutUnit projectedScrollDestination = newState == ScrollSnapState::Gliding ? m_beginTrackingWheelDeltaOffset + LayoutUnit(projectedInertialScrollDistance(initialWheelDelta)) : offset;
</span><span class="cx"> projectedScrollDestination = std::min(std::max(projectedScrollDestination, m_snapOffsets->first()), m_snapOffsets->last());
</span><span class="lines">@@ -203,7 +203,7 @@
</span><span class="cx"> // relationship of the distance traveled, clamped by arbitrary min and max values.
</span><span class="cx"> float AxisScrollSnapAnimator::computeSnapDelta() const
</span><span class="cx"> {
</span><del>- LayoutUnit offset = m_client->scrollOffsetOnAxis(m_axis);
</del><ins>+ LayoutUnit offset = m_client->scrollOffsetInAxis(m_axis);
</ins><span class="cx"> bool canComputeSnap = (m_initialOffset <= offset && offset < m_targetOffset) || (m_targetOffset < offset && offset <= m_initialOffset);
</span><span class="cx"> if (m_currentState != ScrollSnapState::Snapping || !canComputeSnap)
</span><span class="cx"> return 0;
</span><span class="lines">@@ -237,7 +237,7 @@
</span><span class="cx"> // and VF. Thus, we can express our gliding equation all in terms of V0, VF and t.
</span><span class="cx"> float AxisScrollSnapAnimator::computeGlideDelta() const
</span><span class="cx"> {
</span><del>- LayoutUnit offset = m_client->scrollOffsetOnAxis(m_axis);
</del><ins>+ LayoutUnit offset = m_client->scrollOffsetInAxis(m_axis);
</ins><span class="cx"> bool canComputeGlide = (m_initialOffset <= offset && offset < m_targetOffset) || (m_targetOffset < offset && offset <= m_initialOffset);
</span><span class="cx"> if (m_currentState != ScrollSnapState::Gliding || !canComputeGlide)
</span><span class="cx"> return 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacScrollAnimatorMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h (180914 => 180915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h        2015-03-03 03:25:21 UTC (rev 180914)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h        2015-03-03 03:29:41 UTC (rev 180915)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #include "FloatPoint.h"
</span><span class="cx"> #include "FloatSize.h"
</span><span class="cx"> #include "ScrollAnimator.h"
</span><ins>+#include "ScrollController.h"
</ins><span class="cx"> #include "Timer.h"
</span><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="cx">
</span><span class="lines">@@ -41,11 +42,15 @@
</span><span class="cx">
</span><span class="cx"> typedef id ScrollbarPainterController;
</span><span class="cx">
</span><ins>+#if !ENABLE(RUBBER_BANDING)
+class ScrollControllerClient { };
+#endif
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> class Scrollbar;
</span><span class="cx">
</span><del>-class ScrollAnimatorMac : public ScrollAnimator {
</del><ins>+class ScrollAnimatorMac : public ScrollAnimator, private ScrollControllerClient {
</ins><span class="cx">
</span><span class="cx"> public:
</span><span class="cx"> ScrollAnimatorMac(ScrollableArea&);
</span><span class="lines">@@ -145,11 +150,17 @@
</span><span class="cx"> virtual WebCore::IntPoint absoluteScrollPosition() override;
</span><span class="cx"> virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) override;
</span><span class="cx"> virtual void immediateScrollBy(const FloatSize&) override;
</span><ins>+ virtual void startSnapRubberbandTimer() override;
+ virtual void stopSnapRubberbandTimer() override;
</ins><span class="cx"> virtual void adjustScrollPositionToBoundsIfNecessary() override;
</span><span class="cx">
</span><span class="cx"> bool pinnedInDirection(float deltaX, float deltaY);
</span><ins>+ void snapRubberBandTimerFired();
</ins><span class="cx">
</span><span class="cx"> bool isAlreadyPinnedInDirectionOfGesture(const PlatformWheelEvent&, ScrollEventAxis);
</span><ins>+
+ ScrollController m_scrollController;
+ Timer m_snapRubberBandTimer;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> bool m_haveScrolledSincePageLoad;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacScrollAnimatorMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (180914 => 180915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm        2015-03-03 03:25:21 UTC (rev 180914)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm        2015-03-03 03:29:41 UTC (rev 180915)
</span><span class="lines">@@ -643,6 +643,10 @@
</span><span class="cx"> : ScrollAnimator(scrollableArea)
</span><span class="cx"> , m_initialScrollbarPaintTimer(*this, &ScrollAnimatorMac::initialScrollbarPaintTimerFired)
</span><span class="cx"> , m_sendContentAreaScrolledTimer(*this, &ScrollAnimatorMac::sendContentAreaScrolledTimerFired)
</span><ins>+#if ENABLE(RUBBER_BANDING)
+ , m_scrollController(this)
+ , m_snapRubberBandTimer(*this, &ScrollAnimatorMac::snapRubberBandTimerFired)
+#endif
</ins><span class="cx"> , m_haveScrolledSincePageLoad(false)
</span><span class="cx"> , m_needsScrollerStyleUpdate(false)
</span><span class="cx"> {
</span><span class="lines">@@ -1266,6 +1270,21 @@
</span><span class="cx"> m_currentPosY = newPos.y();
</span><span class="cx"> notifyPositionChanged(adjustedDelta);
</span><span class="cx"> }
</span><ins>+
+void ScrollAnimatorMac::startSnapRubberbandTimer()
+{
+ m_snapRubberBandTimer.startRepeating(1.0 / 60.0);
+}
+
+void ScrollAnimatorMac::stopSnapRubberbandTimer()
+{
+ m_snapRubberBandTimer.stop();
+}
+
+void ScrollAnimatorMac::snapRubberBandTimerFired()
+{
+ m_scrollController.snapRubberBandTimerFired();
+}
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> void ScrollAnimatorMac::updateScrollerStyle()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacScrollControllerhfromrev180914trunkSourceWebCoreplatformcocoaScrollControllerh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/mac/ScrollController.h (from rev 180914, trunk/Source/WebCore/platform/cocoa/ScrollController.h) (0 => 180915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/ScrollController.h         (rev 0)
+++ trunk/Source/WebCore/platform/mac/ScrollController.h        2015-03-03 03:29:41 UTC (rev 180915)
</span><span class="lines">@@ -0,0 +1,107 @@
</span><ins>+/*
+ * Copyright (C) 2011 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 ScrollController_h
+#define ScrollController_h
+
+#if ENABLE(RUBBER_BANDING)
+
+#include "FloatPoint.h"
+#include "FloatSize.h"
+#include "ScrollTypes.h"
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+
+class PlatformWheelEvent;
+
+class ScrollControllerClient {
+protected:
+ virtual ~ScrollControllerClient() { }
+
+public:
+ virtual bool allowsHorizontalStretching(const PlatformWheelEvent&) = 0;
+ virtual bool allowsVerticalStretching(const PlatformWheelEvent&) = 0;
+ virtual IntSize stretchAmount() = 0;
+ virtual bool pinnedInDirection(const FloatSize&) = 0;
+ virtual bool canScrollHorizontally() = 0;
+ virtual bool canScrollVertically() = 0;
+ virtual bool shouldRubberBandInDirection(ScrollDirection) = 0;
+
+ // Return the absolute scroll position, not relative to the scroll origin.
+ virtual WebCore::IntPoint absoluteScrollPosition() = 0;
+
+ virtual void immediateScrollBy(const FloatSize&) = 0;
+ virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&) = 0;
+ virtual void startSnapRubberbandTimer() = 0;
+ virtual void stopSnapRubberbandTimer() = 0;
+
+ // If the current scroll position is within the overhang area, this function will cause
+ // the page to scroll to the nearest boundary point.
+ virtual void adjustScrollPositionToBoundsIfNecessary() = 0;
+};
+
+class ScrollController {
+ WTF_MAKE_NONCOPYABLE(ScrollController);
+
+public:
+ explicit ScrollController(ScrollControllerClient*);
+
+ bool handleWheelEvent(const PlatformWheelEvent&);
+ void snapRubberBandTimerFired();
+
+ bool isRubberBandInProgress() const;
+
+private:
+ void stopSnapRubberbandTimer();
+ void snapRubberBand();
+
+ bool shouldRubberBandInHorizontalDirection(const PlatformWheelEvent&);
+
+ ScrollControllerClient* m_client;
+
+ bool m_inScrollGesture;
+ bool m_momentumScrollInProgress;
+ bool m_ignoreMomentumScrolls;
+
+ CFTimeInterval m_lastMomentumScrollTimestamp;
+ FloatSize m_overflowScrollDelta;
+ FloatSize m_stretchScrollForce;
+ FloatSize m_momentumVelocity;
+
+ // Rubber band state.
+ CFTimeInterval m_startTime;
+ FloatSize m_startStretch;
+ FloatPoint m_origOrigin;
+ FloatSize m_origVelocity;
+
+ bool m_snapRubberbandTimerIsActive;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(RUBBER_BANDING)
+
+#endif // ScrollController_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmacScrollControllermmfromrev180914trunkSourceWebCoreplatformcocoaScrollControllermm"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/mac/ScrollController.mm (from rev 180914, trunk/Source/WebCore/platform/cocoa/ScrollController.mm) (0 => 180915)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/ScrollController.mm         (rev 0)
+++ trunk/Source/WebCore/platform/mac/ScrollController.mm        2015-03-03 03:29:41 UTC (rev 180915)
</span><span class="lines">@@ -0,0 +1,406 @@
</span><ins>+/*
+ * Copyright (C) 2011, 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 "ScrollController.h"
+
+#include "PlatformWheelEvent.h"
+#include "WebCoreSystemInterface.h"
+#include <sys/sysctl.h>
+#include <sys/time.h>
+
+#if ENABLE(RUBBER_BANDING)
+
+static NSTimeInterval systemUptime()
+{
+ if ([[NSProcessInfo processInfo] respondsToSelector:@selector(systemUptime)])
+ return [[NSProcessInfo processInfo] systemUptime];
+
+ // Get how long system has been up. Found by looking getting "boottime" from the kernel.
+ static struct timeval boottime = {0, 0};
+ if (!boottime.tv_sec) {
+ int mib[2] = {CTL_KERN, KERN_BOOTTIME};
+ size_t size = sizeof(boottime);
+ if (-1 == sysctl(mib, 2, &boottime, &size, 0, 0))
+ boottime.tv_sec = 0;
+ }
+ struct timeval now;
+ if (boottime.tv_sec && -1 != gettimeofday(&now, 0)) {
+ struct timeval uptime;
+ timersub(&now, &boottime, &uptime);
+ NSTimeInterval result = uptime.tv_sec + (uptime.tv_usec / 1E+6);
+ return result;
+ }
+ return 0;
+}
+
+
+namespace WebCore {
+
+static const float scrollVelocityZeroingTimeout = 0.10f;
+static const float rubberbandDirectionLockStretchRatio = 1;
+static const float rubberbandMinimumRequiredDeltaBeforeStretch = 10;
+
+static float elasticDeltaForTimeDelta(float initialPosition, float initialVelocity, float elapsedTime)
+{
+ return wkNSElasticDeltaForTimeDelta(initialPosition, initialVelocity, elapsedTime);
+}
+
+static float elasticDeltaForReboundDelta(float delta)
+{
+ return wkNSElasticDeltaForReboundDelta(delta);
+}
+
+static float reboundDeltaForElasticDelta(float delta)
+{
+ return wkNSReboundDeltaForElasticDelta(delta);
+}
+
+static float scrollWheelMultiplier()
+{
+ static float multiplier = -1;
+ if (multiplier < 0) {
+ multiplier = [[NSUserDefaults standardUserDefaults] floatForKey:@"NSScrollWheelMultiplier"];
+ if (multiplier <= 0)
+ multiplier = 1;
+ }
+ return multiplier;
+}
+
+ScrollController::ScrollController(ScrollControllerClient* client)
+ : m_client(client)
+ , m_inScrollGesture(false)
+ , m_momentumScrollInProgress(false)
+ , m_ignoreMomentumScrolls(false)
+ , m_lastMomentumScrollTimestamp(0)
+ , m_startTime(0)
+ , m_snapRubberbandTimerIsActive(false)
+{
+}
+
+bool ScrollController::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
+{
+ if (wheelEvent.phase() == PlatformWheelEventPhaseBegan) {
+ // First, check if we should rubber-band at all.
+ if (m_client->pinnedInDirection(FloatSize(-wheelEvent.deltaX(), 0))
+ && !shouldRubberBandInHorizontalDirection(wheelEvent))
+ return false;
+
+ m_inScrollGesture = true;
+ m_momentumScrollInProgress = false;
+ m_ignoreMomentumScrolls = false;
+ m_lastMomentumScrollTimestamp = 0;
+ m_momentumVelocity = FloatSize();
+
+ IntSize stretchAmount = m_client->stretchAmount();
+ m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(stretchAmount.width()));
+ m_stretchScrollForce.setHeight(reboundDeltaForElasticDelta(stretchAmount.height()));
+ m_overflowScrollDelta = FloatSize();
+
+ stopSnapRubberbandTimer();
+
+ return true;
+ }
+
+ if (wheelEvent.phase() == PlatformWheelEventPhaseEnded) {
+ snapRubberBand();
+ return true;
+ }
+
+ bool isMomentumScrollEvent = (wheelEvent.momentumPhase() != PlatformWheelEventPhaseNone);
+ if (m_ignoreMomentumScrolls && (isMomentumScrollEvent || m_snapRubberbandTimerIsActive)) {
+ if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded) {
+ m_ignoreMomentumScrolls = false;
+ return true;
+ }
+ return false;
+ }
+
+ float deltaX = m_overflowScrollDelta.width();
+ float deltaY = m_overflowScrollDelta.height();
+
+ // Reset overflow values because we may decide to remove delta at various points and put it into overflow.
+ m_overflowScrollDelta = FloatSize();
+
+ IntSize stretchAmount = m_client->stretchAmount();
+ bool isVerticallyStretched = stretchAmount.height();
+ bool isHorizontallyStretched = stretchAmount.width();
+
+ float eventCoalescedDeltaX;
+ float eventCoalescedDeltaY;
+
+ if (isVerticallyStretched || isHorizontallyStretched) {
+ eventCoalescedDeltaX = -wheelEvent.unacceleratedScrollingDeltaX();
+ eventCoalescedDeltaY = -wheelEvent.unacceleratedScrollingDeltaY();
+ } else {
+ eventCoalescedDeltaX = -wheelEvent.deltaX();
+ eventCoalescedDeltaY = -wheelEvent.deltaY();
+ }
+
+ deltaX += eventCoalescedDeltaX;
+ deltaY += eventCoalescedDeltaY;
+
+ // Slightly prefer scrolling vertically by applying the = case to deltaY
+ if (fabsf(deltaY) >= fabsf(deltaX))
+ deltaX = 0;
+ else
+ deltaY = 0;
+
+ bool shouldStretch = false;
+
+ PlatformWheelEventPhase momentumPhase = wheelEvent.momentumPhase();
+
+ // If we are starting momentum scrolling then do some setup.
+ if (!m_momentumScrollInProgress && (momentumPhase == PlatformWheelEventPhaseBegan || momentumPhase == PlatformWheelEventPhaseChanged))
+ m_momentumScrollInProgress = true;
+
+ CFTimeInterval timeDelta = wheelEvent.timestamp() - m_lastMomentumScrollTimestamp;
+ if (m_inScrollGesture || m_momentumScrollInProgress) {
+ if (m_lastMomentumScrollTimestamp && timeDelta > 0 && timeDelta < scrollVelocityZeroingTimeout) {
+ m_momentumVelocity.setWidth(eventCoalescedDeltaX / (float)timeDelta);
+ m_momentumVelocity.setHeight(eventCoalescedDeltaY / (float)timeDelta);
+ m_lastMomentumScrollTimestamp = wheelEvent.timestamp();
+ } else {
+ m_lastMomentumScrollTimestamp = wheelEvent.timestamp();
+ m_momentumVelocity = FloatSize();
+ }
+
+ if (isVerticallyStretched) {
+ if (!isHorizontallyStretched && m_client->pinnedInDirection(FloatSize(deltaX, 0))) {
+ // Stretching only in the vertical.
+ if (deltaY && (fabsf(deltaX / deltaY) < rubberbandDirectionLockStretchRatio))
+ deltaX = 0;
+ else if (fabsf(deltaX) < rubberbandMinimumRequiredDeltaBeforeStretch) {
+ m_overflowScrollDelta.setWidth(m_overflowScrollDelta.width() + deltaX);
+ deltaX = 0;
+ } else
+ m_overflowScrollDelta.setWidth(m_overflowScrollDelta.width() + deltaX);
+ }
+ } else if (isHorizontallyStretched) {
+ // Stretching only in the horizontal.
+ if (m_client->pinnedInDirection(FloatSize(0, deltaY))) {
+ if (deltaX && (fabsf(deltaY / deltaX) < rubberbandDirectionLockStretchRatio))
+ deltaY = 0;
+ else if (fabsf(deltaY) < rubberbandMinimumRequiredDeltaBeforeStretch) {
+ m_overflowScrollDelta.setHeight(m_overflowScrollDelta.height() + deltaY);
+ deltaY = 0;
+ } else
+ m_overflowScrollDelta.setHeight(m_overflowScrollDelta.height() + deltaY);
+ }
+ } else {
+ // Not stretching at all yet.
+ if (m_client->pinnedInDirection(FloatSize(deltaX, deltaY))) {
+ if (fabsf(deltaY) >= fabsf(deltaX)) {
+ if (fabsf(deltaX) < rubberbandMinimumRequiredDeltaBeforeStretch) {
+ m_overflowScrollDelta.setWidth(m_overflowScrollDelta.width() + deltaX);
+ deltaX = 0;
+ } else
+ m_overflowScrollDelta.setWidth(m_overflowScrollDelta.width() + deltaX);
+ }
+ shouldStretch = true;
+ }
+ }
+ }
+
+ if (deltaX || deltaY) {
+ if (!(shouldStretch || isVerticallyStretched || isHorizontallyStretched)) {
+ if (deltaY) {
+ deltaY *= scrollWheelMultiplier();
+ m_client->immediateScrollBy(FloatSize(0, deltaY));
+ }
+ if (deltaX) {
+ deltaX *= scrollWheelMultiplier();
+ m_client->immediateScrollBy(FloatSize(deltaX, 0));
+ }
+ } else {
+ if (!m_client->allowsHorizontalStretching(wheelEvent)) {
+ deltaX = 0;
+ eventCoalescedDeltaX = 0;
+ } else if (deltaX && !isHorizontallyStretched && !m_client->pinnedInDirection(FloatSize(deltaX, 0))) {
+ deltaX *= scrollWheelMultiplier();
+
+ m_client->immediateScrollByWithoutContentEdgeConstraints(FloatSize(deltaX, 0));
+ deltaX = 0;
+ }
+
+ if (!m_client->allowsVerticalStretching(wheelEvent)) {
+ deltaY = 0;
+ eventCoalescedDeltaY = 0;
+ } else if (deltaY && !isVerticallyStretched && !m_client->pinnedInDirection(FloatSize(0, deltaY))) {
+ deltaY *= scrollWheelMultiplier();
+
+ m_client->immediateScrollByWithoutContentEdgeConstraints(FloatSize(0, deltaY));
+ deltaY = 0;
+ }
+
+ IntSize stretchAmount = m_client->stretchAmount();
+
+ if (m_momentumScrollInProgress) {
+ if ((m_client->pinnedInDirection(FloatSize(eventCoalescedDeltaX, eventCoalescedDeltaY)) || (fabsf(eventCoalescedDeltaX) + fabsf(eventCoalescedDeltaY) <= 0)) && m_lastMomentumScrollTimestamp) {
+ m_ignoreMomentumScrolls = true;
+ m_momentumScrollInProgress = false;
+ snapRubberBand();
+ }
+ }
+
+ m_stretchScrollForce.setWidth(m_stretchScrollForce.width() + deltaX);
+ m_stretchScrollForce.setHeight(m_stretchScrollForce.height() + deltaY);
+
+ FloatSize dampedDelta(ceilf(elasticDeltaForReboundDelta(m_stretchScrollForce.width())), ceilf(elasticDeltaForReboundDelta(m_stretchScrollForce.height())));
+
+ m_client->immediateScrollByWithoutContentEdgeConstraints(dampedDelta - stretchAmount);
+ }
+ }
+
+ if (m_momentumScrollInProgress && momentumPhase == PlatformWheelEventPhaseEnded) {
+ m_momentumScrollInProgress = false;
+ m_ignoreMomentumScrolls = false;
+ m_lastMomentumScrollTimestamp = 0;
+ }
+
+ return true;
+}
+
+static inline float roundTowardZero(float num)
+{
+ return num > 0 ? ceilf(num - 0.5f) : floorf(num + 0.5f);
+}
+
+static inline float roundToDevicePixelTowardZero(float num)
+{
+ float roundedNum = roundf(num);
+ if (fabs(num - roundedNum) < 0.125)
+ num = roundedNum;
+
+ return roundTowardZero(num);
+}
+
+void ScrollController::snapRubberBandTimerFired()
+{
+ if (!m_momentumScrollInProgress || m_ignoreMomentumScrolls) {
+ CFTimeInterval timeDelta = [NSDate timeIntervalSinceReferenceDate] - m_startTime;
+
+ if (m_startStretch == FloatSize()) {
+ m_startStretch = m_client->stretchAmount();
+ if (m_startStretch == FloatSize()) {
+ stopSnapRubberbandTimer();
+
+ m_stretchScrollForce = FloatSize();
+ m_startTime = 0;
+ m_startStretch = FloatSize();
+ m_origOrigin = FloatPoint();
+ m_origVelocity = FloatSize();
+ return;
+ }
+
+ m_origOrigin = m_client->absoluteScrollPosition() - m_startStretch;
+ m_origVelocity = m_momentumVelocity;
+
+ // Just like normal scrolling, prefer vertical rubberbanding
+ if (fabsf(m_origVelocity.height()) >= fabsf(m_origVelocity.width()))
+ m_origVelocity.setWidth(0);
+
+ // Don't rubber-band horizontally if it's not possible to scroll horizontally
+ if (!m_client->canScrollHorizontally())
+ m_origVelocity.setWidth(0);
+
+ // Don't rubber-band vertically if it's not possible to scroll vertically
+ if (!m_client->canScrollVertically())
+ m_origVelocity.setHeight(0);
+ }
+
+ FloatPoint delta(roundToDevicePixelTowardZero(elasticDeltaForTimeDelta(m_startStretch.width(), -m_origVelocity.width(), (float)timeDelta)),
+ roundToDevicePixelTowardZero(elasticDeltaForTimeDelta(m_startStretch.height(), -m_origVelocity.height(), (float)timeDelta)));
+
+ if (fabs(delta.x()) >= 1 || fabs(delta.y()) >= 1) {
+ m_client->immediateScrollByWithoutContentEdgeConstraints(FloatSize(delta.x(), delta.y()) - m_client->stretchAmount());
+
+ FloatSize newStretch = m_client->stretchAmount();
+
+ m_stretchScrollForce.setWidth(reboundDeltaForElasticDelta(newStretch.width()));
+ m_stretchScrollForce.setHeight(reboundDeltaForElasticDelta(newStretch.height()));
+ } else {
+ m_client->adjustScrollPositionToBoundsIfNecessary();
+
+ stopSnapRubberbandTimer();
+ m_stretchScrollForce = FloatSize();
+ m_startTime = 0;
+ m_startStretch = FloatSize();
+ m_origOrigin = FloatPoint();
+ m_origVelocity = FloatSize();
+ }
+ } else {
+ m_startTime = [NSDate timeIntervalSinceReferenceDate];
+ m_startStretch = FloatSize();
+ }
+}
+
+bool ScrollController::isRubberBandInProgress() const
+{
+ if (!m_inScrollGesture && !m_momentumScrollInProgress && !m_snapRubberbandTimerIsActive)
+ return false;
+
+ return !m_client->stretchAmount().isZero();
+}
+
+void ScrollController::stopSnapRubberbandTimer()
+{
+ m_client->stopSnapRubberbandTimer();
+ m_snapRubberbandTimerIsActive = false;
+}
+
+void ScrollController::snapRubberBand()
+{
+ CFTimeInterval timeDelta = systemUptime() - m_lastMomentumScrollTimestamp;
+ if (m_lastMomentumScrollTimestamp && timeDelta >= scrollVelocityZeroingTimeout)
+ m_momentumVelocity = FloatSize();
+
+ m_inScrollGesture = false;
+
+ if (m_snapRubberbandTimerIsActive)
+ return;
+
+ m_startTime = [NSDate timeIntervalSinceReferenceDate];
+ m_startStretch = FloatSize();
+ m_origOrigin = FloatPoint();
+ m_origVelocity = FloatSize();
+
+ m_client->startSnapRubberbandTimer();
+ m_snapRubberbandTimerIsActive = true;
+}
+
+bool ScrollController::shouldRubberBandInHorizontalDirection(const PlatformWheelEvent& wheelEvent)
+{
+ if (wheelEvent.deltaX() > 0)
+ return m_client->shouldRubberBandInDirection(ScrollLeft);
+ if (wheelEvent.deltaX() < 0)
+ return m_client->shouldRubberBandInDirection(ScrollRight);
+
+ return true;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(RUBBER_BANDING)
</ins></span></pre>
</div>
</div>
</body>
</html>