Changeset 191309 in webkit


Ignore:
Timestamp:
Oct 19, 2015 12:53:45 PM (9 years ago)
Author:
Wenson Hsieh
Message:

Extend fast-clicking behavior to trigger on elements that have negligible zoom
https://bugs.webkit.org/show_bug.cgi?id=150248
<rdar://problem/23140069>

Reviewed by Simon Fraser.

Currently, fast-clicking only triggers on pages that have unscalable viewports. To allow more websites to benefit from fast-clicking
behavior, we generalize fast-clicking to also occur when tapping on elements for which double-tap-to-zoom would zoom the element in
or out by an insignificant amount. We define an insignificant amount of zoom to mean that zooming would increase the viewport scale
by less than a configurable threshold, or decrease the viewport scale by more than a configurable threshold. We accomplish this by
temporarily disabling the double tap gesture recognizer for the duration of the tap. This patch refactors some logic used to compute
zoomed viewports to make it possible to predict the change in viewport scale when double tapping to zoom. See the changes in
SmartMagnificationController and ViewGestureGeometryCollector for more details.

There are no new tests, since this patch does not change existing behavior. Instead, this patch adds the machinery needed for zoom-
dependent fast-clicking: by setting the preferences WebKitFastClickingEnabled and WebKitFastClickZoomThreshold, we will be able to tweak
the behavior dynamically.

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _didCommitLayerTree:]):
(-[WKWebView _contentZoomScale]):
(-[WKWebView _targetContentZoomScaleForRect:currentScale:fitEntireRect:minimumScale:maximumScale:]):
(-[WKWebView _zoomToRect:withOrigin:fitEntireRect:minimumScale:maximumScale:minimumScrollDistance:]):
(-[WKWebView _viewportIsUserScalable]):

  • UIProcess/API/Cocoa/WKWebViewInternal.h:
  • UIProcess/API/Cocoa/WKWebViewPrivate.h:
  • UIProcess/PageClient.h:
  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • UIProcess/ios/PageClientImplIOS.h:
  • UIProcess/ios/PageClientImplIOS.mm:

(WebKit::PageClientImpl::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary):

  • UIProcess/ios/SmartMagnificationController.h:
  • UIProcess/ios/SmartMagnificationController.mm:

(WebKit::SmartMagnificationController::adjustSmartMagnificationTargetRectAndZoomScales):
(WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture):
(WebKit::SmartMagnificationController::magnify):

  • UIProcess/ios/WKContentViewInteraction.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _didGetTapHighlightForRequest:color:quads:topLeftRadius:topRightRadius:bottomLeftRadius:bottomRightRadius:]):
(-[WKContentView _fastClickZoomThreshold]):
(-[WKContentView _allowDoubleTapToZoomForCurrentZoomScale:andTargetZoomScale:]):
(-[WKContentView _disableDoubleTapGesturesUntilTapIsFinishedIfNecessary:allowsDoubleTapZoom:targetRect:isReplaced:minimumScale:maximumScale:]):
(-[WKContentView _highlightLongPressRecognized:]):
(-[WKContentView _endPotentialTapAndEnableDoubleTapGesturesIfNecessary]):
(-[WKContentView _singleTapRecognized:]):
(cancelPotentialTapIfNecessary):
(-[WKContentView _singleTapCommited:]):
(-[WKContentView webSelectionRects]): Deleted.

  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::WebPageProxy::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary):

  • WebProcess/WebPage/ViewGestureGeometryCollector.cpp:

(WebKit::ViewGestureGeometryCollector::collectGeometryForSmartMagnificationGesture):
(WebKit::ViewGestureGeometryCollector::computeZoomInformationForNode):

  • WebProcess/WebPage/ViewGestureGeometryCollector.h:
  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::potentialTapAtPosition):

Location:
trunk/Source/WebKit2
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r191307 r191309  
     12015-10-17  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Extend fast-clicking behavior to trigger on elements that have negligible zoom
     4        https://bugs.webkit.org/show_bug.cgi?id=150248
     5        <rdar://problem/23140069>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Currently, fast-clicking only triggers on pages that have unscalable viewports. To allow more websites to benefit from fast-clicking
     10        behavior, we generalize fast-clicking to also occur when tapping on elements for which double-tap-to-zoom would zoom the element in
     11        or out by an insignificant amount. We define an insignificant amount of zoom to mean that zooming would increase the viewport scale
     12        by less than a configurable threshold, or decrease the viewport scale by more than a configurable threshold. We accomplish this by
     13        temporarily disabling the double tap gesture recognizer for the duration of the tap. This patch refactors some logic used to compute
     14        zoomed viewports to make it possible to predict the change in viewport scale when double tapping to zoom. See the changes in
     15        SmartMagnificationController and ViewGestureGeometryCollector for more details.
     16
     17        There are no new tests, since this patch does not change existing behavior. Instead, this patch adds the machinery needed for zoom-
     18        dependent fast-clicking: by setting the preferences WebKitFastClickingEnabled and WebKitFastClickZoomThreshold, we will be able to tweak
     19        the behavior dynamically.
     20
     21        * UIProcess/API/Cocoa/WKWebView.mm:
     22        (-[WKWebView _didCommitLayerTree:]):
     23        (-[WKWebView _contentZoomScale]):
     24        (-[WKWebView _targetContentZoomScaleForRect:currentScale:fitEntireRect:minimumScale:maximumScale:]):
     25        (-[WKWebView _zoomToRect:withOrigin:fitEntireRect:minimumScale:maximumScale:minimumScrollDistance:]):
     26        (-[WKWebView _viewportIsUserScalable]):
     27        * UIProcess/API/Cocoa/WKWebViewInternal.h:
     28        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
     29        * UIProcess/PageClient.h:
     30        * UIProcess/WebPageProxy.h:
     31        * UIProcess/WebPageProxy.messages.in:
     32        * UIProcess/ios/PageClientImplIOS.h:
     33        * UIProcess/ios/PageClientImplIOS.mm:
     34        (WebKit::PageClientImpl::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary):
     35        * UIProcess/ios/SmartMagnificationController.h:
     36        * UIProcess/ios/SmartMagnificationController.mm:
     37        (WebKit::SmartMagnificationController::adjustSmartMagnificationTargetRectAndZoomScales):
     38        (WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture):
     39        (WebKit::SmartMagnificationController::magnify):
     40        * UIProcess/ios/WKContentViewInteraction.h:
     41        * UIProcess/ios/WKContentViewInteraction.mm:
     42        (-[WKContentView _didGetTapHighlightForRequest:color:quads:topLeftRadius:topRightRadius:bottomLeftRadius:bottomRightRadius:]):
     43        (-[WKContentView _fastClickZoomThreshold]):
     44        (-[WKContentView _allowDoubleTapToZoomForCurrentZoomScale:andTargetZoomScale:]):
     45        (-[WKContentView _disableDoubleTapGesturesUntilTapIsFinishedIfNecessary:allowsDoubleTapZoom:targetRect:isReplaced:minimumScale:maximumScale:]):
     46        (-[WKContentView _highlightLongPressRecognized:]):
     47        (-[WKContentView _endPotentialTapAndEnableDoubleTapGesturesIfNecessary]):
     48        (-[WKContentView _singleTapRecognized:]):
     49        (cancelPotentialTapIfNecessary):
     50        (-[WKContentView _singleTapCommited:]):
     51        (-[WKContentView webSelectionRects]): Deleted.
     52        * UIProcess/ios/WebPageProxyIOS.mm:
     53        (WebKit::WebPageProxy::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary):
     54        * WebProcess/WebPage/ViewGestureGeometryCollector.cpp:
     55        (WebKit::ViewGestureGeometryCollector::collectGeometryForSmartMagnificationGesture):
     56        (WebKit::ViewGestureGeometryCollector::computeZoomInformationForNode):
     57        * WebProcess/WebPage/ViewGestureGeometryCollector.h:
     58        * WebProcess/WebPage/ios/WebPageIOS.mm:
     59        (WebKit::WebPage::potentialTapAtPosition):
     60
    1612015-10-19  Tim Horton  <timothy_horton@apple.com>
    262
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r191228 r191309  
    998998        [_scrollView setZoomScale:layerTreeTransaction.pageScaleFactor()];
    999999
    1000     [_contentView _setDoubleTapGesturesEnabled:[_scrollView isZoomEnabled] && [_scrollView minimumZoomScale] < [_scrollView maximumZoomScale]];
     1000    [_contentView _setDoubleTapGesturesEnabled:self._viewportIsUserScalable];
    10011001
    10021002    [self _updateScrollViewBackground];
     
    13961396}
    13971397
    1398 - (BOOL)_zoomToRect:(WebCore::FloatRect)targetRect withOrigin:(WebCore::FloatPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(float)minimumScrollDistance
    1399 {
    1400     const float maximumScaleFactorDeltaForPanScroll = 0.02;
    1401 
    1402     double currentScale = contentZoomScale(self);
    1403 
     1398- (CGFloat)_contentZoomScale
     1399{
     1400    return contentZoomScale(self);
     1401}
     1402
     1403- (CGFloat)_targetContentZoomScaleForRect:(const WebCore::FloatRect&)targetRect currentScale:(double)currentScale fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale
     1404{
    14041405    WebCore::FloatSize unobscuredContentSize([self _contentRectForUserInteraction].size);
    14051406    double horizontalScale = unobscuredContentSize.width() * currentScale / targetRect.width();
     
    14091410    verticalScale = std::min(std::max(verticalScale, minimumScale), maximumScale);
    14101411
    1411     double targetScale = fitEntireRect ? std::min(horizontalScale, verticalScale) : horizontalScale;
     1412    return fitEntireRect ? std::min(horizontalScale, verticalScale) : horizontalScale;
     1413}
     1414
     1415- (BOOL)_zoomToRect:(WebCore::FloatRect)targetRect withOrigin:(WebCore::FloatPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(float)minimumScrollDistance
     1416{
     1417    const float maximumScaleFactorDeltaForPanScroll = 0.02;
     1418
     1419    double currentScale = contentZoomScale(self);
     1420    double targetScale = [self _targetContentZoomScaleForRect:targetRect currentScale:currentScale fitEntireRect:fitEntireRect minimumScale:minimumScale maximumScale:maximumScale];
     1421
    14121422    if (fabs(targetScale - currentScale) < maximumScaleFactorDeltaForPanScroll) {
    14131423        if ([self _scrollToRect:targetRect origin:origin minimumScrollDistance:minimumScrollDistance])
     
    30673077}
    30683078
     3079- (BOOL)_viewportIsUserScalable
     3080{
     3081    return [_scrollView isZoomEnabled] && [_scrollView minimumZoomScale] < [_scrollView maximumZoomScale];
     3082}
     3083
    30693084- (_WKWebViewPrintFormatter *)_webViewPrintFormatter
    30703085{
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h

    r191183 r191309  
    110110- (void)_navigationGestureDidEnd;
    111111
     112- (CGFloat)_contentZoomScale;
     113- (CGFloat)_targetContentZoomScaleForRect:(const WebCore::FloatRect&)targetRect currentScale:(double)currentScale fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale;
     114
    112115@property (nonatomic, readonly) UIEdgeInsets _computedContentInset;
    113116#else
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h

    r191228 r191309  
    136136// The viewport meta tag width is negative if the value is not defined.
    137137@property (nonatomic, readonly) CGFloat _viewportMetaTagWidth;
     138@property (nonatomic, readonly) BOOL _viewportIsUserScalable;
    138139
    139140@property (nonatomic, readonly) _WKWebViewPrintFormatter *_webViewPrintFormatter;
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r191299 r191309  
    295295    virtual void zoomToRect(WebCore::FloatRect, double minimumScale, double maximumScale) = 0;
    296296    virtual void didChangeViewportMetaTagWidth(float) = 0;
     297    virtual void disableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, const WebCore::FloatRect& targetRect, bool isReplacedElement, double minimumScale, double maximumScale) = 0;
    297298    virtual double minimumZoomScale() const = 0;
    298299    virtual WebCore::FloatRect documentRect() const = 0;
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r191299 r191309  
    510510    void didNotHandleTapAsClick(const WebCore::IntPoint&);
    511511    void viewportMetaTagWidthDidChange(float width);
     512    void disableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, const WebCore::FloatRect& targetRect, bool isReplacedElement, double minimumScale, double maximumScale);
    512513    void didFinishDrawingPagesToPDF(const IPC::DataReference&);
    513514    void contentSizeCategoryDidChange(const String& contentSizeCategory);
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r191181 r191309  
    189189    DidNotHandleTapAsClick(WebCore::IntPoint point)
    190190    ViewportMetaTagWidthDidChange(float width)
     191    DisableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, WebCore::FloatRect targetRect, bool isReplacedElement, double minimumScale, double maximumScale)
    191192    DidFinishDrawingPagesToPDF(IPC::DataReference pdfData)
    192193#endif
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h

    r191146 r191309  
    135135    virtual bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPanelParameters*, WebOpenPanelResultListenerProxy*) override;
    136136    virtual void didChangeViewportMetaTagWidth(float) override;
     137    virtual void disableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, const WebCore::FloatRect& targetRect, bool isReplacedElement, double minimumScale, double maximumScale) override;
    137138    virtual double minimumZoomScale() const override;
    138139    virtual WebCore::FloatRect documentRect() const override;
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm

    r191146 r191309  
    260260}
    261261
     262void PageClientImpl::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, const WebCore::FloatRect& targetRect, bool isReplacedElement, double minimumScale, double maximumScale)
     263{
     264    if (!m_webView._viewportIsUserScalable)
     265        return;
     266
     267    [m_contentView _disableDoubleTapGesturesUntilTapIsFinishedIfNecessary:requestID allowsDoubleTapZoom:allowsDoubleTapZoom targetRect:targetRect isReplaced:isReplacedElement minimumScale:minimumScale maximumScale:maximumScale];
     268}
     269
    262270double PageClientImpl::minimumZoomScale() const
    263271{
  • trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.h

    r184149 r191309  
    4949    void handleSmartMagnificationGesture(WebCore::FloatPoint origin);
    5050    void handleResetMagnificationGesture(WebCore::FloatPoint origin);
     51    void adjustSmartMagnificationTargetRectAndZoomScales(bool addMagnificationPadding, WebCore::FloatRect& targetRect, double& minimumScale, double& maximumScale);
    5152
    5253private:
  • trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.mm

    r184149 r191309  
    7979}
    8080
     81void SmartMagnificationController::adjustSmartMagnificationTargetRectAndZoomScales(bool addMagnificationPadding, WebCore::FloatRect& targetRect, double& minimumScale, double& maximumScale)
     82{
     83    if (addMagnificationPadding) {
     84        targetRect.inflateX(smartMagnificationElementPadding * targetRect.width());
     85        targetRect.inflateY(smartMagnificationElementPadding * targetRect.height());
     86    }
     87
     88    minimumScale = std::max(minimumScale, smartMagnificationMinimumScale);
     89    maximumScale = std::min(maximumScale, smartMagnificationMaximumScale);
     90}
     91
    8192void SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture(FloatPoint origin, FloatRect targetRect, FloatRect visibleContentRect, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale)
    8293{
     
    8697        return;
    8798    }
    88 
    89     if (!isReplacedElement) {
    90         targetRect.inflateX(smartMagnificationElementPadding * targetRect.width());
    91         targetRect.inflateY(smartMagnificationElementPadding * targetRect.height());
    92     }
    93 
    94     double maximumScale = std::min(viewportMaximumScale, smartMagnificationMaximumScale);
    95     double minimumScale = std::max(viewportMinimumScale, smartMagnificationMinimumScale);
     99    double minimumScale = viewportMinimumScale;
     100    double maximumScale = viewportMaximumScale;
     101    adjustSmartMagnificationTargetRectAndZoomScales(!isReplacedElement, targetRect, minimumScale, maximumScale);
    96102
    97103    // FIXME: Check if text selection wants to consume the double tap before we attempt magnification.
     
    119125void SmartMagnificationController::magnify(FloatPoint origin, FloatRect targetRect, FloatRect visibleContentRect, double viewportMinimumScale, double viewportMaximumScale)
    120126{
    121     targetRect.inflateX(smartMagnificationElementPadding * targetRect.width());
    122     targetRect.inflateY(smartMagnificationElementPadding * targetRect.height());
    123 
    124     double maximumScale = std::min(viewportMaximumScale, smartMagnificationMaximumScale);
    125     double minimumScale = std::max(viewportMinimumScale, smartMagnificationMinimumScale);
    126 
     127    double maximumScale = viewportMaximumScale;
     128    double minimumScale = viewportMinimumScale;
     129    adjustSmartMagnificationTargetRectAndZoomScales(true, targetRect, minimumScale, maximumScale);
    127130    [m_contentView _zoomToRect:targetRect withOrigin:origin fitEntireRect:NO minimumScale:minimumScale maximumScale:maximumScale minimumScrollDistance:0];
    128131}
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h

    r191072 r191309  
    127127    id <UITextInputDelegate> _inputDelegate;
    128128
    129     uint64_t _latestTapHighlightID;
     129    uint64_t _latestTapID;
    130130    struct TapHighlightInformation {
    131131        WebCore::Color color;
     
    183183- (void)_didGetTapHighlightForRequest:(uint64_t)requestID color:(const WebCore::Color&)color quads:(const Vector<WebCore::FloatQuad>&)highlightedQuads topLeftRadius:(const WebCore::IntSize&)topLeftRadius topRightRadius:(const WebCore::IntSize&)topRightRadius bottomLeftRadius:(const WebCore::IntSize&)bottomLeftRadius bottomRightRadius:(const WebCore::IntSize&)bottomRightRadius;
    184184
     185- (void)_disableDoubleTapGesturesUntilTapIsFinishedIfNecessary:(uint64_t)requestID allowsDoubleTapZoom:(bool)allowsDoubleTapZoom targetRect:(WebCore::FloatRect)targetRect isReplaced:(BOOL)isReplacedElement minimumScale:(double)minimumScale maximumScale:(double)maximumScale;
    185186- (void)_startAssistingNode:(const WebKit::AssistedNodeInformation&)information userIsInteracting:(BOOL)userIsInteracting blurPreviousNode:(BOOL)blurPreviousNode userObject:(NSObject <NSSecureCoding> *)userObject;
    186187- (void)_stopAssistingNode;
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r191228 r191309  
    832832- (void)_didGetTapHighlightForRequest:(uint64_t)requestID color:(const WebCore::Color&)color quads:(const Vector<WebCore::FloatQuad>&)highlightedQuads topLeftRadius:(const WebCore::IntSize&)topLeftRadius topRightRadius:(const WebCore::IntSize&)topRightRadius bottomLeftRadius:(const WebCore::IntSize&)bottomLeftRadius bottomRightRadius:(const WebCore::IntSize&)bottomRightRadius
    833833{
    834     if (!_isTapHighlightIDValid || _latestTapHighlightID != requestID)
     834    if (!_isTapHighlightIDValid || _latestTapID != requestID)
    835835        return;
    836836
     
    850850
    851851    [self _showTapHighlight];
     852}
     853
     854- (CGFloat)_fastClickZoomThreshold
     855{
     856    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
     857    if (![defaults boolForKey:@"WebKitFastClickingEnabled"])
     858        return 0;
     859
     860    return [defaults floatForKey:@"WebKitFastClickZoomThreshold"];
     861}
     862
     863- (BOOL)_allowDoubleTapToZoomForCurrentZoomScale:(CGFloat)currentZoomScale andTargetZoomScale:(CGFloat)targetZoomScale
     864{
     865    CGFloat zoomThreshold = [self _fastClickZoomThreshold];
     866    if (!zoomThreshold)
     867        return YES;
     868
     869    CGFloat minimumZoomRatioForDoubleTapToZoomIn = 1 + zoomThreshold;
     870    CGFloat maximumZoomRatioForDoubleTapToZoomOut = 1 / minimumZoomRatioForDoubleTapToZoomIn;
     871    CGFloat zoomRatio = targetZoomScale / currentZoomScale;
     872    return zoomRatio < maximumZoomRatioForDoubleTapToZoomOut || zoomRatio > minimumZoomRatioForDoubleTapToZoomIn;
     873}
     874
     875- (void)_disableDoubleTapGesturesUntilTapIsFinishedIfNecessary:(uint64_t)requestID allowsDoubleTapZoom:(bool)allowsDoubleTapZoom targetRect:(WebCore::FloatRect)targetRect isReplaced:(BOOL)isReplacedElement minimumScale:(double)minimumScale maximumScale:(double)maximumScale
     876{
     877    if (!_potentialTapInProgress || _latestTapID != requestID)
     878        return;
     879
     880    if (allowsDoubleTapZoom) {
     881        // Though the element allows us to zoom in on double tap, we avoid this behavior in favor of fast clicking if the difference in scale is insignificant.
     882        _smartMagnificationController->adjustSmartMagnificationTargetRectAndZoomScales(!isReplacedElement, targetRect, minimumScale, maximumScale);
     883        CGFloat currentZoomScale = [_webView _contentZoomScale];
     884        CGFloat targetZoomScale = [_webView _targetContentZoomScaleForRect:targetRect currentScale:currentZoomScale fitEntireRect:isReplacedElement minimumScale:minimumScale maximumScale:maximumScale];
     885        if ([self _allowDoubleTapToZoomForCurrentZoomScale:currentZoomScale andTargetZoomScale:targetZoomScale])
     886            return;
     887    }
     888
     889    [self _setDoubleTapGesturesEnabled:NO];
    852890}
    853891
     
    11561194        _highlightLongPressCanClick = YES;
    11571195        cancelPotentialTapIfNecessary(self);
    1158         _page->tapHighlightAtPosition([gestureRecognizer startPoint], ++_latestTapHighlightID);
     1196        _page->tapHighlightAtPosition([gestureRecognizer startPoint], ++_latestTapID);
    11591197        _isTapHighlightIDValid = YES;
    11601198        break;
     
    11911229}
    11921230
     1231- (void)_endPotentialTapAndEnableDoubleTapGesturesIfNecessary
     1232{
     1233    if (_webView._viewportIsUserScalable)
     1234        [self _setDoubleTapGesturesEnabled:YES];
     1235
     1236    _potentialTapInProgress = NO;
     1237}
     1238
    11931239- (void)_singleTapRecognized:(UITapGestureRecognizer *)gestureRecognizer
    11941240{
     
    11961242    ASSERT(!_potentialTapInProgress);
    11971243
    1198     _page->potentialTapAtPosition(gestureRecognizer.location, ++_latestTapHighlightID);
     1244    _page->potentialTapAtPosition(gestureRecognizer.location, ++_latestTapID);
    11991245    _potentialTapInProgress = YES;
    12001246    _isTapHighlightIDValid = YES;
     
    12041250{
    12051251    if (contentView->_potentialTapInProgress) {
    1206         contentView->_potentialTapInProgress = NO;
     1252        [contentView _endPotentialTapAndEnableDoubleTapGesturesIfNecessary];
    12071253        [contentView _cancelInteraction];
    12081254        contentView->_page->cancelPotentialTap();
     
    12431289    _lastInteractionLocation = gestureRecognizer.location;
    12441290
    1245     _potentialTapInProgress = NO;
     1291    [self _endPotentialTapAndEnableDoubleTapGesturesIfNecessary];
    12461292
    12471293    if (_hasTapHighlightForPotentialTap) {
  • trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm

    r190604 r191309  
    938938}
    939939
     940void WebPageProxy::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, const WebCore::FloatRect& targetRect, bool isReplacedElement, double minimumScale, double maximumScale)
     941{
     942    m_pageClient.disableDoubleTapGesturesUntilTapIsFinishedIfNecessary(requestID, allowsDoubleTapZoom, targetRect, isReplacedElement, minimumScale, maximumScale);
     943}
     944
    940945void WebPageProxy::didFinishDrawingPagesToPDF(const IPC::DataReference& pdfData)
    941946{
  • trunk/Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.cpp

    r179409 r191309  
    8787
    8888    m_webPage.mainFrameView()->renderView()->hitTest(HitTestRequest(), hitTestResult);
    89 
    90     if (Node* node = hitTestResult.innerNode()) {
    91         bool isReplaced;
    92         FloatRect renderRect = node->renderRect(&isReplaced);
    93 
    94         if (node->document().isImageDocument()) {
    95             if (HTMLImageElement* imageElement = static_cast<ImageDocument&>(node->document()).imageElement()) {
    96                 if (node != imageElement) {
    97                     renderRect = imageElement->renderRect(&isReplaced);
    98                     FloatPoint newOrigin = origin;
    99                     if (origin.x() < renderRect.x() || origin.x() > renderRect.maxX())
    100                         newOrigin.setX(renderRect.x() + renderRect.width() / 2);
    101                     if (origin.y() < renderRect.y() || origin.y() > renderRect.maxY())
    102                         newOrigin.setY(renderRect.y() + renderRect.height() / 2);
    103                     origin = newOrigin;
    104                 }
    105                 isReplaced = true;
    106             }
    107         }
    108 
    109 #if PLATFORM(MAC)
    110         double viewportMinimumScale = 0;
    111         double viewportMaximumScale = std::numeric_limits<double>::max();
    112 #else
    113         double viewportMinimumScale = m_webPage.minimumPageScaleFactor();
    114         double viewportMaximumScale = m_webPage.maximumPageScaleFactor();
    115 #endif
    116 
    117         dispatchDidCollectGeometryForSmartMagnificationGesture(origin, renderRect, visibleContentRect, isReplaced, viewportMinimumScale, viewportMaximumScale);
     89    Node* node = hitTestResult.innerNode();
     90    if (!node) {
     91        dispatchDidCollectGeometryForSmartMagnificationGesture(FloatPoint(), FloatRect(), FloatRect(), false, 0, 0);
    11892        return;
    11993    }
    12094
    121     dispatchDidCollectGeometryForSmartMagnificationGesture(FloatPoint(), FloatRect(), FloatRect(), false, 0, 0);
     95    bool isReplaced;
     96    FloatRect renderRect;
     97    double viewportMinimumScale;
     98    double viewportMaximumScale;
     99
     100    computeZoomInformationForNode(*node, origin, renderRect, isReplaced, viewportMinimumScale, viewportMaximumScale);
     101    dispatchDidCollectGeometryForSmartMagnificationGesture(origin, renderRect, visibleContentRect, isReplaced, viewportMinimumScale, viewportMaximumScale);
     102}
     103
     104void ViewGestureGeometryCollector::computeZoomInformationForNode(Node& node, FloatPoint& origin, FloatRect& renderRect, bool& isReplaced, double& viewportMinimumScale, double& viewportMaximumScale)
     105{
     106    renderRect = node.renderRect(&isReplaced);
     107    if (node.document().isImageDocument()) {
     108        if (HTMLImageElement* imageElement = static_cast<ImageDocument&>(node.document()).imageElement()) {
     109            if (&node != imageElement) {
     110                renderRect = imageElement->renderRect(&isReplaced);
     111                FloatPoint newOrigin = origin;
     112                if (origin.x() < renderRect.x() || origin.x() > renderRect.maxX())
     113                    newOrigin.setX(renderRect.x() + renderRect.width() / 2);
     114                if (origin.y() < renderRect.y() || origin.y() > renderRect.maxY())
     115                    newOrigin.setY(renderRect.y() + renderRect.height() / 2);
     116                origin = newOrigin;
     117            }
     118            isReplaced = true;
     119        }
     120    }
     121#if PLATFORM(MAC)
     122    viewportMinimumScale = 0;
     123    viewportMaximumScale = std::numeric_limits<double>::max();
     124#else
     125    viewportMinimumScale = m_webPage.minimumPageScaleFactor();
     126    viewportMaximumScale = m_webPage.maximumPageScaleFactor();
     127#endif
    122128}
    123129
  • trunk/Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.h

    r177917 r191309  
    3333class FloatPoint;
    3434class FloatRect;
     35class Node;
    3536}
    3637
     
    4546
    4647    void mainFrameDidLayout();
     48    void computeZoomInformationForNode(WebCore::Node&, WebCore::FloatPoint& origin, WebCore::FloatRect& renderRect, bool& isReplaced, double& viewportMinimumScale, double& viewportMaximumScale);
    4749
    4850private:
  • trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

    r191049 r191309  
    663663    m_potentialTapNode = m_page->mainFrame().nodeRespondingToClickEvents(position, m_potentialTapLocation);
    664664    sendTapHighlightForNodeIfNecessary(requestID, m_potentialTapNode.get());
     665    if (m_potentialTapNode) {
     666        FloatPoint origin = position;
     667        FloatRect renderRect;
     668        bool isReplaced;
     669        double viewportMinimumScale;
     670        double viewportMaximumScale;
     671
     672        m_viewGestureGeometryCollector.computeZoomInformationForNode(*m_potentialTapNode.get(), origin, renderRect, isReplaced, viewportMinimumScale, viewportMaximumScale);
     673        send(Messages::WebPageProxy::DisableDoubleTapGesturesUntilTapIsFinishedIfNecessary(requestID, true, renderRect, isReplaced, viewportMinimumScale, viewportMaximumScale));
     674    }
    665675}
    666676
Note: See TracChangeset for help on using the changeset viewer.