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

Changeset 242757 in webkit


Ignore:
Timestamp:
Mar 11, 2019, 4:43:04 PM (7 years ago)
Author:
dino@apple.com
Message:

[iOS] Implement a faster click detection that intercepts double-tap-to-zoom if possible
https://bugs.webkit.org/show_bug.cgi?id=195473
<rdar://problem/48718396>

Reviewed by Wenson Hsieh (with some help from Dan Bates).

Source/WebKit:

Adds a new algorithm, behind a flag FasterClicksEnabled, that can trigger a click
event without waiting to see if a double tap will occur. It does this by examining
the amount of zoom that would be triggered if it was a double tap, and if that value
doesn't exceed a set threshold, commits to the click event instead.

This is implemented by having the Web Process respond to the potential click with
some geometry information. If the UI Process receives the information before the
second tap in a double tap, it can decide to trigger a click.

  • Shared/WebPreferences.yaml: New internal feature so this can be toggled in

a UI for testing.

  • SourcesCocoa.txt: Renamed WKSyntheticTapGestureRecognizer.
  • WebKit.xcodeproj/project.pbxproj: Ditto.
  • UIProcess/ios/WKSyntheticTapGestureRecognizer.h:
  • UIProcess/ios/WKSyntheticTapGestureRecognizer.m:

(-[WKSyntheticTapGestureRecognizer setGestureIdentifiedTarget:action:]):
(-[WKSyntheticTapGestureRecognizer setGestureFailedTarget:action:]):
(-[WKSyntheticTapGestureRecognizer setResetTarget:action:]):
(-[WKSyntheticTapGestureRecognizer setState:]):
(-[WKSyntheticTapGestureRecognizer reset]): Renamed WKSyntheticClickTapGestureRecognizer to

WKSyntheticTapGestureRecognizer, changed the signature of the main function to be a bit
more clear about what it does, and added a gesture failed target.

  • UIProcess/API/Cocoa/WKWebViewInternal.h:
  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _initialScaleFactor]):
(-[WKWebView _contentZoomScale]):
(-[WKWebView _targetContentZoomScaleForRect:currentScale:fitEntireRect:minimumScale:maximumScale:]):

Exposed the initial content scale, the current scale and added a declaration that
was missing from the .h.

  • UIProcess/WebPageProxy.messages.in: Add a new message,

HandleSmartMagnificationInformationForPotentialTap, to
communicate the geometry of the clicked node to the UI Process.

  • UIProcess/PageClient.h: Pure virtual function for the geometry message response.
  • UIProcess/WebPageProxy.h: Ditto.
  • UIProcess/ios/PageClientImplIOS.h: Calls into the WKContentView.
  • UIProcess/ios/PageClientImplIOS.mm:

(WebKit::PageClientImpl::handleSmartMagnificationInformationForPotentialTap):

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

(WebKit::SmartMagnificationController::calculatePotentialZoomParameters): A new method that

asks the WKContentView to work out what the zoom factor will be for a potential double
tap at a location.

(WebKit::SmartMagnificationController::smartMagnificationTargetRectAndZoomScales): New implementation

of this function to avoid multiple out-arguments.

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

(-[WKContentView _initialScaleFactor]):
(-[WKContentView _contentZoomScale]):
(-[WKContentView _targetContentZoomScaleForRect:currentScale:fitEntireRect:minimumScale:maximumScale:]):

Exposed the initial content scale, the current scale and the target zoom scale. These
all just call into the WKWebView implementation.

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

(-[WKContentView _createAndConfigureDoubleTapGestureRecognizer]): Use a WKSyntheticTapGestureRecognizer instead

of a generic one, so we can capture the failure.

(-[WKContentView setupInteraction]):
(-[WKContentView cleanupInteraction]):
(-[WKContentView _handleSmartMagnificationInformationForPotentialTap:origin:renderRect:fitEntireRect:viewportMinimumScale:viewportMaximumScale:]):

New method that responds to the incoming Web Process message, and decides if any
potential zoom would be "significant".

(-[WKContentView _singleTapIdentified:]):
(-[WKContentView _doubleTapDidFail:]):
(-[WKContentView _didCompleteSyntheticClick]):
(-[WKContentView _singleTapRecognized:]):
(-[WKContentView _doubleTapRecognized:]):

Add some release logging.

(-[WKContentView _singleTapCommited:]): Deleted.

  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::WebPageProxy::potentialTapAtPosition):
(WebKit::WebPageProxy::handleSmartMagnificationInformationForPotentialTap):

  • WebProcess/WebPage/ViewGestureGeometryCollector.h:
  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:

Removed an unused parameter from the existing message.

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::potentialTapAtPosition): Calculates the geometry of the element
if requested, and sends it to the UIProcess.

LayoutTests:

Implement a test (iPad only) that sets up a page with zoomable content
but not quite at a significant scale, meaning we should dispatch a click
event rather than Double Tap To Zoom.

In order to do this, a humanSpeedDoubleTapAt() method was added to
UIHelper that sleeps a bit between taps, otherwise the double tap
gesture is recognized before the Web Process has had a chance to
evaluate the potential click.

  • fast/events/ios/ipad/fast-click-double-tap-sends-click-on-insignificant-zoom-expected.txt: Added.
  • fast/events/ios/ipad/fast-click-double-tap-sends-click-on-insignificant-zoom.html: Added.
  • platform/ios/TestExpectations:
  • platform/ipad/TestExpectations:
  • resources/ui-helper.js:

(window.UIHelper.humanSpeedDoubleTapAt):

Location:
trunk
Files:
3 added
25 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r242749 r242757  
     12019-03-11  Dean Jackson  <dino@apple.com>
     2
     3        [iOS] Implement a faster click detection that intercepts double-tap-to-zoom if possible
     4        https://bugs.webkit.org/show_bug.cgi?id=195473
     5        <rdar://problem/48718396>
     6
     7        Reviewed by Wenson Hsieh (with some help from Dan Bates).
     8
     9        Implement a test (iPad only) that sets up a page with zoomable content
     10        but not quite at a significant scale, meaning we should dispatch a click
     11        event rather than Double Tap To Zoom.
     12
     13        In order to do this, a humanSpeedDoubleTapAt() method was added to
     14        UIHelper that sleeps a bit between taps, otherwise the double tap
     15        gesture is recognized before the Web Process has had a chance to
     16        evaluate the potential click.
     17
     18        * fast/events/ios/ipad/fast-click-double-tap-sends-click-on-insignificant-zoom-expected.txt: Added.
     19        * fast/events/ios/ipad/fast-click-double-tap-sends-click-on-insignificant-zoom.html: Added.
     20        * platform/ios/TestExpectations:
     21        * platform/ipad/TestExpectations:
     22        * resources/ui-helper.js:
     23        (window.UIHelper.humanSpeedDoubleTapAt):
     24
    1252019-03-11  Wenson Hsieh  <wenson_hsieh@apple.com>
    226
  • trunk/LayoutTests/platform/ios/TestExpectations

    r242730 r242757  
    2323# End platform-specific directories.
    2424#//////////////////////////////////////////////////////////////////////////////////////////
     25
     26# iPad-specific tests skipped here and re-enabled in platform/ipad
     27fast/events/ios/ipad [ Skip ]
    2528
    2629###
  • trunk/LayoutTests/resources/ui-helper.js

    r242683 r242757  
    7272                    uiController.uiScriptComplete();
    7373                });`, resolve);
     74        });
     75    }
     76
     77    static humanSpeedDoubleTapAt(x, y)
     78    {
     79        console.assert(this.isIOS());
     80
     81        if (!this.isWebKit2()) {
     82            // FIXME: Add a sleep in here.
     83            eventSender.addTouchPoint(x, y);
     84            eventSender.touchStart();
     85            eventSender.releaseTouchPoint(0);
     86            eventSender.touchEnd();
     87            eventSender.addTouchPoint(x, y);
     88            eventSender.touchStart();
     89            eventSender.releaseTouchPoint(0);
     90            eventSender.touchEnd();
     91            return Promise.resolve();
     92        }
     93
     94        return new Promise(async (resolve) => {
     95            await UIHelper.tapAt(x, y);
     96            await new Promise(resolveAfterDelay => setTimeout(resolveAfterDelay, 120));
     97            await UIHelper.tapAt(x, y);
     98            resolve();
    7499        });
    75100    }
  • trunk/Source/WebKit/ChangeLog

    r242756 r242757  
     12019-03-11  Dean Jackson  <dino@apple.com>
     2
     3        [iOS] Implement a faster click detection that intercepts double-tap-to-zoom if possible
     4        https://bugs.webkit.org/show_bug.cgi?id=195473
     5        <rdar://problem/48718396>
     6
     7        Reviewed by Wenson Hsieh (with some help from Dan Bates).
     8
     9        Adds a new algorithm, behind a flag FasterClicksEnabled, that can trigger a click
     10        event without waiting to see if a double tap will occur. It does this by examining
     11        the amount of zoom that would be triggered if it was a double tap, and if that value
     12        doesn't exceed a set threshold, commits to the click event instead.
     13
     14        This is implemented by having the Web Process respond to the potential click with
     15        some geometry information. If the UI Process receives the information before the
     16        second tap in a double tap, it can decide to trigger a click.
     17
     18        * Shared/WebPreferences.yaml: New internal feature so this can be toggled in
     19            a UI for testing.
     20
     21        * SourcesCocoa.txt: Renamed WKSyntheticTapGestureRecognizer.
     22        * WebKit.xcodeproj/project.pbxproj: Ditto.
     23
     24        * UIProcess/ios/WKSyntheticTapGestureRecognizer.h:
     25        * UIProcess/ios/WKSyntheticTapGestureRecognizer.m:
     26        (-[WKSyntheticTapGestureRecognizer setGestureIdentifiedTarget:action:]):
     27        (-[WKSyntheticTapGestureRecognizer setGestureFailedTarget:action:]):
     28        (-[WKSyntheticTapGestureRecognizer setResetTarget:action:]):
     29        (-[WKSyntheticTapGestureRecognizer setState:]):
     30        (-[WKSyntheticTapGestureRecognizer reset]):  Renamed WKSyntheticClickTapGestureRecognizer to
     31            WKSyntheticTapGestureRecognizer, changed the signature of the main function to be a bit
     32            more clear about what it does, and added a gesture failed target.
     33
     34        * UIProcess/API/Cocoa/WKWebViewInternal.h:
     35        * UIProcess/API/Cocoa/WKWebView.mm:
     36        (-[WKWebView _initialScaleFactor]):
     37        (-[WKWebView _contentZoomScale]):
     38        (-[WKWebView _targetContentZoomScaleForRect:currentScale:fitEntireRect:minimumScale:maximumScale:]):
     39            Exposed the initial content scale, the current scale and added a declaration that
     40            was missing from the .h.
     41
     42        * UIProcess/WebPageProxy.messages.in: Add a new message,
     43            HandleSmartMagnificationInformationForPotentialTap, to
     44            communicate the geometry of the clicked node to the UI Process.
     45
     46        * UIProcess/PageClient.h: Pure virtual function for the geometry message response.
     47        * UIProcess/WebPageProxy.h: Ditto.
     48
     49        * UIProcess/ios/PageClientImplIOS.h: Calls into the WKContentView.
     50        * UIProcess/ios/PageClientImplIOS.mm:
     51        (WebKit::PageClientImpl::handleSmartMagnificationInformationForPotentialTap):
     52
     53        * UIProcess/ios/SmartMagnificationController.h:
     54        * UIProcess/ios/SmartMagnificationController.mm:
     55        (WebKit::SmartMagnificationController::calculatePotentialZoomParameters): A new method that
     56            asks the WKContentView to work out what the zoom factor will be for a potential double
     57            tap at a location.
     58        (WebKit::SmartMagnificationController::smartMagnificationTargetRectAndZoomScales): New implementation
     59            of this function to avoid multiple out-arguments.
     60
     61        * UIProcess/ios/WKContentView.h:
     62        * UIProcess/ios/WKContentView.mm:
     63        (-[WKContentView _initialScaleFactor]):
     64        (-[WKContentView _contentZoomScale]):
     65        (-[WKContentView _targetContentZoomScaleForRect:currentScale:fitEntireRect:minimumScale:maximumScale:]):
     66            Exposed the initial content scale, the current scale and the target zoom scale. These
     67            all just call into the WKWebView implementation.
     68
     69        * UIProcess/ios/WKContentViewInteraction.h:
     70        * UIProcess/ios/WKContentViewInteraction.mm:
     71        (-[WKContentView _createAndConfigureDoubleTapGestureRecognizer]): Use a WKSyntheticTapGestureRecognizer instead
     72            of a generic one, so we can capture the failure.
     73        (-[WKContentView setupInteraction]):
     74        (-[WKContentView cleanupInteraction]):
     75        (-[WKContentView _handleSmartMagnificationInformationForPotentialTap:origin:renderRect:fitEntireRect:viewportMinimumScale:viewportMaximumScale:]):
     76            New method that responds to the incoming Web Process message, and decides if any
     77            potential zoom would be "significant".
     78        (-[WKContentView _singleTapIdentified:]):
     79        (-[WKContentView _doubleTapDidFail:]):
     80        (-[WKContentView _didCompleteSyntheticClick]):
     81        (-[WKContentView _singleTapRecognized:]):
     82        (-[WKContentView _doubleTapRecognized:]):
     83            Add some release logging.
     84        (-[WKContentView _singleTapCommited:]): Deleted.
     85
     86        * UIProcess/ios/WebPageProxyIOS.mm:
     87        (WebKit::WebPageProxy::potentialTapAtPosition):
     88        (WebKit::WebPageProxy::handleSmartMagnificationInformationForPotentialTap):
     89        * WebProcess/WebPage/ViewGestureGeometryCollector.h:
     90        * WebProcess/WebPage/WebPage.h:
     91        * WebProcess/WebPage/WebPage.messages.in:
     92            Removed an unused parameter from the existing message.
     93
     94        * WebProcess/WebPage/ios/WebPageIOS.mm:
     95        (WebKit::WebPage::potentialTapAtPosition): Calculates the geometry of the element
     96        if requested, and sends it to the UIProcess.
     97
    1982019-03-11  Per Arne Vollan  <pvollan@apple.com>
    299
  • trunk/Source/WebKit/Shared/WebPreferences.yaml

    r242748 r242757  
    14711471  webcoreName: selectionAcrossShadowBoundariesEnabled
    14721472
     1473FasterClicksEnabled:
     1474  type: bool
     1475  defaultValue: true
     1476  condition: PLATFORM(IOS_FAMILY)
     1477  humanReadableName: "Faster clicks"
     1478  humanReadableDescription: "Support faster clicks on zoomable pages"
     1479  webcoreBinding: none
     1480  category: internal
     1481
    14731482InputTypeColorEnabled:
    14741483  type: bool
  • trunk/Source/WebKit/SourcesCocoa.txt

    r242748 r242757  
    412412UIProcess/ios/WKPDFView.mm
    413413UIProcess/ios/WKScrollView.mm
    414 UIProcess/ios/WKSyntheticClickTapGestureRecognizer.m
    415414UIProcess/ios/WKSyntheticFlagsChangedWebEvent.mm
     415UIProcess/ios/WKSyntheticTapGestureRecognizer.m
    416416UIProcess/ios/WKSystemPreviewView.mm
    417417UIProcess/ios/WKWebEvent.mm
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r242696 r242757  
    24562456}
    24572457
    2458 - (CGFloat)_targetContentZoomScaleForRect:(const WebCore::FloatRect&)targetRect currentScale:(double)currentScale fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale
     2458- (double)_initialScaleFactor
     2459{
     2460    return _initialScaleFactor;
     2461}
     2462
     2463- (double)_contentZoomScale
     2464{
     2465    return contentZoomScale(self);
     2466}
     2467
     2468- (double)_targetContentZoomScaleForRect:(const WebCore::FloatRect&)targetRect currentScale:(double)currentScale fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale
    24592469{
    24602470    WebCore::FloatSize unobscuredContentSize([self _contentRectForUserInteraction].size);
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h

    r242339 r242757  
    100100- (void)_scrollToContentScrollPosition:(WebCore::FloatPoint)scrollPosition scrollOrigin:(WebCore::IntPoint)scrollOrigin;
    101101- (BOOL)_scrollToRect:(WebCore::FloatRect)targetRect origin:(WebCore::FloatPoint)origin minimumScrollDistance:(float)minimumScrollDistance;
     102- (double)_initialScaleFactor;
     103- (double)_contentZoomScale;
     104- (double)_targetContentZoomScaleForRect:(const WebCore::FloatRect&)targetRect currentScale:(double)currentScale fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale;
    102105- (void)_zoomToFocusRect:(const WebCore::FloatRect&)focusedElementRect selectionRect:(const WebCore::FloatRect&)selectionRectInDocumentCoordinates insideFixed:(BOOL)insideFixed fontSize:(float)fontSize minimumScale:(double)minimumScale maximumScale:(double)maximumScale allowScaling:(BOOL)allowScaling forceScroll:(BOOL)forceScroll;
    103106- (BOOL)_zoomToRect:(WebCore::FloatRect)targetRect withOrigin:(WebCore::FloatPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(float)minimumScrollDistance;
  • trunk/Source/WebKit/UIProcess/PageClient.h

    r242551 r242757  
    380380    virtual void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect, WebCore::RouteSharingPolicy, const String&) = 0;
    381381    virtual void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) = 0;
     382    virtual void handleSmartMagnificationInformationForPotentialTap(uint64_t requestID, const WebCore::FloatRect& renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale) = 0;
    382383    virtual double minimumZoomScale() const = 0;
    383384    virtual WebCore::FloatRect documentRect() const = 0;
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r242753 r242757  
    679679    void didCompleteSyntheticClick();
    680680    void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID);
     681    void handleSmartMagnificationInformationForPotentialTap(uint64_t requestID, const WebCore::FloatRect& renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale);
    681682    void contentSizeCategoryDidChange(const String& contentSizeCategory);
    682683    void getSelectionContext(WTF::Function<void(const String&, const String&, const String&, CallbackBase::Error)>&&);
     
    11791180    void willStartUserTriggeredZooming();
    11801181
    1181     void potentialTapAtPosition(const WebCore::FloatPoint&, uint64_t& requestID);
     1182    void potentialTapAtPosition(const WebCore::FloatPoint&, bool shouldRequestMagnificationInformation, uint64_t& requestID);
    11821183    void commitPotentialTap(OptionSet<WebKit::WebEvent::Modifier>, uint64_t layerTreeTransactionIdAtLastTouchStart);
    11831184    void cancelPotentialTap();
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r242753 r242757  
    196196    DidCompleteSyntheticClick()
    197197    DisableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID)
     198    HandleSmartMagnificationInformationForPotentialTap(uint64_t requestID, WebCore::FloatRect renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale)
    198199    DrawToPDFCallback(IPC::DataReference pdfData, WebKit::CallbackID callbackID)
    199200    SelectionRectsCallback(Vector<WebCore::SelectionRect> selectionRects, WebKit::CallbackID callbackID);
  • trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h

    r242551 r242757  
    162162   
    163163    void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) override;
     164    void handleSmartMagnificationInformationForPotentialTap(uint64_t requestID, const WebCore::FloatRect& renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale) override;
     165
    164166    double minimumZoomScale() const override;
    165167    WebCore::FloatRect documentRect() const override;
  • trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm

    r242551 r242757  
    239239}
    240240
     241void PageClientImpl::handleSmartMagnificationInformationForPotentialTap(uint64_t requestID, const WebCore::FloatRect& renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale)
     242{
     243    [m_contentView _handleSmartMagnificationInformationForPotentialTap:requestID renderRect:renderRect fitEntireRect:fitEntireRect viewportMinimumScale:viewportMinimumScale viewportMaximumScale:viewportMaximumScale];
     244}
     245
    241246double PageClientImpl::minimumZoomScale() const
    242247{
  • trunk/Source/WebKit/UIProcess/ios/SmartMagnificationController.h

    r241323 r242757  
    4949    void handleResetMagnificationGesture(WebCore::FloatPoint origin);
    5050
     51    double zoomFactorForTargetRect(WebCore::FloatRect targetRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale);
     52
    5153private:
    5254    // IPC::MessageReceiver.
     
    5658    void magnify(WebCore::FloatPoint origin, WebCore::FloatRect targetRect, WebCore::FloatRect visibleContentRect, double viewportMinimumScale, double viewportMaximumScale);
    5759    void scrollToRect(WebCore::FloatPoint origin, WebCore::FloatRect targetRect);
    58     void adjustSmartMagnificationTargetRectAndZoomScales(bool addMagnificationPadding, WebCore::FloatRect& targetRect, double& minimumScale, double& maximumScale);
     60    std::tuple<WebCore::FloatRect, double, double> smartMagnificationTargetRectAndZoomScales(WebCore::FloatRect targetRect, double minimumScale, double maximumScale, bool addMagnificationPadding);
    5961
    6062    WebPageProxy& m_webPageProxy;
  • trunk/Source/WebKit/UIProcess/ios/SmartMagnificationController.mm

    r241323 r242757  
    7777}
    7878
    79 void SmartMagnificationController::adjustSmartMagnificationTargetRectAndZoomScales(bool addMagnificationPadding, WebCore::FloatRect& targetRect, double& minimumScale, double& maximumScale)
     79std::tuple<FloatRect, double, double> SmartMagnificationController::smartMagnificationTargetRectAndZoomScales(FloatRect targetRect, double minimumScale, double maximumScale, bool addMagnificationPadding)
    8080{
     81    FloatRect outTargetRect = targetRect;
     82    double outMinimumScale = minimumScale;
     83    double outMaximumScale = maximumScale;
     84
    8185    if (addMagnificationPadding) {
    82         targetRect.inflateX(smartMagnificationElementPadding * targetRect.width());
    83         targetRect.inflateY(smartMagnificationElementPadding * targetRect.height());
     86        outTargetRect.inflateX(smartMagnificationElementPadding * outTargetRect.width());
     87        outTargetRect.inflateY(smartMagnificationElementPadding * outTargetRect.height());
    8488    }
    8589
    86     minimumScale = std::max(minimumScale, smartMagnificationMinimumScale);
    87     maximumScale = std::min(maximumScale, smartMagnificationMaximumScale);
     90    outMinimumScale = std::max(outMinimumScale, smartMagnificationMinimumScale);
     91    outMaximumScale = std::min(outMaximumScale, smartMagnificationMaximumScale);
     92
     93    return { outTargetRect, outMinimumScale, outMaximumScale };
     94}
     95
     96double SmartMagnificationController::zoomFactorForTargetRect(FloatRect targetRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale)
     97{
     98    // FIXME: Share some of this code with didCollectGeometryForSmartMagnificationGesture?
     99
     100    FloatRect adjustedTargetRect;
     101    double minimumScale = viewportMinimumScale;
     102    double maximumScale = viewportMaximumScale;
     103    std::tie(adjustedTargetRect, minimumScale, maximumScale) = smartMagnificationTargetRectAndZoomScales(targetRect, viewportMinimumScale, viewportMaximumScale, !fitEntireRect);
     104
     105    double currentScale = [m_contentView _contentZoomScale];
     106    double targetScale = [m_contentView _targetContentZoomScaleForRect:adjustedTargetRect currentScale:currentScale fitEntireRect:fitEntireRect minimumScale:minimumScale maximumScale:maximumScale];
     107
     108    if (targetScale == currentScale)
     109        targetScale = [m_contentView _initialScaleFactor];
     110
     111    return targetScale;
    88112}
    89113
     
    95119        return;
    96120    }
     121    FloatRect adjustedTargetRect;
    97122    double minimumScale = viewportMinimumScale;
    98123    double maximumScale = viewportMaximumScale;
    99     adjustSmartMagnificationTargetRectAndZoomScales(!fitEntireRect, targetRect, minimumScale, maximumScale);
     124    std::tie(adjustedTargetRect, minimumScale, maximumScale) = smartMagnificationTargetRectAndZoomScales(targetRect, viewportMinimumScale, viewportMaximumScale, !fitEntireRect);
    100125
    101126    // FIXME: Check if text selection wants to consume the double tap before we attempt magnification.
     
    114139    // in the view, so scale it down enough to make both dimensions fit if possible.
    115140    // For other elements, try to fit them horizontally.
    116     if ([m_contentView _zoomToRect:targetRect withOrigin:origin fitEntireRect:fitEntireRect minimumScale:minimumScale maximumScale:maximumScale minimumScrollDistance:minimumScrollDistance])
     141    if ([m_contentView _zoomToRect:adjustedTargetRect withOrigin:origin fitEntireRect:fitEntireRect minimumScale:minimumScale maximumScale:maximumScale minimumScrollDistance:minimumScrollDistance])
    117142        return;
    118143
     
    123148void SmartMagnificationController::magnify(FloatPoint origin, FloatRect targetRect, FloatRect visibleContentRect, double viewportMinimumScale, double viewportMaximumScale)
    124149{
     150    FloatRect adjustedTargetRect;
    125151    double maximumScale = viewportMaximumScale;
    126152    double minimumScale = viewportMinimumScale;
    127     adjustSmartMagnificationTargetRectAndZoomScales(true, targetRect, minimumScale, maximumScale);
    128     [m_contentView _zoomToRect:targetRect withOrigin:origin fitEntireRect:NO minimumScale:minimumScale maximumScale:maximumScale minimumScrollDistance:0];
     153    std::tie(adjustedTargetRect, minimumScale, maximumScale) = smartMagnificationTargetRectAndZoomScales(targetRect, viewportMinimumScale, viewportMaximumScale, true);
     154
     155    [m_contentView _zoomToRect:adjustedTargetRect withOrigin:origin fitEntireRect:NO minimumScale:minimumScale maximumScale:maximumScale minimumScrollDistance:0];
    129156}
    130157
  • trunk/Source/WebKit/UIProcess/ios/WKContentView.h

    r240139 r242757  
    3939
    4040namespace WebCore {
     41class FloatRect;
    4142struct Highlight;
    4243}
     
    109110- (void)_zoomOutWithOrigin:(CGPoint)origin;
    110111- (void)_zoomToInitialScaleWithOrigin:(CGPoint)origin;
     112- (double)_initialScaleFactor;
     113- (double)_contentZoomScale;
     114- (double)_targetContentZoomScaleForRect:(const WebCore::FloatRect&)targetRect currentScale:(double)currentScale fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale;
    111115
    112116@end
  • trunk/Source/WebKit/UIProcess/ios/WKContentView.mm

    r242339 r242757  
    642642}
    643643
     644- (double)_initialScaleFactor
     645{
     646    return [_webView _initialScaleFactor];
     647}
     648
     649- (double)_contentZoomScale
     650{
     651    return [_webView _contentZoomScale];
     652}
     653
     654- (double)_targetContentZoomScaleForRect:(const WebCore::FloatRect&)targetRect currentScale:(double)currentScale fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale
     655{
     656    return [_webView _targetContentZoomScaleForRect:targetRect currentScale:currentScale fitEntireRect:fitEntireRect minimumScale:minimumScale maximumScale:maximumScale];
     657}
     658
    644659- (void)_applicationWillResignActive:(NSNotification*)notification
    645660{
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h

    r242551 r242757  
    4444#import "WKKeyboardScrollingAnimator.h"
    4545#import "WKShareSheet.h"
    46 #import "WKSyntheticClickTapGestureRecognizer.h"
     46#import "WKSyntheticTapGestureRecognizer.h"
    4747#import "_WKFormInputSession.h"
    4848#import <UIKit/UIView.h>
     
    203203#endif
    204204
    205     RetainPtr<WKSyntheticClickTapGestureRecognizer> _singleTapGestureRecognizer;
     205    RetainPtr<WKSyntheticTapGestureRecognizer> _singleTapGestureRecognizer;
    206206    RetainPtr<_UIWebHighlightLongPressGestureRecognizer> _highlightLongPressGestureRecognizer;
    207207    RetainPtr<UILongPressGestureRecognizer> _longPressGestureRecognizer;
    208     RetainPtr<UITapGestureRecognizer> _doubleTapGestureRecognizer;
     208    RetainPtr<WKSyntheticTapGestureRecognizer> _doubleTapGestureRecognizer;
    209209    RetainPtr<UITapGestureRecognizer> _nonBlockingDoubleTapGestureRecognizer;
    210210    RetainPtr<UITapGestureRecognizer> _twoFingerDoubleTapGestureRecognizer;
     
    406406- (BOOL)_mayDisableDoubleTapGesturesDuringSingleTap;
    407407- (void)_disableDoubleTapGesturesDuringTapIfNecessary:(uint64_t)requestID;
     408- (void)_handleSmartMagnificationInformationForPotentialTap:(uint64_t)requestID renderRect:(const WebCore::FloatRect&)renderRect fitEntireRect:(BOOL)fitEntireRect viewportMinimumScale:(double)viewportMinimumScale viewportMaximumScale:(double)viewportMaximumScale;
    408409- (void)_elementDidFocus:(const WebKit::FocusedElementInformation&)information userIsInteracting:(BOOL)userIsInteracting blurPreviousNode:(BOOL)blurPreviousNode changingActivityState:(BOOL)changingActivityState userObject:(NSObject <NSSecureCoding> *)userObject;
    409410- (void)_elementDidBlur;
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r242695 r242757  
    229229} // namespace WebKit
    230230
    231 static const float highlightDelay = 0.12;
    232 static const float tapAndHoldDelay  = 0.75;
    233 const CGFloat minimumTapHighlightRadius = 2.0;
     231constexpr float highlightDelay = 0.12;
     232constexpr float tapAndHoldDelay = 0.75;
     233constexpr CGFloat minimumTapHighlightRadius = 2.0;
     234constexpr double fasterTapSignificantZoomThreshold = 0.8;
    234235
    235236@interface WKTextRange : UITextRange {
     
    646647- (void)_createAndConfigureDoubleTapGestureRecognizer
    647648{
    648     _doubleTapGestureRecognizer = adoptNS([[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_doubleTapRecognized:)]);
     649    _doubleTapGestureRecognizer = adoptNS([[WKSyntheticTapGestureRecognizer alloc] initWithTarget:self action:@selector(_doubleTapRecognized:)]);
     650    [_doubleTapGestureRecognizer setGestureFailedTarget:self action:@selector(_doubleTapDidFail:)];
    649651    [_doubleTapGestureRecognizer setNumberOfTapsRequired:2];
    650652    [_doubleTapGestureRecognizer setDelegate:self];
     
    695697#endif
    696698
    697     _singleTapGestureRecognizer = adoptNS([[WKSyntheticClickTapGestureRecognizer alloc] initWithTarget:self action:@selector(_singleTapCommited:)]);
     699    _singleTapGestureRecognizer = adoptNS([[WKSyntheticTapGestureRecognizer alloc] initWithTarget:self action:@selector(_singleTapRecognized:)]);
    698700    [_singleTapGestureRecognizer setDelegate:self];
    699     [_singleTapGestureRecognizer setGestureRecognizedTarget:self action:@selector(_singleTapRecognized:)];
     701    [_singleTapGestureRecognizer setGestureIdentifiedTarget:self action:@selector(_singleTapIdentified:)];
    700702    [_singleTapGestureRecognizer setResetTarget:self action:@selector(_singleTapDidReset:)];
    701703    [self addGestureRecognizer:_singleTapGestureRecognizer.get()];
     
    814816
    815817    [_singleTapGestureRecognizer setDelegate:nil];
    816     [_singleTapGestureRecognizer setGestureRecognizedTarget:nil action:nil];
     818    [_singleTapGestureRecognizer setGestureIdentifiedTarget:nil action:nil];
    817819    [_singleTapGestureRecognizer setResetTarget:nil action:nil];
    818820    [self removeGestureRecognizer:_singleTapGestureRecognizer.get()];
     
    14901492
    14911493    [self _setDoubleTapGesturesEnabled:NO];
     1494}
     1495
     1496- (void)_handleSmartMagnificationInformationForPotentialTap:(uint64_t)requestID renderRect:(const WebCore::FloatRect&)renderRect fitEntireRect:(BOOL)fitEntireRect viewportMinimumScale:(double)viewportMinimumScale viewportMaximumScale:(double)viewportMaximumScale
     1497{
     1498    ASSERT(_page->preferences().fasterClicksEnabled());
     1499    if (!_potentialTapInProgress)
     1500        return;
     1501
     1502    auto targetScale = _smartMagnificationController->zoomFactorForTargetRect(renderRect, fitEntireRect, viewportMinimumScale, viewportMaximumScale);
     1503
     1504    auto initialScale = [self _initialScaleFactor];
     1505    if (std::min(targetScale, initialScale) / std::max(targetScale, initialScale) > fasterTapSignificantZoomThreshold) {
     1506        RELEASE_LOG(ViewGestures, "Potential tap would not cause a significant zoom. Trigger click. (%p)", self);
     1507        [self _setDoubleTapGesturesEnabled:NO];
     1508        return;
     1509    }
     1510    RELEASE_LOG(ViewGestures, "Potential tap may cause significant zoom. Wait. (%p)", self);
    14921511}
    14931512
     
    21772196}
    21782197
    2179 - (void)_singleTapRecognized:(UITapGestureRecognizer *)gestureRecognizer
     2198- (void)_singleTapIdentified:(UITapGestureRecognizer *)gestureRecognizer
    21802199{
    21812200    ASSERT(gestureRecognizer == _singleTapGestureRecognizer);
     
    21832202    [self _resetIsDoubleTapPending];
    21842203
    2185     _page->potentialTapAtPosition(gestureRecognizer.location, ++_latestTapID);
     2204    bool shouldRequestMagnificationInformation = _page->preferences().fasterClicksEnabled();
     2205    if (shouldRequestMagnificationInformation)
     2206        RELEASE_LOG(ViewGestures, "Single tap identified. Request details on potential zoom. (%p)", self);
     2207
     2208    _page->potentialTapAtPosition(gestureRecognizer.location, shouldRequestMagnificationInformation, ++_latestTapID);
    21862209    _potentialTapInProgress = YES;
    21872210    _isTapHighlightIDValid = YES;
     
    22022225    ASSERT(gestureRecognizer == _singleTapGestureRecognizer);
    22032226    cancelPotentialTapIfNecessary(self);
     2227}
     2228
     2229- (void)_doubleTapDidFail:(UITapGestureRecognizer *)gestureRecognizer
     2230{
     2231    RELEASE_LOG(ViewGestures, "Double tap was not recognized. (%p)", self);
     2232    ASSERT(gestureRecognizer == _doubleTapGestureRecognizer);
    22042233}
    22052234
     
    22332262- (void)_didCompleteSyntheticClick
    22342263{
     2264    RELEASE_LOG(ViewGestures, "Synthetic click completed. (%p)", self);
    22352265    [self _resetInputViewDeferral];
    22362266}
    22372267
    2238 - (void)_singleTapCommited:(UITapGestureRecognizer *)gestureRecognizer
     2268- (void)_singleTapRecognized:(UITapGestureRecognizer *)gestureRecognizer
    22392269{
    22402270    ASSERT(gestureRecognizer == _singleTapGestureRecognizer);
     
    22612291
    22622292    [_inputPeripheral endEditing];
     2293
     2294    RELEASE_LOG(ViewGestures, "Single tap recognized - commit potential tap (%p)", self);
     2295
    22632296    _page->commitPotentialTap(WebKit::webEventModifierFlags(gestureRecognizerModifierFlags(gestureRecognizer)), _layerTreeTransactionIdAtLastTouchStart);
    22642297
     
    22692302- (void)_doubleTapRecognized:(UITapGestureRecognizer *)gestureRecognizer
    22702303{
     2304    RELEASE_LOG(ViewGestures, "Identified a double tap (%p)", self);
     2305
    22712306    [self _resetIsDoubleTapPending];
    22722307    _lastInteractionLocation = gestureRecognizer.location;
  • trunk/Source/WebKit/UIProcess/ios/WKSyntheticTapGestureRecognizer.h

    • Property svn:eol-style set to native
    • Property svn:keywords set to Date Author Id Revision HeadURL
    r242756 r242757  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014 - 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828#import "UIKitSPI.h"
    2929
    30 @interface WKSyntheticClickTapGestureRecognizer : UITapGestureRecognizer
    31 - (void)setGestureRecognizedTarget:(id)target action:(SEL)action;
     30// The purpose of this class is to call a target/action when
     31// the gesture is recognized, as well as the typical time when
     32// a gesture should be handled. This allows it to be used while
     33// it is waiting for another gesture recognizer to fail.
     34@interface WKSyntheticTapGestureRecognizer : UITapGestureRecognizer
     35- (void)setGestureIdentifiedTarget:(id)target action:(SEL)action;
     36- (void)setGestureFailedTarget:(id)target action:(SEL)action;
    3237- (void)setResetTarget:(id)target action:(SEL)action;
    3338@end
  • trunk/Source/WebKit/UIProcess/ios/WKSyntheticTapGestureRecognizer.m

    r242756 r242757  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014 - 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626#import "config.h"
    27 #import "WKSyntheticClickTapGestureRecognizer.h"
     27#import "WKSyntheticTapGestureRecognizer.h"
    2828
    2929#if PLATFORM(IOS_FAMILY)
     
    3131#import <UIKit/UIGestureRecognizerSubclass.h>
    3232
    33 @implementation WKSyntheticClickTapGestureRecognizer {
    34     id _gestureRecognizedTarget;
    35     SEL _gestureRecognizedAction;
     33@implementation WKSyntheticTapGestureRecognizer {
     34    id _gestureIdentifiedTarget;
     35    SEL _gestureIdentifiedAction;
     36    id _gestureFailedTarget;
     37    SEL _gestureFailedAction;
    3638    id _resetTarget;
    3739    SEL _resetAction;
    3840}
    3941
    40 - (void)setGestureRecognizedTarget:(id)target action:(SEL)action
     42- (void)setGestureIdentifiedTarget:(id)target action:(SEL)action
    4143{
    42     _gestureRecognizedTarget = target;
    43     _gestureRecognizedAction = action;
     44    _gestureIdentifiedTarget = target;
     45    _gestureIdentifiedAction = action;
     46}
     47
     48- (void)setGestureFailedTarget:(id)target action:(SEL)action
     49{
     50    _gestureFailedTarget = target;
     51    _gestureFailedAction = action;
    4452}
    4553
     
    5361{
    5462    if (state == UIGestureRecognizerStateEnded)
    55         [_gestureRecognizedTarget performSelector:_gestureRecognizedAction withObject:self];
     63        [_gestureIdentifiedTarget performSelector:_gestureIdentifiedAction withObject:self];
     64    else if (state == UIGestureRecognizerStateFailed)
     65        [_gestureFailedTarget performSelector:_gestureFailedAction withObject:self];
    5666    [super setState:state];
    5767}
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r242748 r242757  
    813813}
    814814
    815 void WebPageProxy::potentialTapAtPosition(const WebCore::FloatPoint& position, uint64_t& requestID)
     815void WebPageProxy::potentialTapAtPosition(const WebCore::FloatPoint& position, bool shouldRequestMagnificationInformation, uint64_t& requestID)
    816816{
    817817    hideValidationMessage();
    818     process().send(Messages::WebPage::PotentialTapAtPosition(requestID, position), m_pageID);
     818    process().send(Messages::WebPage::PotentialTapAtPosition(requestID, position, shouldRequestMagnificationInformation), m_pageID);
    819819}
    820820
     
    10311031{
    10321032    pageClient().disableDoubleTapGesturesDuringTapIfNecessary(requestID);
     1033}
     1034
     1035void WebPageProxy::handleSmartMagnificationInformationForPotentialTap(uint64_t requestID, const WebCore::FloatRect& renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale)
     1036{
     1037    pageClient().handleSmartMagnificationInformationForPotentialTap(requestID, renderRect, fitEntireRect, viewportMinimumScale, viewportMaximumScale);
    10331038}
    10341039
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r242748 r242757  
    416416                2684055218B86ED60022C38B /* ViewUpdateDispatcherMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2684055018B86ED60022C38B /* ViewUpdateDispatcherMessageReceiver.cpp */; };
    417417                2684055318B86ED60022C38B /* ViewUpdateDispatcherMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 2684055118B86ED60022C38B /* ViewUpdateDispatcherMessages.h */; };
    418                 26F10BE819187E2E001D0E68 /* WKSyntheticClickTapGestureRecognizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 26F10BE619187E2E001D0E68 /* WKSyntheticClickTapGestureRecognizer.h */; };
    419                 26F10BE919187E2E001D0E68 /* WKSyntheticClickTapGestureRecognizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 26F10BE719187E2E001D0E68 /* WKSyntheticClickTapGestureRecognizer.m */; };
     418                26F10BE819187E2E001D0E68 /* WKSyntheticTapGestureRecognizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 26F10BE619187E2E001D0E68 /* WKSyntheticTapGestureRecognizer.h */; };
     419                26F10BE919187E2E001D0E68 /* WKSyntheticTapGestureRecognizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 26F10BE719187E2E001D0E68 /* WKSyntheticTapGestureRecognizer.m */; };
    420420                26F9A83B18A3468100AEB88A /* WKWebViewPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 26F9A83A18A3463F00AEB88A /* WKWebViewPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
    421421                2749F6442146561B008380BF /* InjectedBundleNodeHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC4BEEAA120A0A5F00FBA0C7 /* InjectedBundleNodeHandle.cpp */; };
     
    24462446                2684055018B86ED60022C38B /* ViewUpdateDispatcherMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ViewUpdateDispatcherMessageReceiver.cpp; path = DerivedSources/WebKit2/ViewUpdateDispatcherMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
    24472447                2684055118B86ED60022C38B /* ViewUpdateDispatcherMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ViewUpdateDispatcherMessages.h; path = DerivedSources/WebKit2/ViewUpdateDispatcherMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
    2448                 26F10BE619187E2E001D0E68 /* WKSyntheticClickTapGestureRecognizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKSyntheticClickTapGestureRecognizer.h; path = ios/WKSyntheticClickTapGestureRecognizer.h; sourceTree = "<group>"; };
    2449                 26F10BE719187E2E001D0E68 /* WKSyntheticClickTapGestureRecognizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WKSyntheticClickTapGestureRecognizer.m; path = ios/WKSyntheticClickTapGestureRecognizer.m; sourceTree = "<group>"; };
     2448                26F10BE619187E2E001D0E68 /* WKSyntheticTapGestureRecognizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKSyntheticTapGestureRecognizer.h; path = ios/WKSyntheticTapGestureRecognizer.h; sourceTree = "<group>"; };
     2449                26F10BE719187E2E001D0E68 /* WKSyntheticTapGestureRecognizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WKSyntheticTapGestureRecognizer.m; path = ios/WKSyntheticTapGestureRecognizer.m; sourceTree = "<group>"; };
    24502450                26F9A83A18A3463F00AEB88A /* WKWebViewPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWebViewPrivate.h; sourceTree = "<group>"; };
    24512451                290F4271172A0C7400939FF0 /* AuxiliaryProcessSupplement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AuxiliaryProcessSupplement.h; sourceTree = "<group>"; };
     
    59055905                                0FCB4E4418BBE044000FCFC9 /* WKScrollView.h */,
    59065906                                0FCB4E4518BBE044000FCFC9 /* WKScrollView.mm */,
    5907                                 26F10BE619187E2E001D0E68 /* WKSyntheticClickTapGestureRecognizer.h */,
    5908                                 26F10BE719187E2E001D0E68 /* WKSyntheticClickTapGestureRecognizer.m */,
    59095907                                CE5B4C8621B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.h */,
    59105908                                CE5B4C8721B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.mm */,
     5909                                26F10BE619187E2E001D0E68 /* WKSyntheticTapGestureRecognizer.h */,
     5910                                26F10BE719187E2E001D0E68 /* WKSyntheticTapGestureRecognizer.m */,
    59115911                                316B8B622054B55800BD4A62 /* WKSystemPreviewView.h */,
    59125912                                316B8B612054B55800BD4A62 /* WKSystemPreviewView.mm */,
     
    99659965                                BC40761A124FF0370068F20A /* WKStringCF.h in Headers */,
    99669966                                BC9099801256A98200083756 /* WKStringPrivate.h in Headers */,
    9967                                 26F10BE819187E2E001D0E68 /* WKSyntheticClickTapGestureRecognizer.h in Headers */,
    99689967                                CE5B4C8821B73D870022E64F /* WKSyntheticFlagsChangedWebEvent.h in Headers */,
     9968                                26F10BE819187E2E001D0E68 /* WKSyntheticTapGestureRecognizer.h in Headers */,
    99699969                                316B8B642054B55800BD4A62 /* WKSystemPreviewView.h in Headers */,
    99709970                                51F886A61F2C228100C193EF /* WKTestingSupport.h in Headers */,
     
    1116811168                                5CA26D83217AD1B800F97A35 /* WKSafeBrowsingWarning.mm in Sources */,
    1116911169                                1DB01944211CF005009FB3E8 /* WKShareSheet.mm in Sources */,
    11170                                 26F10BE919187E2E001D0E68 /* WKSyntheticClickTapGestureRecognizer.m in Sources */,
     11170                                26F10BE919187E2E001D0E68 /* WKSyntheticTapGestureRecognizer.m in Sources */,
    1117111171                        );
    1117211172                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/WebKit/WebProcess/WebPage/ViewGestureGeometryCollector.h

    r241224 r242757  
    4747    void mainFrameDidLayout();
    4848
     49    void computeZoomInformationForNode(WebCore::Node&, WebCore::FloatPoint& origin, WebCore::FloatRect& renderRect, bool& isReplaced, double& viewportMinimumScale, double& viewportMaximumScale);
     50
    4951private:
    5052    // IPC::MessageReceiver.
     
    6365
    6466    void dispatchDidCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect targetRect, WebCore::FloatRect visibleContentRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale);
    65     void computeZoomInformationForNode(WebCore::Node&, WebCore::FloatPoint& origin, WebCore::FloatRect& renderRect, bool& isReplaced, double& viewportMinimumScale, double& viewportMaximumScale);
    6667    void computeMinimumAndMaximumViewportScales(double& viewportMinimumScale, double& viewportMaximumScale) const;
    6768
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r242753 r242757  
    615615
    616616    void handleTap(const WebCore::IntPoint&, OptionSet<WebKit::WebEvent::Modifier>, uint64_t lastLayerTreeTransactionId);
    617     void potentialTapAtPosition(uint64_t requestID, const WebCore::FloatPoint&);
     617    void potentialTapAtPosition(uint64_t requestID, const WebCore::FloatPoint&, bool shouldRequestMagnificationInformation);
    618618    void commitPotentialTap(OptionSet<WebKit::WebEvent::Modifier>, uint64_t lastLayerTreeTransactionId);
    619619    void commitPotentialTapFailed();
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r242696 r242757  
    5353
    5454    HandleTap(WebCore::IntPoint point, OptionSet<WebKit::WebEvent::Modifier> modifiers, uint64_t lastLayerTreeTransactionId)
    55     PotentialTapAtPosition(uint64_t requestID, WebCore::FloatPoint point)
     55    PotentialTapAtPosition(uint64_t requestID, WebCore::FloatPoint point, bool shouldRequestMagnificationInformation)
    5656    CommitPotentialTap(OptionSet<WebKit::WebEvent::Modifier> modifiers, uint64_t lastLayerTreeTransactionId)
    5757    CancelPotentialTap()
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r242675 r242757  
    4444#import "UIKitSPI.h"
    4545#import "UserData.h"
     46#import "ViewGestureGeometryCollector.h"
    4647#import "VisibleContentRectUpdateInfo.h"
    4748#import "WKAccessibilityWebPageObjectIOS.h"
     
    809810}
    810811
    811 void WebPage::potentialTapAtPosition(uint64_t requestID, const WebCore::FloatPoint& position)
     812void WebPage::potentialTapAtPosition(uint64_t requestID, const WebCore::FloatPoint& position, bool shouldRequestMagnificationInformation)
    812813{
    813814    m_potentialTapNode = m_page->mainFrame().nodeRespondingToClickEvents(position, m_potentialTapLocation, m_potentialTapSecurityOrigin.get());
     815
     816    if (shouldRequestMagnificationInformation && m_potentialTapNode && m_viewGestureGeometryCollector) {
     817        // FIXME: Could this be combined into tap highlight?
     818        FloatPoint origin = position;
     819        FloatRect renderRect;
     820        bool fitEntireRect;
     821        double viewportMinimumScale;
     822        double viewportMaximumScale;
     823
     824        m_viewGestureGeometryCollector->computeZoomInformationForNode(*m_potentialTapNode, origin, renderRect, fitEntireRect, viewportMinimumScale, viewportMaximumScale);
     825        send(Messages::WebPageProxy::HandleSmartMagnificationInformationForPotentialTap(requestID, renderRect, fitEntireRect, viewportMinimumScale, viewportMaximumScale));
     826    }
     827
    814828    sendTapHighlightForNodeIfNecessary(requestID, m_potentialTapNode.get());
    815829#if ENABLE(TOUCH_EVENTS)
Note: See TracChangeset for help on using the changeset viewer.