Title: [187131] trunk/Source/WebKit2
Revision
187131
Author
za...@apple.com
Date
2015-07-21 15:35:57 -0700 (Tue, 21 Jul 2015)

Log Message

[iOS] Menu drop down such as on nike.com does not stay
https://bugs.webkit.org/show_bug.cgi?id=147047
rdar://problem/21046961

Reviewed by Benjamin Poulain.

This is a workaround for unintended scrolling while scaling.
(Based on Benjamin Poulain's WIP patch for webkit.org/b/136904)

In certain cases when scaling would result in moving the scrollview (which would trigger
a scroll event on WebCore side), zoomRect is called instead of setZoomScale to ensure
that the scroll position stays intact.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _didCommitLayerTree:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (187130 => 187131)


--- trunk/Source/WebKit2/ChangeLog	2015-07-21 22:34:27 UTC (rev 187130)
+++ trunk/Source/WebKit2/ChangeLog	2015-07-21 22:35:57 UTC (rev 187131)
@@ -1,3 +1,21 @@
+2015-07-21  Zalan Bujtas  <za...@apple.com>
+
+        [iOS] Menu drop down such as on nike.com does not stay
+        https://bugs.webkit.org/show_bug.cgi?id=147047
+        rdar://problem/21046961
+
+        Reviewed by Benjamin Poulain.
+
+        This is a workaround for unintended scrolling while scaling.
+        (Based on Benjamin Poulain's WIP patch for webkit.org/b/136904)
+
+        In certain cases when scaling would result in moving the scrollview (which would trigger
+        a scroll event on WebCore side), zoomRect is called instead of setZoomScale to ensure
+        that the scroll position stays intact.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _didCommitLayerTree:]):
+
 2015-07-21  Daniel Bates  <daba...@apple.com>
 
         WTFCrash() in WebKit::WebProcess::networkConnection()

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


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-07-21 22:34:27 UTC (rev 187130)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-07-21 22:35:57 UTC (rev 187131)
@@ -959,9 +959,23 @@
     [_scrollView setMinimumZoomScale:layerTreeTransaction.minimumScaleFactor()];
     [_scrollView setMaximumZoomScale:layerTreeTransaction.maximumScaleFactor()];
     [_scrollView setZoomEnabled:layerTreeTransaction.allowsUserScaling()];
-    if (!layerTreeTransaction.scaleWasSetByUIProcess() && ![_scrollView isZooming] && ![_scrollView isZoomBouncing] && ![_scrollView _isAnimatingZoom])
-        [_scrollView setZoomScale:layerTreeTransaction.pageScaleFactor()];
+    if (!layerTreeTransaction.scaleWasSetByUIProcess() && ![_scrollView isZooming] && ![_scrollView isZoomBouncing] && ![_scrollView _isAnimatingZoom]) {
+        float newPageScaleFactor = layerTreeTransaction.pageScaleFactor();
 
+        if (!areEssentiallyEqualAsFloat(contentZoomScale(self), newPageScaleFactor)) {
+            // FIXME: We need to handle stick to bottom.
+            WebCore::FloatRect oldUnobscuredContentRect = _page->unobscuredContentRect();
+            if (!oldUnobscuredContentRect.isEmpty() && oldUnobscuredContentRect.y() < 1) {
+                CGFloat relativeHorizontalPosition = oldUnobscuredContentRect.x() / oldUnobscuredContentRect.width();
+                CGPoint newTopLeft = [self _adjustedContentOffset: { relativeHorizontalPosition * newContentSize.width, 0 }];
+                CGSize scrollViewSize = [_scrollView bounds].size;
+                CGSize rectToZoomSize = CGSizeMake(scrollViewSize.width * newPageScaleFactor, scrollViewSize.height * newPageScaleFactor);
+                [_scrollView zoomToRect: { newTopLeft, rectToZoomSize } animated:NO];
+            } else
+                [_scrollView setZoomScale:newPageScaleFactor];
+        }
+    }
+
     [self _updateScrollViewBackground];
 
     if (_gestureController)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to