Changeset 191644 in webkit


Ignore:
Timestamp:
Oct 27, 2015 4:34:54 PM (8 years ago)
Author:
Wenson Hsieh
Message:

Implement viewport-width-based fast-click heuristic
https://bugs.webkit.org/show_bug.cgi?id=150604
<rdar://problem/23267308>

Reviewed by Simon Fraser.

Source/WebKit2:

Implement a new fast-click heuristic that applies to viewports with width = device-width. The basic rules are
as follows: when a page has viewport width = device-width and is at initial zoom scale, we disable double-tapping
in favor of fast-clicking. However, if the viewport scale is not the initial scale, we allow double tapping. For
fast-clicking to remain useful after the user pinch-zooms, we change our double-tap to zoom out behavior to zoom
to the initial scale rather than the minimum scale. For unscalable viewports, we default to fast-clicking behavior,
and for all other viewports not at device-width, we double-tap to zoom and scroll as normal.

This patch removes some logic previously used for our scroll- and zoom-based fast-clicking heuristic, and adds
information about the viewport width and initial scale to RemoteLayerTreeTransactions. This information is then
used by the UI process to determine whether double tapping should be disabled or enabled.

The fast-click heuristic can be turned off through user default preferences, and a tap highlight for debugging
fast-clicking can also be enabled through a user default preference. A red highlight indicates that a single-
tap was slow, whereas a green highlight indicates a fast single-tap.

  • Shared/mac/RemoteLayerTreeTransaction.h:

(WebKit::RemoteLayerTreeTransaction::initialScaleFactor):
(WebKit::RemoteLayerTreeTransaction::setInitialScaleFactor):
(WebKit::RemoteLayerTreeTransaction::viewportMetaTagWidth):
(WebKit::RemoteLayerTreeTransaction::setViewportMetaTagWidth):

  • Shared/mac/RemoteLayerTreeTransaction.mm:

(WebKit::RemoteLayerTreeTransaction::encode):
(WebKit::RemoteLayerTreeTransaction::decode):

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView initWithFrame:configuration:]):
(-[WKWebView _processDidExit]):
(-[WKWebView _didCommitLayerTree:]):
(-[WKWebView _zoomToInitialScaleWithOrigin:animated:]):
(-[WKWebView _allowsDoubleTapGestures]):
(-[WKWebView _setViewportMetaTagWidth:]): Deleted.
(-[WKWebView _contentZoomScale]): Deleted.
(-[WKWebView _viewportMetaTagWidth]): Deleted.
(-[WKWebView _viewportIsUserScalable]): Deleted.

  • 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::disableDoubleTapGesturesDuringTapIfNecessary):
(WebKit::PageClientImpl::didChangeViewportMetaTagWidth): Deleted.
(WebKit::PageClientImpl::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary): Deleted.

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

(WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture):

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

(-[WKContentView _zoomToInitialScaleWithOrigin:]):

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

(-[WKContentView setupInteraction]):
(-[WKContentView _showTapHighlight]):
(-[WKContentView _didGetTapHighlightForRequest:color:quads:topLeftRadius:topRightRadius:bottomLeftRadius:bottomRightRadius:]):
(-[WKContentView _mayDisableDoubleTapGesturesDuringSingleTap]):
(-[WKContentView _disableDoubleTapGesturesDuringTapIfNecessary:]):
(-[WKContentView _finishInteraction]):
(-[WKContentView _endPotentialTapAndEnableDoubleTapGesturesIfNecessary]):
(-[WKContentView _tapHighlightColorForFastClick:]):
(-[WKContentView _setDoubleTapGesturesEnabled:]):
(-[WKContentView _fastClickZoomThreshold]): Deleted.
(-[WKContentView _allowDoubleTapToZoomForCurrentZoomScale:andTargetZoomScale:]): Deleted.
(-[WKContentView _disableDoubleTapGesturesUntilTapIsFinishedIfNecessary:allowsDoubleTapZoom:targetRect:isReplaced:minimumScale:maximumScale:]): Deleted.

  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::WebPageProxy::disableDoubleTapGesturesDuringTapIfNecessary):
(WebKit::WebPageProxy::viewportMetaTagWidthDidChange): Deleted.
(WebKit::WebPageProxy::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary): Deleted.

  • WebProcess/WebPage/ViewGestureGeometryCollector.h:
  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::willCommitLayerTree):

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::potentialTapAtPosition):
(WebKit::WebPage::viewportPropertiesDidChange): Deleted.

LayoutTests:

Implement a new fast-click heuristic that applies to viewports with width = device-width. Adds
new tests to check various fast-clicking behaviors. These three tests check (for pages with width=
device-width) that:

  • Double-tapping to zoom still works when the scale is not the initial scale.
  • If the page is at initial scale, we fire fast-clicks instead of zooming.
  • When zooming out from element scale, we end up at initial scale instead of minimum scale.
  • fast/events/ios/viewport-device-width-allows-double-tap-zoom-out-expected.txt: Added.
  • fast/events/ios/viewport-device-width-allows-double-tap-zoom-out.html: Added.
  • fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks-expected.txt: Added.
  • fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks.html: Added.
  • fast/events/ios/viewport-zooms-from-element-to-initial-scale-expected.txt: Added.
  • fast/events/ios/viewport-zooms-from-element-to-initial-scale.html: Added.
Location:
trunk
Files:
6 added
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r191638 r191644  
     12015-10-27  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Implement viewport-width-based fast-click heuristic
     4        https://bugs.webkit.org/show_bug.cgi?id=150604
     5        <rdar://problem/23267308>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Implement a new fast-click heuristic that applies to viewports with width = device-width. Adds
     10        new tests to check various fast-clicking behaviors. These three tests check (for pages with width=
     11        device-width) that:
     12
     13        - Double-tapping to zoom still works when the scale is not the initial scale.
     14        - If the page is at initial scale, we fire fast-clicks instead of zooming.
     15        - When zooming out from element scale, we end up at initial scale instead of minimum scale.
     16
     17        * fast/events/ios/viewport-device-width-allows-double-tap-zoom-out-expected.txt: Added.
     18        * fast/events/ios/viewport-device-width-allows-double-tap-zoom-out.html: Added.
     19        * fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks-expected.txt: Added.
     20        * fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks.html: Added.
     21        * fast/events/ios/viewport-zooms-from-element-to-initial-scale-expected.txt: Added.
     22        * fast/events/ios/viewport-zooms-from-element-to-initial-scale.html: Added.
     23
    1242015-10-27  Ryan Haddad  <ryanhaddad@apple.com>
    225
  • trunk/Source/WebKit2/ChangeLog

    r191637 r191644  
     12015-10-27  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Implement viewport-width-based fast-click heuristic
     4        https://bugs.webkit.org/show_bug.cgi?id=150604
     5        <rdar://problem/23267308>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Implement a new fast-click heuristic that applies to viewports with width = device-width. The basic rules are
     10        as follows: when a page has viewport width = device-width and is at initial zoom scale, we disable double-tapping
     11        in favor of fast-clicking. However, if the viewport scale is not the initial scale, we allow double tapping. For
     12        fast-clicking to remain useful after the user pinch-zooms, we change our double-tap to zoom out behavior to zoom
     13        to the initial scale rather than the minimum scale. For unscalable viewports, we default to fast-clicking behavior,
     14        and for all other viewports not at device-width, we double-tap to zoom and scroll as normal.
     15
     16        This patch removes some logic previously used for our scroll- and zoom-based fast-clicking heuristic, and adds
     17        information about the viewport width and initial scale to RemoteLayerTreeTransactions. This information is then
     18        used by the UI process to determine whether double tapping should be disabled or enabled.
     19
     20        The fast-click heuristic can be turned off through user default preferences, and a tap highlight for debugging
     21        fast-clicking can also be enabled through a user default preference. A red highlight indicates that a single-
     22        tap was slow, whereas a green highlight indicates a fast single-tap.
     23
     24        * Shared/mac/RemoteLayerTreeTransaction.h:
     25        (WebKit::RemoteLayerTreeTransaction::initialScaleFactor):
     26        (WebKit::RemoteLayerTreeTransaction::setInitialScaleFactor):
     27        (WebKit::RemoteLayerTreeTransaction::viewportMetaTagWidth):
     28        (WebKit::RemoteLayerTreeTransaction::setViewportMetaTagWidth):
     29        * Shared/mac/RemoteLayerTreeTransaction.mm:
     30        (WebKit::RemoteLayerTreeTransaction::encode):
     31        (WebKit::RemoteLayerTreeTransaction::decode):
     32        * UIProcess/API/Cocoa/WKWebView.mm:
     33        (-[WKWebView initWithFrame:configuration:]):
     34        (-[WKWebView _processDidExit]):
     35        (-[WKWebView _didCommitLayerTree:]):
     36        (-[WKWebView _zoomToInitialScaleWithOrigin:animated:]):
     37        (-[WKWebView _allowsDoubleTapGestures]):
     38        (-[WKWebView _setViewportMetaTagWidth:]): Deleted.
     39        (-[WKWebView _contentZoomScale]): Deleted.
     40        (-[WKWebView _viewportMetaTagWidth]): Deleted.
     41        (-[WKWebView _viewportIsUserScalable]): Deleted.
     42        * UIProcess/API/Cocoa/WKWebViewInternal.h:
     43        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
     44        * UIProcess/PageClient.h:
     45        * UIProcess/WebPageProxy.h:
     46        * UIProcess/WebPageProxy.messages.in:
     47        * UIProcess/ios/PageClientImplIOS.h:
     48        * UIProcess/ios/PageClientImplIOS.mm:
     49        (WebKit::PageClientImpl::disableDoubleTapGesturesDuringTapIfNecessary):
     50        (WebKit::PageClientImpl::didChangeViewportMetaTagWidth): Deleted.
     51        (WebKit::PageClientImpl::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary): Deleted.
     52        * UIProcess/ios/SmartMagnificationController.h:
     53        * UIProcess/ios/SmartMagnificationController.mm:
     54        (WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture):
     55        * UIProcess/ios/WKContentView.h:
     56        * UIProcess/ios/WKContentView.mm:
     57        (-[WKContentView _zoomToInitialScaleWithOrigin:]):
     58        * UIProcess/ios/WKContentViewInteraction.h:
     59        * UIProcess/ios/WKContentViewInteraction.mm:
     60        (-[WKContentView setupInteraction]):
     61        (-[WKContentView _showTapHighlight]):
     62        (-[WKContentView _didGetTapHighlightForRequest:color:quads:topLeftRadius:topRightRadius:bottomLeftRadius:bottomRightRadius:]):
     63        (-[WKContentView _mayDisableDoubleTapGesturesDuringSingleTap]):
     64        (-[WKContentView _disableDoubleTapGesturesDuringTapIfNecessary:]):
     65        (-[WKContentView _finishInteraction]):
     66        (-[WKContentView _endPotentialTapAndEnableDoubleTapGesturesIfNecessary]):
     67        (-[WKContentView _tapHighlightColorForFastClick:]):
     68        (-[WKContentView _setDoubleTapGesturesEnabled:]):
     69        (-[WKContentView _fastClickZoomThreshold]): Deleted.
     70        (-[WKContentView _allowDoubleTapToZoomForCurrentZoomScale:andTargetZoomScale:]): Deleted.
     71        (-[WKContentView _disableDoubleTapGesturesUntilTapIsFinishedIfNecessary:allowsDoubleTapZoom:targetRect:isReplaced:minimumScale:maximumScale:]): Deleted.
     72        * UIProcess/ios/WebPageProxyIOS.mm:
     73        (WebKit::WebPageProxy::disableDoubleTapGesturesDuringTapIfNecessary):
     74        (WebKit::WebPageProxy::viewportMetaTagWidthDidChange): Deleted.
     75        (WebKit::WebPageProxy::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary): Deleted.
     76        * WebProcess/WebPage/ViewGestureGeometryCollector.h:
     77        * WebProcess/WebPage/WebPage.cpp:
     78        (WebKit::WebPage::willCommitLayerTree):
     79        * WebProcess/WebPage/ios/WebPageIOS.mm:
     80        (WebKit::WebPage::potentialTapAtPosition):
     81        (WebKit::WebPage::viewportPropertiesDidChange): Deleted.
     82
    1832015-10-27  Tim Horton  <timothy_horton@apple.com>
    284
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h

    r190064 r191644  
    225225    void setMaximumScaleFactor(double scale) { m_maximumScaleFactor = scale; }
    226226
     227    double initialScaleFactor() const { return m_initialScaleFactor; }
     228    void setInitialScaleFactor(double scale) { m_initialScaleFactor = scale; }
     229
     230    double viewportMetaTagWidth() const { return m_viewportMetaTagWidth; }
     231    void setViewportMetaTagWidth(double width) { m_viewportMetaTagWidth = width; }
     232
    227233    bool allowsUserScaling() const { return m_allowsUserScaling; }
    228234    void setAllowsUserScaling(bool allowsUserScaling) { m_allowsUserScaling = allowsUserScaling; }
     
    259265    double m_minimumScaleFactor { 1 };
    260266    double m_maximumScaleFactor { 1 };
     267    double m_initialScaleFactor { 1 };
     268    double m_viewportMetaTagWidth { -1 };
    261269    uint64_t m_renderTreeSize { 0 };
    262270    uint64_t m_transactionID { 0 };
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm

    r191243 r191644  
    518518    encoder << m_minimumScaleFactor;
    519519    encoder << m_maximumScaleFactor;
     520    encoder << m_initialScaleFactor;
     521    encoder << m_viewportMetaTagWidth;
    520522
    521523    encoder << m_renderTreeSize;
     
    596598
    597599    if (!decoder.decode(result.m_maximumScaleFactor))
     600        return false;
     601
     602    if (!decoder.decode(result.m_initialScaleFactor))
     603        return false;
     604
     605    if (!decoder.decode(result.m_viewportMetaTagWidth))
    598606        return false;
    599607
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r191600 r191644  
    175175    CGRect _inputViewBounds;
    176176    CGFloat _viewportMetaTagWidth;
     177    CGFloat _initialScaleFactor;
     178    BOOL _fastClickingIsDisabled;
     179
    177180    BOOL _allowsLinkPreview;
    178181
     
    354357    [self _updateScrollViewBackground];
    355358
    356     _viewportMetaTagWidth = -1;
     359    _viewportMetaTagWidth = WebCore::ViewportArguments::ValueAuto;
     360    _initialScaleFactor = 1;
     361    _fastClickingIsDisabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitFastClickingDisabled"];
    357362
    358363    [self _frameOrBoundsChanged];
     
    815820}
    816821
    817 - (void)_setViewportMetaTagWidth:(float)newWidth
    818 {
    819     _viewportMetaTagWidth = newWidth;
    820 }
    821 
    822822- (void)_willInvokeUIScrollViewDelegateCallback
    823823{
     
    932932    [_scrollView setZoomScale:1];
    933933
    934     _viewportMetaTagWidth = -1;
     934    _viewportMetaTagWidth = WebCore::ViewportArguments::ValueAuto;
     935    _initialScaleFactor = 1;
    935936    _hasCommittedLoadForMainFrame = NO;
    936937    _needsResetViewStateAfterCommitLoadForMainFrame = NO;
     
    10141015        [_scrollView setZoomScale:layerTreeTransaction.pageScaleFactor()];
    10151016
    1016     [_contentView _setDoubleTapGesturesEnabled:self._viewportIsUserScalable];
     1017    _viewportMetaTagWidth = layerTreeTransaction.viewportMetaTagWidth();
     1018    _initialScaleFactor = layerTreeTransaction.initialScaleFactor();
     1019    if (![_contentView _mayDisableDoubleTapGesturesDuringSingleTap])
     1020        [_contentView _setDoubleTapGesturesEnabled:self._allowsDoubleTapGestures];
    10171021
    10181022    [self _updateScrollViewBackground];
     
    12931297}
    12941298
     1299- (void)_zoomToInitialScaleWithOrigin:(WebCore::FloatPoint)origin animated:(BOOL)animated
     1300{
     1301    ASSERT(_initialScaleFactor > 0);
     1302    [self _zoomToPoint:origin atScale:_initialScaleFactor animated:animated];
     1303}
     1304
    12951305// focusedElementRect and selectionRect are both in document coordinates.
    12961306- (void)_zoomToFocusRect:(WebCore::FloatRect)focusedElementRectInDocumentCoordinates selectionRect:(WebCore::FloatRect)selectionRectInDocumentCoordinates fontSize:(float)fontSize minimumScale:(double)minimumScale maximumScale:(double)maximumScale allowScaling:(BOOL)allowScaling forceScroll:(BOOL)forceScroll
     
    14101420                     duration:UIWebFormAnimationDuration
    14111421                        force:YES];
    1412 }
    1413 
    1414 - (CGFloat)_contentZoomScale
    1415 {
    1416     return contentZoomScale(self);
    14171422}
    14181423
     
    30973102}
    30983103
    3099 - (CGFloat)_viewportMetaTagWidth
    3100 {
    3101     return _viewportMetaTagWidth;
    3102 }
    3103 
    3104 - (BOOL)_viewportIsUserScalable
    3105 {
    3106     return [_scrollView isZoomEnabled] && [_scrollView minimumZoomScale] < [_scrollView maximumZoomScale];
     3104- (BOOL)_allowsDoubleTapGestures
     3105{
     3106    if (_fastClickingIsDisabled)
     3107        return YES;
     3108
     3109    // If the page is not user scalable, we don't allow double tap gestures.
     3110    if (![_scrollView isZoomEnabled] || [_scrollView minimumZoomScale] >= [_scrollView maximumZoomScale])
     3111        return NO;
     3112
     3113    // For scalable viewports, only disable double tap gestures if the viewport width is device width.
     3114    if (_viewportMetaTagWidth != WebCore::ViewportArguments::ValueDeviceWidth)
     3115        return YES;
     3116
     3117    return !areEssentiallyEqualAsFloat(contentZoomScale(self), _initialScaleFactor);
    31073118}
    31083119
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h

    r191309 r191644  
    8888- (BOOL)_zoomToRect:(WebCore::FloatRect)targetRect withOrigin:(WebCore::FloatPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(float)minimumScrollDistance;
    8989- (void)_zoomOutWithOrigin:(WebCore::FloatPoint)origin animated:(BOOL)animated;
     90- (void)_zoomToInitialScaleWithOrigin:(WebCore::FloatPoint)origin animated:(BOOL)animated;
    9091
    9192- (void)_setHasCustomContentView:(BOOL)hasCustomContentView loadedMIMEType:(const WTF::String&)mimeType;
    9293- (void)_didFinishLoadingDataForCustomContentProviderWithSuggestedFilename:(const WTF::String&)suggestedFilename data:(NSData *)data;
    93 - (void)_setViewportMetaTagWidth:(float)newWidth;
    9494
    9595- (void)_willInvokeUIScrollViewDelegateCallback;
     
    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 
     112@property (nonatomic, readonly) BOOL _allowsDoubleTapGestures;
    115113@property (nonatomic, readonly) UIEdgeInsets _computedContentInset;
    116114#else
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h

    r191479 r191644  
    135135@property (nonatomic, readonly) NSString *_suggestedFilenameForDisplayedPDF;
    136136
    137 // The viewport meta tag width is negative if the value is not defined.
    138 @property (nonatomic, readonly) CGFloat _viewportMetaTagWidth;
    139 @property (nonatomic, readonly) BOOL _viewportIsUserScalable;
    140 
    141137@property (nonatomic, readonly) _WKWebViewPrintFormatter *_webViewPrintFormatter;
    142138
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r191402 r191644  
    295295    virtual void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect) = 0;
    296296    virtual void zoomToRect(WebCore::FloatRect, double minimumScale, double maximumScale) = 0;
    297     virtual void didChangeViewportMetaTagWidth(float) = 0;
    298     virtual void disableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, const WebCore::FloatRect& targetRect, bool isReplacedElement, double minimumScale, double maximumScale) = 0;
     297    virtual void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) = 0;
    299298    virtual double minimumZoomScale() const = 0;
    300299    virtual WebCore::FloatRect documentRect() const = 0;
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r191543 r191644  
    511511    void commitPotentialTapFailed();
    512512    void didNotHandleTapAsClick(const WebCore::IntPoint&);
    513     void viewportMetaTagWidthDidChange(float width);
    514     void disableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, const WebCore::FloatRect& targetRect, bool isReplacedElement, double minimumScale, double maximumScale);
     513    void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID);
    515514    void didFinishDrawingPagesToPDF(const IPC::DataReference&);
    516515    void contentSizeCategoryDidChange(const String& contentSizeCategory);
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r191543 r191644  
    184184    CommitPotentialTapFailed()
    185185    DidNotHandleTapAsClick(WebCore::IntPoint point)
    186     ViewportMetaTagWidthDidChange(float width)
    187     DisableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, WebCore::FloatRect targetRect, bool isReplacedElement, double minimumScale, double maximumScale)
     186    DisableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID)
    188187    DidFinishDrawingPagesToPDF(IPC::DataReference pdfData)
    189188#endif
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h

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

    r191402 r191644  
    255255}
    256256
    257 void PageClientImpl::didChangeViewportMetaTagWidth(float newWidth)
    258 {
    259     [m_webView _setViewportMetaTagWidth:newWidth];
    260 }
    261 
    262 void PageClientImpl::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, const WebCore::FloatRect& targetRect, bool isReplacedElement, double minimumScale, double maximumScale)
    263 {
    264     if (!m_webView._viewportIsUserScalable)
     257void PageClientImpl::disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID)
     258{
     259    if (!m_webView._allowsDoubleTapGestures)
    265260        return;
    266261
    267     [m_contentView _disableDoubleTapGesturesUntilTapIsFinishedIfNecessary:requestID allowsDoubleTapZoom:allowsDoubleTapZoom targetRect:targetRect isReplaced:isReplacedElement minimumScale:minimumScale maximumScale:maximumScale];
     262    [m_contentView _disableDoubleTapGesturesDuringTapIfNecessary:requestID];
    268263}
    269264
  • trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.h

    r191309 r191644  
    4949    void handleSmartMagnificationGesture(WebCore::FloatPoint origin);
    5050    void handleResetMagnificationGesture(WebCore::FloatPoint origin);
    51     void adjustSmartMagnificationTargetRectAndZoomScales(bool addMagnificationPadding, WebCore::FloatRect& targetRect, double& minimumScale, double& maximumScale);
    5251
    5352private:
     
    5756    void didCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale);
    5857    void magnify(WebCore::FloatPoint origin, WebCore::FloatRect targetRect, WebCore::FloatRect visibleContentRect, double viewportMinimumScale, double viewportMaximumScale);
     58    void adjustSmartMagnificationTargetRectAndZoomScales(bool addMagnificationPadding, WebCore::FloatRect& targetRect, double& minimumScale, double& maximumScale);
    5959
    6060    WebPageProxy& m_webPageProxy;
  • trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.mm

    r191309 r191644  
    9494    if (targetRect.isEmpty()) {
    9595        // FIXME: If we don't zoom, send the tap along to text selection (see <rdar://problem/6810344>).
    96         [m_contentView _zoomOutWithOrigin:origin];
     96        [m_contentView _zoomToInitialScaleWithOrigin:origin];
    9797        return;
    9898    }
     
    120120
    121121    // FIXME: If we still don't zoom, send the tap along to text selection (see <rdar://problem/6810344>).
    122     [m_contentView _zoomOutWithOrigin:origin];
     122    [m_contentView _zoomToInitialScaleWithOrigin:origin];
    123123}
    124124
  • trunk/Source/WebKit2/UIProcess/ios/WKContentView.h

    r188892 r191644  
    9393- (BOOL)_zoomToRect:(CGRect)targetRect withOrigin:(CGPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(CGFloat)minimumScrollDistance;
    9494- (void)_zoomOutWithOrigin:(CGPoint)origin;
     95- (void)_zoomToInitialScaleWithOrigin:(CGPoint)origin;
    9596
    9697@end
  • trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm

    r188892 r191644  
    541541}
    542542
     543- (void)_zoomToInitialScaleWithOrigin:(CGPoint)origin
     544{
     545    return [_webView _zoomToInitialScaleWithOrigin:origin animated:YES];
     546}
     547
    543548- (void)_applicationWillResignActive:(NSNotification*)notification
    544549{
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h

    r191409 r191644  
    160160    BOOL _didAccessoryTabInitiateFocus;
    161161    BOOL _isExpectingFastSingleTapCommit;
     162    BOOL _showDebugTapHighlightsForFastClicking;
    162163}
    163164
     
    184185- (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;
    185186
    186 - (void)_disableDoubleTapGesturesUntilTapIsFinishedIfNecessary:(uint64_t)requestID allowsDoubleTapZoom:(bool)allowsDoubleTapZoom targetRect:(WebCore::FloatRect)targetRect isReplaced:(BOOL)isReplacedElement minimumScale:(double)minimumScale maximumScale:(double)maximumScale;
     187- (BOOL)_mayDisableDoubleTapGesturesDuringSingleTap;
     188- (void)_disableDoubleTapGesturesDuringTapIfNecessary:(uint64_t)requestID;
    187189- (void)_startAssistingNode:(const WebKit::AssistedNodeInformation&)information userIsInteracting:(BOOL)userIsInteracting blurPreviousNode:(BOOL)blurPreviousNode userObject:(NSObject <NSSecureCoding> *)userObject;
    188190- (void)_stopAssistingNode;
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r191535 r191644  
    477477    _smartMagnificationController = std::make_unique<SmartMagnificationController>(self);
    478478    _isExpectingFastSingleTapCommit = NO;
     479    _showDebugTapHighlightsForFastClicking = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitShowFastClickDebugTapHighlights"];
    479480}
    480481
     
    841842- (void)_showTapHighlight
    842843{
    843     if (!highlightedQuadsAreSmallerThanRect(_tapHighlightInformation.quads, _page->unobscuredContentRect()))
     844    if (!highlightedQuadsAreSmallerThanRect(_tapHighlightInformation.quads, _page->unobscuredContentRect()) && !_showDebugTapHighlightsForFastClicking)
    844845        return;
    845846
     
    861862    _isTapHighlightIDValid = NO;
    862863
    863     _tapHighlightInformation.color = color;
    864864    _tapHighlightInformation.quads = highlightedQuads;
    865865    _tapHighlightInformation.topLeftRadius = topLeftRadius;
     
    867867    _tapHighlightInformation.bottomLeftRadius = bottomLeftRadius;
    868868    _tapHighlightInformation.bottomRightRadius = bottomRightRadius;
     869    if (_showDebugTapHighlightsForFastClicking)
     870        _tapHighlightInformation.color = [self _tapHighlightColorForFastClick:![_doubleTapGestureRecognizer isEnabled]];
     871    else
     872        _tapHighlightInformation.color = color;
    869873
    870874    if (_potentialTapInProgress) {
     
    881885}
    882886
    883 - (CGFloat)_fastClickZoomThreshold
    884 {
    885     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    886     if (![defaults boolForKey:@"WebKitFastClickingEnabled"])
    887         return 0;
    888 
    889     return [defaults floatForKey:@"WebKitFastClickZoomThreshold"];
    890 }
    891 
    892 - (BOOL)_allowDoubleTapToZoomForCurrentZoomScale:(CGFloat)currentZoomScale andTargetZoomScale:(CGFloat)targetZoomScale
    893 {
    894     CGFloat zoomThreshold = [self _fastClickZoomThreshold];
    895     if (!zoomThreshold)
    896         return YES;
    897 
    898     CGFloat minimumZoomRatioForDoubleTapToZoomIn = 1 + zoomThreshold;
    899     CGFloat maximumZoomRatioForDoubleTapToZoomOut = 1 / minimumZoomRatioForDoubleTapToZoomIn;
    900     CGFloat zoomRatio = targetZoomScale / currentZoomScale;
    901     return zoomRatio < maximumZoomRatioForDoubleTapToZoomOut || zoomRatio > minimumZoomRatioForDoubleTapToZoomIn;
    902 }
    903 
    904 - (void)_disableDoubleTapGesturesUntilTapIsFinishedIfNecessary:(uint64_t)requestID allowsDoubleTapZoom:(bool)allowsDoubleTapZoom targetRect:(WebCore::FloatRect)targetRect isReplaced:(BOOL)isReplacedElement minimumScale:(double)minimumScale maximumScale:(double)maximumScale
     887- (BOOL)_mayDisableDoubleTapGesturesDuringSingleTap
     888{
     889    return _potentialTapInProgress;
     890}
     891
     892- (void)_disableDoubleTapGesturesDuringTapIfNecessary:(uint64_t)requestID
    905893{
    906894    if (!_potentialTapInProgress || _latestTapID != requestID)
    907895        return;
    908 
    909     if (allowsDoubleTapZoom) {
    910         // 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.
    911         _smartMagnificationController->adjustSmartMagnificationTargetRectAndZoomScales(!isReplacedElement, targetRect, minimumScale, maximumScale);
    912         CGFloat currentZoomScale = [_webView _contentZoomScale];
    913         CGFloat targetZoomScale = [_webView _targetContentZoomScaleForRect:targetRect currentScale:currentZoomScale fitEntireRect:isReplacedElement minimumScale:minimumScale maximumScale:maximumScale];
    914         if ([self _allowDoubleTapToZoomForCurrentZoomScale:currentZoomScale andTargetZoomScale:targetZoomScale])
    915             return;
    916     }
    917896
    918897    [self _setDoubleTapGesturesEnabled:NO];
     
    11541133{
    11551134    _isTapHighlightIDValid = NO;
    1156     [UIView animateWithDuration:0.1
     1135    CGFloat tapHighlightFadeDuration = _showDebugTapHighlightsForFastClicking ? 0.25 : 0.1;
     1136    [UIView animateWithDuration:tapHighlightFadeDuration
    11571137                     animations:^{
    11581138                         [_highlightView layer].opacity = 0;
     
    12601240- (void)_endPotentialTapAndEnableDoubleTapGesturesIfNecessary
    12611241{
    1262     if (_webView._viewportIsUserScalable)
     1242    if (_webView._allowsDoubleTapGestures)
    12631243        [self _setDoubleTapGesturesEnabled:YES];
    12641244
     
    24152395}
    24162396
     2397- (WebCore::Color)_tapHighlightColorForFastClick:(BOOL)forFastClick
     2398{
     2399    ASSERT(_showDebugTapHighlightsForFastClicking);
     2400    return forFastClick ? WebCore::Color(0, 225, 0, 127) : WebCore::Color(225, 0, 0, 127);
     2401}
     2402
    24172403- (void)_setDoubleTapGesturesEnabled:(BOOL)enabled
    24182404{
     
    24242410        [self _createAndConfigureDoubleTapGestureRecognizer];
    24252411    }
     2412
     2413    if (_showDebugTapHighlightsForFastClicking && !enabled)
     2414        _tapHighlightInformation.color = [self _tapHighlightColorForFastClick:YES];
     2415
    24262416    [_doubleTapGestureRecognizer setEnabled:enabled];
    24272417}
  • trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm

    r191309 r191644  
    933933}
    934934
    935 void WebPageProxy::viewportMetaTagWidthDidChange(float width)
    936 {
    937     m_pageClient.didChangeViewportMetaTagWidth(width);
    938 }
    939 
    940 void 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);
     935void WebPageProxy::disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID)
     936{
     937    m_pageClient.disableDoubleTapGesturesDuringTapIfNecessary(requestID);
    943938}
    944939
  • trunk/Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.h

    r191309 r191644  
    4646
    4747    void mainFrameDidLayout();
    48     void computeZoomInformationForNode(WebCore::Node&, WebCore::FloatPoint& origin, WebCore::FloatRect& renderRect, bool& isReplaced, double& viewportMinimumScale, double& viewportMaximumScale);
    4948
    5049private:
     
    6362
    6463    void dispatchDidCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect targetRect, WebCore::FloatRect visibleContentRect, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale);
     64    void computeZoomInformationForNode(WebCore::Node&, WebCore::FloatPoint& origin, WebCore::FloatRect& renderRect, bool& isReplaced, double& viewportMinimumScale, double& viewportMaximumScale);
    6565
    6666    WebPage& m_webPage;
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r191543 r191644  
    29442944    layerTransaction.setMinimumScaleFactor(m_viewportConfiguration.minimumScale());
    29452945    layerTransaction.setMaximumScaleFactor(m_viewportConfiguration.maximumScale());
     2946    layerTransaction.setInitialScaleFactor(m_viewportConfiguration.initialScale());
     2947    layerTransaction.setViewportMetaTagWidth(m_viewportConfiguration.viewportArguments().width);
    29462948    layerTransaction.setAllowsUserScaling(allowsUserScaling());
    29472949#endif
  • trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

    r191452 r191644  
    234234        return;
    235235
    236     float oldWidth = m_viewportConfiguration.viewportArguments().width;
    237 
    238236    m_viewportConfiguration.setViewportArguments(viewportArguments);
    239237    viewportConfigurationChanged();
    240 
    241     if (oldWidth != viewportArguments.width)
    242         send(Messages::WebPageProxy::ViewportMetaTagWidthDidChange(viewportArguments.width));
    243238}
    244239
     
    665660    m_potentialTapNode = m_page->mainFrame().nodeRespondingToClickEvents(position, m_potentialTapLocation);
    666661    sendTapHighlightForNodeIfNecessary(requestID, m_potentialTapNode.get());
    667     if (m_potentialTapNode) {
    668662#if ENABLE(TOUCH_EVENTS)
    669         if (!m_potentialTapNode->allowsDoubleTapGesture()) {
    670             send(Messages::WebPageProxy::DisableDoubleTapGesturesUntilTapIsFinishedIfNecessary(requestID, false, FloatRect(), false, 0, 0));
    671             return;
    672         }
     663    if (m_potentialTapNode && !m_potentialTapNode->allowsDoubleTapGesture())
     664        send(Messages::WebPageProxy::DisableDoubleTapGesturesDuringTapIfNecessary(requestID));
    673665#endif
    674         FloatPoint origin = position;
    675         FloatRect renderRect;
    676         bool isReplaced;
    677         double viewportMinimumScale;
    678         double viewportMaximumScale;
    679 
    680         m_viewGestureGeometryCollector.computeZoomInformationForNode(*m_potentialTapNode.get(), origin, renderRect, isReplaced, viewportMinimumScale, viewportMaximumScale);
    681         send(Messages::WebPageProxy::DisableDoubleTapGesturesUntilTapIsFinishedIfNecessary(requestID, true, renderRect, isReplaced, viewportMinimumScale, viewportMaximumScale));
    682     }
    683666}
    684667
Note: See TracChangeset for help on using the changeset viewer.