Title: [175827] trunk/Source/WebKit2
Revision
175827
Author
simon.fra...@apple.com
Date
2014-11-10 13:39:02 -0800 (Mon, 10 Nov 2014)

Log Message

[iOS WK2] Scroll deceleration rate is wrong
https://bugs.webkit.org/show_bug.cgi?id=138574
rdar://problem/18715303

Reviewed by Benjamin Poulain.

The CSS Snap Points code incorrectly set the WKScrollView's deceleration rate,
overriding the custom value that UIWebScrollView sets.

Fix by having WKScrollView store the custom rate at init time, and
using that value in -scrollViewWillBeginDragging:.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView scrollViewWillBeginDragging:]):
* UIProcess/ios/WKScrollView.h:
* UIProcess/ios/WKScrollView.mm:
(-[WKScrollView initWithFrame:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (175826 => 175827)


--- trunk/Source/WebKit2/ChangeLog	2014-11-10 20:43:50 UTC (rev 175826)
+++ trunk/Source/WebKit2/ChangeLog	2014-11-10 21:39:02 UTC (rev 175827)
@@ -1,3 +1,23 @@
+2014-11-10  Simon Fraser  <simon.fra...@apple.com>
+
+        [iOS WK2] Scroll deceleration rate is wrong
+        https://bugs.webkit.org/show_bug.cgi?id=138574
+        rdar://problem/18715303
+
+        Reviewed by Benjamin Poulain.
+        
+        The CSS Snap Points code incorrectly set the WKScrollView's deceleration rate,
+        overriding the custom value that UIWebScrollView sets.
+        
+        Fix by having WKScrollView store the custom rate at init time, and
+        using that value in -scrollViewWillBeginDragging:.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView scrollViewWillBeginDragging:]):
+        * UIProcess/ios/WKScrollView.h:
+        * UIProcess/ios/WKScrollView.mm:
+        (-[WKScrollView initWithFrame:]):
+
 2014-11-09  Ada Chan  <adac...@apple.com>
 
         Reset WebPageProxy's isPlayingAudio state after web process crash or page invalidation.

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (175826 => 175827)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2014-11-10 20:43:50 UTC (rev 175826)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2014-11-10 21:39:02 UTC (rev 175827)
@@ -1307,11 +1307,13 @@
 
     if (scrollView.panGestureRecognizer.state == UIGestureRecognizerStateBegan)
         [_contentView scrollViewWillStartPanOrPinchGesture];
+
     [_contentView willStartZoomOrScroll];
 #if ENABLE(CSS_SCROLL_SNAP) && ENABLE(ASYNC_SCROLLING)
     // FIXME: We will want to detect whether snapping will occur before beginning to drag. See WebPageProxy::didCommitLayerTree.
     WebKit::RemoteScrollingCoordinatorProxy* coordinator = _page->scrollingCoordinatorProxy();
-    scrollView.decelerationRate = (coordinator && coordinator->shouldSetScrollViewDecelerationRateFast()) ? UIScrollViewDecelerationRateFast : UIScrollViewDecelerationRateNormal;
+    ASSERT(scrollView == _scrollView.get());
+    scrollView.decelerationRate = (coordinator && coordinator->shouldSetScrollViewDecelerationRateFast()) ? UIScrollViewDecelerationRateFast : [_scrollView preferredScrollDecelerationFactor];;
 #endif
 }
 

Modified: trunk/Source/WebKit2/UIProcess/ios/WKScrollView.h (175826 => 175827)


--- trunk/Source/WebKit2/UIProcess/ios/WKScrollView.h	2014-11-10 20:43:50 UTC (rev 175826)
+++ trunk/Source/WebKit2/UIProcess/ios/WKScrollView.h	2014-11-10 21:39:02 UTC (rev 175827)
@@ -32,6 +32,7 @@
 @interface WKScrollView : UIWebScrollView
 
 @property (nonatomic, assign) WKWebView <UIScrollViewDelegate> *internalDelegate;
+@property (nonatomic, readonly) CGFloat preferredScrollDecelerationFactor;
 
 - (void)_setContentSizePreservingContentOffsetDuringRubberband:(CGSize)contentSize;
 

Modified: trunk/Source/WebKit2/UIProcess/ios/WKScrollView.mm (175826 => 175827)


--- trunk/Source/WebKit2/UIProcess/ios/WKScrollView.mm	2014-11-10 20:43:50 UTC (rev 175826)
+++ trunk/Source/WebKit2/UIProcess/ios/WKScrollView.mm	2014-11-10 21:39:02 UTC (rev 175827)
@@ -111,6 +111,17 @@
     WKScrollViewDelegateForwarder *_delegateForwarder;
 }
 
+- (id)initWithFrame:(CGRect)frame
+{
+    if (self = [super initWithFrame:frame]) {
+        ASSERT([self verticalScrollDecelerationFactor] == [self horizontalScrollDecelerationFactor]);
+        // FIXME: use UIWebPreferredScrollDecelerationFactor() from UIKit: rdar://problem/18931007.
+        _preferredScrollDecelerationFactor = [self verticalScrollDecelerationFactor];
+    }
+    
+    return self;
+}
+
 - (void)setInternalDelegate:(WKWebView <UIScrollViewDelegate> *)internalDelegate
 {
     if (internalDelegate == _internalDelegate)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to