<!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>[180902] 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/180902">180902</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2015-03-02 15:49:24 -0800 (Mon, 02 Mar 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Move scroll animating functions from ScrollAnimator to ScrollController
https://bugs.webkit.org/show_bug.cgi?id=142102
<rdar://problem/20007161>
Reviewed by Simon Fraser.
No change in functionality.
Do some refactoring of the various scrolling classes:
1. Consolidate animation times to RunLoop::Timer instead of a combination of WebCore::Timer
and CFRunLoopTimers. Do this for Scroll Snap Point and Rubberband animations.
2. Move ScrollController from platform/mac to platform/cocoa to enable sharing with iOS.
3. Move code from ScrollAnimator{Mac} -> ScrollController.
4. Rename scrollOffsetInAxis -> scrollOffsetOnAxis
5. Rename immediateScrollInAxis -> immediateScrollOnAxis
* WebCore.xcodeproj/project.pbxproj: Move ScrollController to 'platform/cocoa'
* page/mac/EventHandlerMac.mm: Make sure the scroll controller is notified of end-of-scroll
events, just as is done for the "event not handled" case in EventHandler.cpp.
(WebCore::EventHandler::platformCompleteWheelEvent):
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h: Remove timer and some delegate
methods, now that ScrollController is controlling this state.
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
(WebCore::ScrollingTreeFrameScrollingNodeMac::~ScrollingTreeFrameScrollingNodeMac): We no longer
need to clean up the CFRunLoopTimer.
(WebCore::ScrollingTreeFrameScrollingNodeMac::scrollOffsetOnAxis): Add temporary stub needed
until Bug 141973 is completed.).
(WebCore::ScrollingTreeFrameScrollingNodeMac::immediateScrollOnAxis): Ditto.
(WebCore::ScrollingTreeFrameScrollingNodeMac::startSnapRubberbandTimer): Deleted.
(WebCore::ScrollingTreeFrameScrollingNodeMac::stopSnapRubberbandTimer): Deleted.
* platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::ScrollAnimator):
(WebCore::ScrollAnimator::processWheelEventForScrollSnap): Just call the ScrollController method.
(WebCore::ScrollAnimator::handleWheelEvent): Ditto.
(WebCore::ScrollAnimator::updateScrollAnimatorsAndTimers): Ditto.
(WebCore::ScrollAnimator::scrollOffsetOnAxis): Renamed from scrollOffsetInAxis.
(WebCore::ScrollAnimator::scrollOffsetInAxis): Deleted.
(WebCore::ScrollAnimator::immediateScrollOnAxis): Renamed from immediateScrollInAxis.
(WebCore::ScrollAnimator::immediateScrollInAxis): Deleted.
(WebCore::ScrollAnimator::startScrollSnapTimer): Deleted.
(WebCore::ScrollAnimator::stopScrollSnapTimer): Deleted.
(WebCore::ScrollAnimator::horizontalScrollSnapTimerFired): Deleted.
(WebCore::ScrollAnimator::verticalScrollSnapTimerFired): Deleted.
* platform/ScrollAnimator.h:
* platform/cocoa/ScrollController.h: Copied from platform/mac/ScrollController.h.
* platform/cocoa/ScrollController.mm: Copied from platform/mac/ScrollController.mm.
(WebCore::ScrollController::ScrollController): Update to initialize new timers.
(WebCore::ScrollController::handleWheelEvent): Update to handle Scroll Snap Point events.
(WebCore::ScrollController::startSnapRubberbandTimer): Added.
(WebCore::ScrollController::stopSnapRubberbandTimer): Manage animation timers locally, do not
require client to maintain timers.
(WebCore::ScrollController::snapRubberBand): Ditto.
(WebCore::ScrollController::processWheelEventForScrollSnap): Added. (Moved from ScrollAnimatorMac)
(WebCore::ScrollController::updateScrollAnimatorsAndTimers): Ditto. Also updated to use RunLoop::Timer.
(WebCore::ScrollController::startScrollSnapTimer): Ditto. Also updated to use RunLoop::Timer.
(WebCore::ScrollController::stopScrollSnapTimer): Ditto. Also updated to use RunLoop::Timer.
(WebCore::ScrollController::horizontalScrollSnapTimerFired): Ditto.
(WebCore::ScrollController::verticalScrollSnapTimerFired): Ditto.
(WebCore::ScrollController::scrollOffsetOnAxis): Moved from ScrollAnimatorMac.
(WebCore::ScrollController::immediateScrollOnAxis): Ditto.
* platform/mac/AxisScrollSnapAnimator.h: Rename methods from 'InAxis' to 'OnAxis'
* platform/mac/AxisScrollSnapAnimator.mm: Ditto.
* platform/mac/ScrollAnimatorMac.h:
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::ScrollAnimatorMac): Remove unused Rubberband timers (now that this is
controlled in the ScrollController)
(WebCore::ScrollAnimatorMac::startSnapRubberbandTimer): Deleted.
(WebCore::ScrollAnimatorMac::stopSnapRubberbandTimer): Deleted.
(WebCore::ScrollAnimatorMac::snapRubberBandTimerFired): Deleted.
* platform/mac/ScrollController.h: Removed.
* platform/mac/ScrollController.mm: 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="#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="#trunkSourceWebCoreplatformcocoaScrollControllerh">trunk/Source/WebCore/platform/cocoa/ScrollController.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaScrollControllermm">trunk/Source/WebCore/platform/cocoa/ScrollController.mm</a></li>
</ul>
<h3>Removed 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>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (180901 => 180902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-03-02 23:39:47 UTC (rev 180901)
+++ trunk/Source/WebCore/ChangeLog        2015-03-02 23:49:24 UTC (rev 180902)
</span><span class="lines">@@ -1,3 +1,77 @@
</span><ins>+2015-03-02 Brent Fulgham <bfulgham@apple.com>
+
+ Move scroll animating functions from ScrollAnimator to ScrollController
+ https://bugs.webkit.org/show_bug.cgi?id=142102
+ <rdar://problem/20007161>
+
+ Reviewed by Simon Fraser.
+
+ No change in functionality.
+
+ Do some refactoring of the various scrolling classes:
+ 1. Consolidate animation times to RunLoop::Timer instead of a combination of WebCore::Timer
+ and CFRunLoopTimers. Do this for Scroll Snap Point and Rubberband animations.
+ 2. Move ScrollController from platform/mac to platform/cocoa to enable sharing with iOS.
+ 3. Move code from ScrollAnimator{Mac} -> ScrollController.
+ 4. Rename scrollOffsetInAxis -> scrollOffsetOnAxis
+ 5. Rename immediateScrollInAxis -> immediateScrollOnAxis
+
+ * WebCore.xcodeproj/project.pbxproj: Move ScrollController to 'platform/cocoa'
+ * page/mac/EventHandlerMac.mm: Make sure the scroll controller is notified of end-of-scroll
+ events, just as is done for the "event not handled" case in EventHandler.cpp.
+ (WebCore::EventHandler::platformCompleteWheelEvent):
+ * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h: Remove timer and some delegate
+ methods, now that ScrollController is controlling this state.
+ * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
+ (WebCore::ScrollingTreeFrameScrollingNodeMac::~ScrollingTreeFrameScrollingNodeMac): We no longer
+ need to clean up the CFRunLoopTimer.
+ (WebCore::ScrollingTreeFrameScrollingNodeMac::scrollOffsetOnAxis): Add temporary stub needed
+ until Bug 141973 is completed.).
+ (WebCore::ScrollingTreeFrameScrollingNodeMac::immediateScrollOnAxis): Ditto.
+ (WebCore::ScrollingTreeFrameScrollingNodeMac::startSnapRubberbandTimer): Deleted.
+ (WebCore::ScrollingTreeFrameScrollingNodeMac::stopSnapRubberbandTimer): Deleted.
+ * platform/ScrollAnimator.cpp:
+ (WebCore::ScrollAnimator::ScrollAnimator):
+ (WebCore::ScrollAnimator::processWheelEventForScrollSnap): Just call the ScrollController method.
+ (WebCore::ScrollAnimator::handleWheelEvent): Ditto.
+ (WebCore::ScrollAnimator::updateScrollAnimatorsAndTimers): Ditto.
+ (WebCore::ScrollAnimator::scrollOffsetOnAxis): Renamed from scrollOffsetInAxis.
+ (WebCore::ScrollAnimator::scrollOffsetInAxis): Deleted.
+ (WebCore::ScrollAnimator::immediateScrollOnAxis): Renamed from immediateScrollInAxis.
+ (WebCore::ScrollAnimator::immediateScrollInAxis): Deleted.
+ (WebCore::ScrollAnimator::startScrollSnapTimer): Deleted.
+ (WebCore::ScrollAnimator::stopScrollSnapTimer): Deleted.
+ (WebCore::ScrollAnimator::horizontalScrollSnapTimerFired): Deleted.
+ (WebCore::ScrollAnimator::verticalScrollSnapTimerFired): Deleted.
+ * platform/ScrollAnimator.h:
+ * platform/cocoa/ScrollController.h: Copied from platform/mac/ScrollController.h.
+ * platform/cocoa/ScrollController.mm: Copied from platform/mac/ScrollController.mm.
+ (WebCore::ScrollController::ScrollController): Update to initialize new timers.
+ (WebCore::ScrollController::handleWheelEvent): Update to handle Scroll Snap Point events.
+ (WebCore::ScrollController::startSnapRubberbandTimer): Added.
+ (WebCore::ScrollController::stopSnapRubberbandTimer): Manage animation timers locally, do not
+ require client to maintain timers.
+ (WebCore::ScrollController::snapRubberBand): Ditto.
+ (WebCore::ScrollController::processWheelEventForScrollSnap): Added. (Moved from ScrollAnimatorMac)
+ (WebCore::ScrollController::updateScrollAnimatorsAndTimers): Ditto. Also updated to use RunLoop::Timer.
+ (WebCore::ScrollController::startScrollSnapTimer): Ditto. Also updated to use RunLoop::Timer.
+ (WebCore::ScrollController::stopScrollSnapTimer): Ditto. Also updated to use RunLoop::Timer.
+ (WebCore::ScrollController::horizontalScrollSnapTimerFired): Ditto.
+ (WebCore::ScrollController::verticalScrollSnapTimerFired): Ditto.
+ (WebCore::ScrollController::scrollOffsetOnAxis): Moved from ScrollAnimatorMac.
+ (WebCore::ScrollController::immediateScrollOnAxis): Ditto.
+ * platform/mac/AxisScrollSnapAnimator.h: Rename methods from 'InAxis' to 'OnAxis'
+ * platform/mac/AxisScrollSnapAnimator.mm: Ditto.
+ * platform/mac/ScrollAnimatorMac.h:
+ * platform/mac/ScrollAnimatorMac.mm:
+ (WebCore::ScrollAnimatorMac::ScrollAnimatorMac): Remove unused Rubberband timers (now that this is
+ controlled in the ScrollController)
+ (WebCore::ScrollAnimatorMac::startSnapRubberbandTimer): Deleted.
+ (WebCore::ScrollAnimatorMac::stopSnapRubberbandTimer): Deleted.
+ (WebCore::ScrollAnimatorMac::snapRubberBandTimerFired): Deleted.
+ * platform/mac/ScrollController.h: Removed.
+ * platform/mac/ScrollController.mm: Removed.
+
</ins><span class="cx"> 2015-03-02 Mark Lam <mark.lam@apple.com>
</span><span class="cx">
</span><span class="cx"> The InspectorTimelineAgent should gracefully handle attempts to start more than once.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (180901 => 180902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-03-02 23:39:47 UTC (rev 180901)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-03-02 23:49:24 UTC (rev 180902)
</span><span class="lines">@@ -786,8 +786,6 @@
</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><del>-                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, ); }; };
</del><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">@@ -2445,6 +2443,8 @@
</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><ins>+                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 */; };
</ins><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,8 +7809,6 @@
</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><del>-                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>"; };
</del><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">@@ -9667,6 +9665,8 @@
</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><ins>+                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>"; };
</ins><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,8 +16587,6 @@
</span><span class="cx">                                 BC51156D12B1749C00C96754 /* ScrollAnimatorMac.mm */,
</span><span class="cx">                                 BC8B853C0E7C7F1100AB6984 /* ScrollbarThemeMac.h */,
</span><span class="cx">                                 BCEF869E0E844E9D00A85CD5 /* ScrollbarThemeMac.mm */,
</span><del>-                                1AA84F03143BA7BD0051D153 /* ScrollController.h */,
-                                1AA84F02143BA7BD0051D153 /* ScrollController.mm */,
</del><span class="cx">                                 9353676A09AED88B00D35CD6 /* ScrollViewMac.mm */,
</span><span class="cx">                                 077AF14118F4B1BB0001ED61 /* SerializedPlatformRepresentationMac.h */,
</span><span class="cx">                                 077AF14218F4B1BB0001ED61 /* SerializedPlatformRepresentationMac.mm */,
</span><span class="lines">@@ -18698,6 +18696,8 @@
</span><span class="cx">                                 1A0409F21A43675C009E47F3 /* MachSendRight.cpp */,
</span><span class="cx">                                 1A0409DB1A4360B5009E47F3 /* MachSendRight.h */,
</span><span class="cx">                                 ADB6B29718FB90240081963E /* MemoryPressureHandlerCocoa.mm */,
</span><ins>+                                7AFFA4111AA1039D00F0125B /* ScrollController.h */,
+                                7AFFA4121AA1039D00F0125B /* ScrollController.mm */,
</ins><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,6 +24648,7 @@
</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><ins>+                                7A9ADFF31AA1163800D2733C /* ScrollController.h in Headers */,
</ins><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">@@ -26101,7 +26102,6 @@
</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><del>-                                1AA84F05143BA7BD0051D153 /* ScrollController.h in Headers */,
</del><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,6 +27496,7 @@
</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><ins>+                                7A9ADFF41AA1163B00D2733C /* ScrollController.mm in Sources */,
</ins><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">@@ -29508,7 +29509,6 @@
</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><del>-                                1AA84F04143BA7BD0051D153 /* ScrollController.mm in Sources */,
</del><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 (180901 => 180902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/mac/EventHandlerMac.mm        2015-03-02 23:39:47 UTC (rev 180901)
+++ trunk/Source/WebCore/page/mac/EventHandlerMac.mm        2015-03-02 23:49:24 UTC (rev 180902)
</span><span class="lines">@@ -961,6 +961,12 @@
</span><span class="cx">
</span><span class="cx"> bool didHandleEvent = view ? view->wheelEvent(wheelEvent) : false;
</span><span class="cx"> m_isHandlingWheelEvent = false;
</span><ins>+
+#if ENABLE(CSS_SCROLL_SNAP)
+ if (scrollableArea)
+ platformNotifySnapIfNecessary(wheelEvent, *scrollableArea);
+#endif
+
</ins><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 (180901 => 180902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h        2015-03-02 23:39:47 UTC (rev 180901)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h        2015-03-02 23:49:24 UTC (rev 180902)
</span><span class="lines">@@ -61,8 +61,6 @@
</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><del>- virtual void startSnapRubberbandTimer() override;
- virtual void stopSnapRubberbandTimer() override;
</del><span class="cx"> virtual void adjustScrollPositionToBoundsIfNecessary() override;
</span><span class="cx">
</span><span class="cx"> virtual FloatPoint scrollPosition() const override;
</span><span class="lines">@@ -80,10 +78,14 @@
</span><span class="cx">
</span><span class="cx"> bool isAlreadyPinnedInDirectionOfGesture(const PlatformWheelEvent&, ScrollEventAxis);
</span><span class="cx">
</span><ins>+#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
+ LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) override;
+ void immediateScrollOnAxis(ScrollEventAxis, float delta) override;
+#endif
+
</ins><span class="cx"> void logExposedUnfilledArea();
</span><span class="cx">
</span><span class="cx"> ScrollController m_scrollController;
</span><del>- RetainPtr<CFRunLoopTimerRef> m_snapRubberbandTimer;
</del><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 (180901 => 180902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm        2015-03-02 23:39:47 UTC (rev 180901)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm        2015-03-02 23:49:24 UTC (rev 180902)
</span><span class="lines">@@ -66,8 +66,6 @@
</span><span class="cx">
</span><span class="cx"> ScrollingTreeFrameScrollingNodeMac::~ScrollingTreeFrameScrollingNodeMac()
</span><span class="cx"> {
</span><del>- if (m_snapRubberbandTimer)
- CFRunLoopTimerInvalidate(m_snapRubberbandTimer.get());
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void ScrollingTreeFrameScrollingNodeMac::updateBeforeChildren(const ScrollingStateNode& stateNode)
</span><span class="lines">@@ -296,32 +294,6 @@
</span><span class="cx"> scrollByWithoutContentEdgeConstraints(offset);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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;
-}
-
</del><span class="cx"> void ScrollingTreeFrameScrollingNodeMac::adjustScrollPositionToBoundsIfNecessary()
</span><span class="cx"> {
</span><span class="cx"> FloatPoint currentScrollPosition = absoluteScrollPosition();
</span><span class="lines">@@ -540,6 +512,19 @@
</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><ins>+#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
+
</ins><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 (180901 => 180902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollAnimator.cpp        2015-03-02 23:39:47 UTC (rev 180901)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp        2015-03-02 23:49:24 UTC (rev 180902)
</span><span class="lines">@@ -49,6 +49,9 @@
</span><span class="cx">
</span><span class="cx"> ScrollAnimator::ScrollAnimator(ScrollableArea& scrollableArea)
</span><span class="cx"> : m_scrollableArea(scrollableArea)
</span><ins>+#if (ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)) && PLATFORM(MAC)
+ , m_scrollController(this)
+#endif
</ins><span class="cx"> , m_currentPosX(0)
</span><span class="cx"> , m_currentPosY(0)
</span><span class="cx"> {
</span><span class="lines">@@ -81,28 +84,16 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
</span><del>-void ScrollAnimator::processWheelEventForScrollSnap(const PlatformWheelEvent& wheelEvent)
</del><ins>+bool ScrollAnimator::processWheelEventForScrollSnap(const PlatformWheelEvent& wheelEvent)
</ins><span class="cx"> {
</span><del>- if (m_verticalScrollSnapAnimator)
- m_verticalScrollSnapAnimator->handleWheelEvent(wheelEvent);
- if (m_horizontalScrollSnapAnimator)
- m_horizontalScrollSnapAnimator->handleWheelEvent(wheelEvent);
</del><ins>+ return m_scrollController.processWheelEventForScrollSnap(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>- 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;
- }
</del><ins>+ m_scrollController.processWheelEventForScrollSnap(e);
</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">@@ -183,30 +174,15 @@
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
</span><span class="cx"> void ScrollAnimator::updateScrollAnimatorsAndTimers()
</span><span class="cx"> {
</span><del>- // 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;
- }
</del><ins>+ m_scrollController.updateScrollAnimatorsAndTimers(m_scrollableArea);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-LayoutUnit ScrollAnimator::scrollOffsetInAxis(ScrollEventAxis axis)
</del><ins>+LayoutUnit ScrollAnimator::scrollOffsetOnAxis(ScrollEventAxis axis)
</ins><span class="cx"> {
</span><del>- FloatPoint currentPosition = this->currentPosition();
- return axis == ScrollEventAxis::Horizontal ? currentPosition.x() : currentPosition.y();
</del><ins>+ return axis == ScrollEventAxis::Horizontal ? m_currentPosX : m_currentPosY;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void ScrollAnimator::immediateScrollInAxis(ScrollEventAxis axis, float delta)
</del><ins>+void ScrollAnimator::immediateScrollOnAxis(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">@@ -214,30 +190,6 @@
</span><span class="cx"> else
</span><span class="cx"> scrollToOffsetWithoutAnimation(FloatPoint(currentPosition.x(), currentPosition.y() + delta));
</span><span class="cx"> }
</span><del>-
-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();
-}
</del><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 (180901 => 180902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollAnimator.h        2015-03-02 23:39:47 UTC (rev 180901)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h        2015-03-02 23:49:24 UTC (rev 180902)
</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><ins>+#include "LayoutUnit.h"
</ins><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(CSS_SCROLL_SNAP) && PLATFORM(MAC)
-#include "AxisScrollSnapAnimator.h"
-#include "Timer.h"
</del><ins>+#if (ENABLE(RUBBER_BANDING) || ENABLE(CSS_SCROLL_SNAP)) && PLATFORM(MAC)
+#include "ScrollController.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) && PLATFORM(MAC)
-class ScrollAnimator : public AxisScrollSnapAnimatorClient {
</del><ins>+#if (ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)) && PLATFORM(MAC)
+class ScrollAnimator : private ScrollControllerClient {
</ins><span class="cx"> #else
</span><span class="cx"> class ScrollAnimator {
</span><span class="cx"> #endif
</span><span class="lines">@@ -118,33 +118,22 @@
</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>- void processWheelEventForScrollSnap(const PlatformWheelEvent&);
</del><ins>+ bool processWheelEventForScrollSnap(const PlatformWheelEvent&);
+
</ins><span class="cx"> void updateScrollAnimatorsAndTimers();
</span><del>- virtual LayoutUnit scrollOffsetInAxis(ScrollEventAxis) override;
- virtual void immediateScrollInAxis(ScrollEventAxis, float delta) override;
- virtual void startScrollSnapTimer(ScrollEventAxis) override;
- virtual void stopScrollSnapTimer(ScrollEventAxis) override;
</del><ins>+ LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) override;
+ void immediateScrollOnAxis(ScrollEventAxis, float delta) 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><del>-#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
-
</del><span class="cx"> ScrollableArea& m_scrollableArea;
</span><ins>+#if (ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)) && PLATFORM(MAC)
+ ScrollController m_scrollController;
+#endif
</ins><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><del>-#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
</del><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaScrollControllerhfromrev180702trunkSourceWebCoreplatformmacScrollControllerh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/cocoa/ScrollController.h (from rev 180702, trunk/Source/WebCore/platform/mac/ScrollController.h) (0 => 180902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/ScrollController.h         (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.h        2015-03-02 23:49:24 UTC (rev 180902)
</span><span class="lines">@@ -0,0 +1,144 @@
</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.
+ */
+
+#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
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaScrollControllermmfromrev180702trunkSourceWebCoreplatformmacScrollControllermm"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/cocoa/ScrollController.mm (from rev 180702, trunk/Source/WebCore/platform/mac/ScrollController.mm) (0 => 180902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/ScrollController.mm         (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.mm        2015-03-02 23:49:24 UTC (rev 180902)
</span><span class="lines">@@ -0,0 +1,492 @@
</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(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)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmacAxisScrollSnapAnimatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.h (180901 => 180902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.h        2015-03-02 23:39:47 UTC (rev 180901)
+++ trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.h        2015-03-02 23:49:24 UTC (rev 180902)
</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 scrollOffsetInAxis(ScrollEventAxis) = 0;
- virtual void immediateScrollInAxis(ScrollEventAxis, float velocity) = 0;
</del><ins>+ virtual LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) = 0;
+ virtual void immediateScrollOnAxis(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 (180901 => 180902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.mm        2015-03-02 23:39:47 UTC (rev 180901)
+++ trunk/Source/WebCore/platform/mac/AxisScrollSnapAnimator.mm        2015-03-02 23:49:24 UTC (rev 180902)
</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->scrollOffsetInAxis(m_axis);
</del><ins>+ m_beginTrackingWheelDeltaOffset = m_client->scrollOffsetOnAxis(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->immediateScrollInAxis(m_axis, delta);
</del><ins>+ m_client->immediateScrollOnAxis(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->scrollOffsetInAxis(m_axis);
</del><ins>+ LayoutUnit offset = m_client->scrollOffsetOnAxis(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->scrollOffsetInAxis(m_axis);
</del><ins>+ LayoutUnit offset = m_client->scrollOffsetOnAxis(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->scrollOffsetInAxis(m_axis);
</del><ins>+ LayoutUnit offset = m_client->scrollOffsetOnAxis(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 (180901 => 180902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h        2015-03-02 23:39:47 UTC (rev 180901)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h        2015-03-02 23:49:24 UTC (rev 180902)
</span><span class="lines">@@ -32,7 +32,6 @@
</span><span class="cx"> #include "FloatPoint.h"
</span><span class="cx"> #include "FloatSize.h"
</span><span class="cx"> #include "ScrollAnimator.h"
</span><del>-#include "ScrollController.h"
</del><span class="cx"> #include "Timer.h"
</span><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="cx">
</span><span class="lines">@@ -42,15 +41,11 @@
</span><span class="cx">
</span><span class="cx"> typedef id ScrollbarPainterController;
</span><span class="cx">
</span><del>-#if !ENABLE(RUBBER_BANDING)
-class ScrollControllerClient { };
-#endif
-
</del><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, private ScrollControllerClient {
</del><ins>+class ScrollAnimatorMac : public ScrollAnimator {
</ins><span class="cx">
</span><span class="cx"> public:
</span><span class="cx"> ScrollAnimatorMac(ScrollableArea&);
</span><span class="lines">@@ -150,17 +145,11 @@
</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><del>- virtual void startSnapRubberbandTimer() override;
- virtual void stopSnapRubberbandTimer() override;
</del><span class="cx"> virtual void adjustScrollPositionToBoundsIfNecessary() override;
</span><span class="cx">
</span><span class="cx"> bool pinnedInDirection(float deltaX, float deltaY);
</span><del>- void snapRubberBandTimerFired();
</del><span class="cx">
</span><span class="cx"> bool isAlreadyPinnedInDirectionOfGesture(const PlatformWheelEvent&, ScrollEventAxis);
</span><del>-
- ScrollController m_scrollController;
- Timer m_snapRubberBandTimer;
</del><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 (180901 => 180902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm        2015-03-02 23:39:47 UTC (rev 180901)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm        2015-03-02 23:49:24 UTC (rev 180902)
</span><span class="lines">@@ -643,10 +643,6 @@
</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><del>-#if ENABLE(RUBBER_BANDING)
- , m_scrollController(this)
- , m_snapRubberBandTimer(*this, &ScrollAnimatorMac::snapRubberBandTimerFired)
-#endif
</del><span class="cx"> , m_haveScrolledSincePageLoad(false)
</span><span class="cx"> , m_needsScrollerStyleUpdate(false)
</span><span class="cx"> {
</span><span class="lines">@@ -1270,21 +1266,6 @@
</span><span class="cx"> m_currentPosY = newPos.y();
</span><span class="cx"> notifyPositionChanged(adjustedDelta);
</span><span class="cx"> }
</span><del>-
-void ScrollAnimatorMac::startSnapRubberbandTimer()
-{
- m_snapRubberBandTimer.startRepeating(1.0 / 60.0);
-}
-
-void ScrollAnimatorMac::stopSnapRubberbandTimer()
-{
- m_snapRubberBandTimer.stop();
-}
-
-void ScrollAnimatorMac::snapRubberBandTimerFired()
-{
- m_scrollController.snapRubberBandTimerFired();
-}
</del><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> void ScrollAnimatorMac::updateScrollerStyle()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacScrollControllerh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/mac/ScrollController.h (180901 => 180902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/ScrollController.h        2015-03-02 23:39:47 UTC (rev 180901)
+++ trunk/Source/WebCore/platform/mac/ScrollController.h        2015-03-02 23:49:24 UTC (rev 180902)
</span><span class="lines">@@ -1,107 +0,0 @@
</span><del>-/*
- * 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
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformmacScrollControllermm"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/mac/ScrollController.mm (180901 => 180902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/ScrollController.mm        2015-03-02 23:39:47 UTC (rev 180901)
+++ trunk/Source/WebCore/platform/mac/ScrollController.mm        2015-03-02 23:49:24 UTC (rev 180902)
</span><span class="lines">@@ -1,406 +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(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)
</del></span></pre>
</div>
</div>
</body>
</html>