WKWebView scroll deceleration rate is not being set properly
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Sep 2015 02:42:39 +0000 (02:42 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Sep 2015 02:42:39 +0000 (02:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149145
<rdar://problem/22064071>

Reviewed by Simon Fraser.

We are not currently setting the web view's deceleration rate to the correct preferred value because we
are setting the decelerationRate property of the scrollView, which snaps input values to the closer of
two predefined UIKit constants, UIScrollViewDecelerationRateFast and UIScrollViewDecelerationRateNormal.
To fix this, we directly set the horizontal and vertical scroll deceleration factors to the preferred
value.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView scrollViewWillBeginDragging:]): Directly set the scroll view's deceleration factor without
        going through the decelerationRate property.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189773 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

index a4d388e699da33ddcb6c64a870eb1ed3f8a883cb..3e8ba61a32a8b928802a3d26f809043c05854c7d 100644 (file)
@@ -1,3 +1,21 @@
+2015-09-14  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        WKWebView scroll deceleration rate is not being set properly
+        https://bugs.webkit.org/show_bug.cgi?id=149145
+        <rdar://problem/22064071>
+
+        Reviewed by Simon Fraser.
+
+        We are not currently setting the web view's deceleration rate to the correct preferred value because we
+        are setting the decelerationRate property of the scrollView, which snaps input values to the closer of
+        two predefined UIKit constants, UIScrollViewDecelerationRateFast and UIScrollViewDecelerationRateNormal.
+        To fix this, we directly set the horizontal and vertical scroll deceleration factors to the preferred
+        value.
+
+        * UIProcess/API/Cocoa/WKWebView.mm: 
+        (-[WKWebView scrollViewWillBeginDragging:]): Directly set the scroll view's deceleration factor without
+                going through the decelerationRate property.
+
 2015-09-14  Dan Bernstein  <mitz@apple.com>
 
         Consolidate touch event code dealing with force.
index f07cd12e8a4c02a7dda49f65b00eeebe5d16457e..241515e56bcd9b948e535c63fbbe585cb64e5c42 100644 (file)
@@ -1480,7 +1480,9 @@ static WebCore::FloatPoint constrainContentOffset(WebCore::FloatPoint contentOff
     // FIXME: We will want to detect whether snapping will occur before beginning to drag. See WebPageProxy::didCommitLayerTree.
     WebKit::RemoteScrollingCoordinatorProxy* coordinator = _page->scrollingCoordinatorProxy();
     ASSERT(scrollView == _scrollView.get());
-    scrollView.decelerationRate = (coordinator && coordinator->shouldSetScrollViewDecelerationRateFast()) ? UIScrollViewDecelerationRateFast : [_scrollView preferredScrollDecelerationFactor];
+    CGFloat scrollDecelerationFactor = (coordinator && coordinator->shouldSetScrollViewDecelerationRateFast()) ? UIScrollViewDecelerationRateFast : [_scrollView preferredScrollDecelerationFactor];
+    scrollView.horizontalScrollDecelerationFactor = scrollDecelerationFactor;
+    scrollView.verticalScrollDecelerationFactor = scrollDecelerationFactor;
 #endif
 }