⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 187131 in webkit


Ignore:
Timestamp:
Jul 21, 2015, 3:35:57 PM (11 years ago)
Author:
Alan Bujtas
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:]):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r187129 r187131  
     12015-07-21  Zalan Bujtas  <zalan@apple.com>
     2
     3        [iOS] Menu drop down such as on nike.com does not stay
     4        https://bugs.webkit.org/show_bug.cgi?id=147047
     5        rdar://problem/21046961
     6
     7        Reviewed by Benjamin Poulain.
     8
     9        This is a workaround for unintended scrolling while scaling.
     10        (Based on Benjamin Poulain's WIP patch for webkit.org/b/136904)
     11
     12        In certain cases when scaling would result in moving the scrollview (which would trigger
     13        a scroll event on WebCore side), zoomRect is called instead of setZoomScale to ensure
     14        that the scroll position stays intact.
     15
     16        * UIProcess/API/Cocoa/WKWebView.mm:
     17        (-[WKWebView _didCommitLayerTree:]):
     18
    1192015-07-21  Daniel Bates  <dabates@apple.com>
    220
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r186778 r187131  
    960960    [_scrollView setMaximumZoomScale:layerTreeTransaction.maximumScaleFactor()];
    961961    [_scrollView setZoomEnabled:layerTreeTransaction.allowsUserScaling()];
    962     if (!layerTreeTransaction.scaleWasSetByUIProcess() && ![_scrollView isZooming] && ![_scrollView isZoomBouncing] && ![_scrollView _isAnimatingZoom])
    963         [_scrollView setZoomScale:layerTreeTransaction.pageScaleFactor()];
     962    if (!layerTreeTransaction.scaleWasSetByUIProcess() && ![_scrollView isZooming] && ![_scrollView isZoomBouncing] && ![_scrollView _isAnimatingZoom]) {
     963        float newPageScaleFactor = layerTreeTransaction.pageScaleFactor();
     964
     965        if (!areEssentiallyEqualAsFloat(contentZoomScale(self), newPageScaleFactor)) {
     966            // FIXME: We need to handle stick to bottom.
     967            WebCore::FloatRect oldUnobscuredContentRect = _page->unobscuredContentRect();
     968            if (!oldUnobscuredContentRect.isEmpty() && oldUnobscuredContentRect.y() < 1) {
     969                CGFloat relativeHorizontalPosition = oldUnobscuredContentRect.x() / oldUnobscuredContentRect.width();
     970                CGPoint newTopLeft = [self _adjustedContentOffset: { relativeHorizontalPosition * newContentSize.width, 0 }];
     971                CGSize scrollViewSize = [_scrollView bounds].size;
     972                CGSize rectToZoomSize = CGSizeMake(scrollViewSize.width * newPageScaleFactor, scrollViewSize.height * newPageScaleFactor);
     973                [_scrollView zoomToRect: { newTopLeft, rectToZoomSize } animated:NO];
     974            } else
     975                [_scrollView setZoomScale:newPageScaleFactor];
     976        }
     977    }
    964978
    965979    [self _updateScrollViewBackground];
Note: See TracChangeset for help on using the changeset viewer.