Title: [185681] trunk/Source
Revision
185681
Author
[email protected]
Date
2015-06-17 17:32:33 -0700 (Wed, 17 Jun 2015)

Log Message

Overflow regions with scroll snap points are not reliably rubber banding
https://bugs.webkit.org/show_bug.cgi?id=142522
<rdar://problem/20100726>

Reviewed by Darin Adler.

Source/WebCore:

When computing the target scroll destination, update the nearest snap point index
and other bookkeeping, but keep the original gesture target if it would have taken
us beyond either limit of the scroll container.

* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
(WebCore::ScrollingTreeFrameScrollingNodeMac::scrollExtents): Add new method
to support client API.
* platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::scrollExtents): Add new method to support client API.
* platform/ScrollAnimator.h:
* platform/cocoa/ScrollController.h:
(WebCore::ScrollControllerClient::scrollExtents): Added new pure virtual method to API.
* platform/cocoa/ScrollController.mm:
(WebCore::ScrollController::beginScrollSnapAnimation): Hold onto original user gesture
target, and use that instead of our nearest snap point if the gesture takes us past
either extreme of the scroll container.

Source/WebKit2:

Make sure we don't block rubberbanding behavior when a scroll gesture should take us past
the end of the scroll container.

* UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
(-[WKOverflowScrollViewDelegate scrollViewWillEndDragging:withVelocity:targetContentOffset:]): Don't adjust
target point if we were going to scroll past the edges of the scroll container.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (185680 => 185681)


--- trunk/Source/WebCore/ChangeLog	2015-06-18 00:22:23 UTC (rev 185680)
+++ trunk/Source/WebCore/ChangeLog	2015-06-18 00:32:33 UTC (rev 185681)
@@ -1,3 +1,29 @@
+2015-06-17  Brent Fulgham  <[email protected]>
+
+        Overflow regions with scroll snap points are not reliably rubber banding
+        https://bugs.webkit.org/show_bug.cgi?id=142522
+        <rdar://problem/20100726>
+
+        Reviewed by Darin Adler.
+
+        When computing the target scroll destination, update the nearest snap point index
+        and other bookkeeping, but keep the original gesture target if it would have taken
+        us beyond either limit of the scroll container.
+
+        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
+        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeFrameScrollingNodeMac::scrollExtents): Add new method
+        to support client API.
+        * platform/ScrollAnimator.cpp:
+        (WebCore::ScrollAnimator::scrollExtents): Add new method to support client API.
+        * platform/ScrollAnimator.h:
+        * platform/cocoa/ScrollController.h:
+        (WebCore::ScrollControllerClient::scrollExtents): Added new pure virtual method to API.
+        * platform/cocoa/ScrollController.mm:
+        (WebCore::ScrollController::beginScrollSnapAnimation): Hold onto original user gesture
+        target, and use that instead of our nearest snap point if the gesture takes us past
+        either extreme of the scroll container.
+
 2015-06-17  Tim Horton  <[email protected]>
 
         Swipe gesture can get stuck, preventing scrolling and other gestures

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h (185680 => 185681)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h	2015-06-18 00:22:23 UTC (rev 185680)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h	2015-06-18 00:32:33 UTC (rev 185681)
@@ -88,6 +88,7 @@
     float pageScaleFactor() const override;
     void startScrollSnapTimer(ScrollEventAxis) override;
     void stopScrollSnapTimer(ScrollEventAxis) override;
+    LayoutSize scrollExtent() const override;
 #endif
 
     void logExposedUnfilledArea();

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm (185680 => 185681)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm	2015-06-18 00:22:23 UTC (rev 185680)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm	2015-06-18 00:32:33 UTC (rev 185681)
@@ -29,6 +29,7 @@
 #if ENABLE(ASYNC_SCROLLING) && PLATFORM(MAC)
 
 #import "FrameView.h"
+#import "LayoutSize.h"
 #import "Logging.h"
 #import "NSScrollerImpDetails.h"
 #import "PlatformWheelEvent.h"
@@ -587,6 +588,11 @@
     if (!m_scrollController.hasActiveScrollSnapTimerForAxis(otherAxis))
         scrollingTree().setMainFrameIsScrollSnapping(false);
 }
+    
+LayoutSize ScrollingTreeFrameScrollingNodeMac::scrollExtent() const
+{
+    return LayoutSize(totalContentsSize());
+}
 #endif
 
 void ScrollingTreeFrameScrollingNodeMac::deferTestsForReason(WheelEventTestTrigger::ScrollableAreaIdentifier identifier, WheelEventTestTrigger::DeferTestTriggerReason reason) const

Modified: trunk/Source/WebCore/platform/ScrollAnimator.cpp (185680 => 185681)


--- trunk/Source/WebCore/platform/ScrollAnimator.cpp	2015-06-18 00:22:23 UTC (rev 185680)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp	2015-06-18 00:32:33 UTC (rev 185681)
@@ -33,6 +33,7 @@
 #include "ScrollAnimator.h"
 
 #include "FloatPoint.h"
+#include "LayoutSize.h"
 #include "PlatformWheelEvent.h"
 #include "ScrollableArea.h"
 #include <algorithm>
@@ -213,6 +214,11 @@
     else
         scrollToOffsetWithoutAnimation(FloatPoint(currentPosition.x(), currentPosition.y() + delta));
 }
+
+LayoutSize ScrollAnimator::scrollExtent() const
+{
+    return m_scrollableArea.contentsSize();
+}
 #endif
 
 #if (ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)) && PLATFORM(MAC)

Modified: trunk/Source/WebCore/platform/ScrollAnimator.h (185680 => 185681)


--- trunk/Source/WebCore/platform/ScrollAnimator.h	2015-06-18 00:22:23 UTC (rev 185680)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h	2015-06-18 00:32:33 UTC (rev 185681)
@@ -135,6 +135,7 @@
     void immediateScrollOnAxis(ScrollEventAxis, float delta) override;
     bool activeScrollSnapIndexDidChange() const;
     unsigned activeScrollSnapIndexForAxis(ScrollEventAxis) const;
+    LayoutSize scrollExtent() const override;
 #endif
 
 protected:

Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.h (185680 => 185681)


--- trunk/Source/WebCore/platform/cocoa/ScrollController.h	2015-06-18 00:22:23 UTC (rev 185680)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.h	2015-06-18 00:32:33 UTC (rev 185681)
@@ -41,6 +41,7 @@
 
 namespace WebCore {
 
+class LayoutSize;
 class PlatformWheelEvent;
 class ScrollableArea;
 class WheelEventTestTrigger;
@@ -102,6 +103,8 @@
     {
         return 0;
     }
+
+    virtual LayoutSize scrollExtent() const = 0;
 #endif
 };
 

Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.mm (185680 => 185681)


--- trunk/Source/WebCore/platform/cocoa/ScrollController.mm	2015-06-18 00:22:23 UTC (rev 185680)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.mm	2015-06-18 00:32:33 UTC (rev 185681)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "ScrollController.h"
 
+#include "LayoutSize.h"
 #include "PlatformWheelEvent.h"
 #include "WebCoreSystemInterface.h"
 #include "WheelEventTestTrigger.h"
@@ -752,18 +753,24 @@
 
     LayoutUnit offset = m_client.scrollOffsetOnAxis(axis);
     float initialWheelDelta = newState == ScrollSnapState::Gliding ? snapState.averageInitialWheelDelta() : 0;
-    LayoutUnit projectedScrollDestination = newState == ScrollSnapState::Gliding ? snapState.m_beginTrackingWheelDeltaOffset + LayoutUnit(projectedInertialScrollDistance(initialWheelDelta)) : offset;
+    LayoutUnit scaledProjectedScrollDestination = newState == ScrollSnapState::Gliding ? snapState.m_beginTrackingWheelDeltaOffset + LayoutUnit(projectedInertialScrollDistance(initialWheelDelta)) : offset;
     if (snapState.m_snapOffsets.isEmpty())
         return;
 
     float scaleFactor = m_client.pageScaleFactor();
+    LayoutUnit originalProjectedScrollDestination = scaledProjectedScrollDestination / scaleFactor;
     
-    projectedScrollDestination = std::min(std::max(LayoutUnit(projectedScrollDestination / scaleFactor), snapState.m_snapOffsets.first()), snapState.m_snapOffsets.last());
+    LayoutUnit clampedScrollDestination = std::min(std::max(originalProjectedScrollDestination, snapState.m_snapOffsets.first()), snapState.m_snapOffsets.last());
     snapState.m_initialOffset = offset;
     m_activeScrollSnapIndexDidChange = false;
-    snapState.m_targetOffset = scaleFactor * closestSnapOffset<LayoutUnit, float>(snapState.m_snapOffsets, projectedScrollDestination, initialWheelDelta, snapState.m_activeSnapIndex);
+    snapState.m_targetOffset = scaleFactor * closestSnapOffset<LayoutUnit, float>(snapState.m_snapOffsets, clampedScrollDestination, initialWheelDelta, snapState.m_activeSnapIndex);
     if (snapState.m_initialOffset == snapState.m_targetOffset)
         return;
+
+    LayoutUnit scrollExtent = (axis == ScrollEventAxis::Horizontal) ? m_client.scrollExtent().width() : m_client.scrollExtent().height();
+    LayoutUnit projectedScrollDestination = clampedScrollDestination;
+    if (originalProjectedScrollDestination < 0 || originalProjectedScrollDestination > scrollExtent)
+        projectedScrollDestination = originalProjectedScrollDestination;
     
     m_activeScrollSnapIndexDidChange = true;
     snapState.m_currentState = newState;

Modified: trunk/Source/WebKit2/ChangeLog (185680 => 185681)


--- trunk/Source/WebKit2/ChangeLog	2015-06-18 00:22:23 UTC (rev 185680)
+++ trunk/Source/WebKit2/ChangeLog	2015-06-18 00:32:33 UTC (rev 185681)
@@ -1,3 +1,18 @@
+2015-06-17  Brent Fulgham  <[email protected]>
+
+        Overflow regions with scroll snap points are not reliably rubber banding
+        https://bugs.webkit.org/show_bug.cgi?id=142522
+        <rdar://problem/20100726>
+
+        Reviewed by Darin Adler.
+
+        Make sure we don't block rubberbanding behavior when a scroll gesture should take us past
+        the end of the scroll container.
+
+        * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
+        (-[WKOverflowScrollViewDelegate scrollViewWillEndDragging:withVelocity:targetContentOffset:]): Don't adjust
+        target point if we were going to scroll past the edges of the scroll container.
+
 2015-06-17  Anders Carlsson  <[email protected]>
 
         Would like a way, in the API, to get notified about a web process crash

Modified: trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm (185680 => 185681)


--- trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm	2015-06-18 00:22:23 UTC (rev 185680)
+++ trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm	2015-06-18 00:32:33 UTC (rev 185681)
@@ -80,11 +80,14 @@
 #if ENABLE(CSS_SCROLL_SNAP)
 - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
 {
+    CGFloat horizontalTarget = targetContentOffset->x;
+    CGFloat verticalTarget = targetContentOffset->y;
+
     unsigned ignore;
-    if (!_scrollingTreeNode->horizontalSnapOffsets().isEmpty())
-        targetContentOffset->x = closestSnapOffset<float, CGFloat>(_scrollingTreeNode->horizontalSnapOffsets(), targetContentOffset->x, velocity.x, ignore);
-    if (!_scrollingTreeNode->verticalSnapOffsets().isEmpty())
-        targetContentOffset->y = closestSnapOffset<float, CGFloat>(_scrollingTreeNode->verticalSnapOffsets(), targetContentOffset->y, velocity.y, ignore);
+    if (!_scrollingTreeNode->horizontalSnapOffsets().isEmpty() && horizontalTarget >= 0 && horizontalTarget <= scrollView.contentSize.width)
+        targetContentOffset->x = closestSnapOffset<float, CGFloat>(_scrollingTreeNode->horizontalSnapOffsets(), horizontalTarget, velocity.x, ignore);
+    if (!_scrollingTreeNode->verticalSnapOffsets().isEmpty() && verticalTarget >= 0 && verticalTarget <= scrollView.contentSize.height)
+        targetContentOffset->y = closestSnapOffset<float, CGFloat>(_scrollingTreeNode->verticalSnapOffsets(), verticalTarget, velocity.y, ignore);
 }
 #endif
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to