Changeset 249431 in webkit


Ignore:
Timestamp:
Sep 3, 2019 9:38:09 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

[iOS] Treat a two-finger single tap as if the user tapped with the Cmd key pressed
https://bugs.webkit.org/show_bug.cgi?id=201420
<rdar://problem/53207786>

Patch by Antoine Quint <Antoine Quint> on 2019-09-03
Reviewed by Simon Fraser.

Source/WebKit:

Set the metaKey modifier to true when generating a click event based on a two-finger single tap. This is important so that sites like Google and DuckDuckGo
correctly open links in their search results page in a new tab in Safari on iOS. This currently doesn't work because those sites will call preventDefault()
if the metaKey flag isn't set on a "click" event, and if it is set, they let the browser handle the navigation themselves.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _twoFingerSingleTapGestureRecognized:]):

Tools:

Add a new twoFingerSingleTapAtPoint() method to UIScriptController, which just calls into the existing (but unused)
-[HIDEventGenerator twoFingerTap:completionBlock:].

  • TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
  • TestRunnerShared/UIScriptContext/UIScriptController.h:

(WTR::UIScriptController::twoFingerSingleTapAtPoint):

  • WebKitTestRunner/ios/UIScriptControllerIOS.h:
  • WebKitTestRunner/ios/UIScriptControllerIOS.mm:

(WTR::UIScriptControllerIOS::twoFingerSingleTapAtPoint):

LayoutTests:

Add a new event that checks that a two-finger single tap on a clickable element yields a "click" event with the metaKey flag set to true.

  • fast/events/ios/click-event-two-finger-single-tap-meta-key-expected.txt: Added.
  • fast/events/ios/click-event-two-finger-single-tap-meta-key.html: Added.
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r249426 r249431  
     12019-09-03  Antoine Quint  <graouts@apple.com>
     2
     3        [iOS] Treat a two-finger single tap as if the user tapped with the Cmd key pressed
     4        https://bugs.webkit.org/show_bug.cgi?id=201420
     5        <rdar://problem/53207786>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Add a new event that checks that a two-finger single tap on a clickable element yields a "click" event with the metaKey flag set to true.
     10
     11        * fast/events/ios/click-event-two-finger-single-tap-meta-key-expected.txt: Added.
     12        * fast/events/ios/click-event-two-finger-single-tap-meta-key.html: Added.
     13
    1142019-09-03  Rob Buis  <rbuis@igalia.com>
    215
  • trunk/Source/WebKit/ChangeLog

    r249430 r249431  
     12019-09-03  Antoine Quint  <graouts@apple.com>
     2
     3        [iOS] Treat a two-finger single tap as if the user tapped with the Cmd key pressed
     4        https://bugs.webkit.org/show_bug.cgi?id=201420
     5        <rdar://problem/53207786>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Set the metaKey modifier to true when generating a click event based on a two-finger single tap. This is important so that sites like Google and DuckDuckGo
     10        correctly open links in their search results page in a new tab in Safari on iOS. This currently doesn't work because those sites will call preventDefault()
     11        if the metaKey flag isn't set on a "click" event, and if it is set, they let the browser handle the navigation themselves.
     12
     13        * UIProcess/ios/WKContentViewInteraction.mm:
     14        (-[WKContentView _twoFingerSingleTapGestureRecognized:]):
     15
    1162019-08-28  Brent Fulgham  <bfulgham@apple.com>
    217
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r249368 r249431  
    24042404    _isTapHighlightIDValid = YES;
    24052405    _isExpectingFastSingleTapCommit = YES;
    2406     _page->handleTwoFingerTapAtPoint(WebCore::roundedIntPoint(gestureRecognizer.centroid), WebKit::webEventModifierFlags(gestureRecognizerModifierFlags(gestureRecognizer)), ++_latestTapID);
     2406    _page->handleTwoFingerTapAtPoint(WebCore::roundedIntPoint(gestureRecognizer.centroid), WebKit::webEventModifierFlags(gestureRecognizerModifierFlags(gestureRecognizer) | UIKeyModifierCommand), ++_latestTapID);
    24072407}
    24082408
  • trunk/Tools/ChangeLog

    r249425 r249431  
     12019-09-03  Antoine Quint  <graouts@apple.com>
     2
     3        [iOS] Treat a two-finger single tap as if the user tapped with the Cmd key pressed
     4        https://bugs.webkit.org/show_bug.cgi?id=201420
     5        <rdar://problem/53207786>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Add a new twoFingerSingleTapAtPoint() method to UIScriptController, which just calls into the existing (but unused)
     10        -[HIDEventGenerator twoFingerTap:completionBlock:].
     11
     12        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
     13        * TestRunnerShared/UIScriptContext/UIScriptController.h:
     14        (WTR::UIScriptController::twoFingerSingleTapAtPoint):
     15        * WebKitTestRunner/ios/UIScriptControllerIOS.h:
     16        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
     17        (WTR::UIScriptControllerIOS::twoFingerSingleTapAtPoint):
     18
    1192019-09-03  Zan Dobersek  <zdobersek@igalia.com>
    220
  • trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl

    r249125 r249431  
    6060    void singleTapAtPoint(long x, long y, object callback);
    6161    void singleTapAtPointWithModifiers(long x, long y, object modifierArray, object callback);
     62    void twoFingerSingleTapAtPoint(long x, long y, object callback);
    6263    void doubleTapAtPoint(long x, long y, float delay, object callback);
    6364    void dragFromPointToPoint(long startX, long startY, long endX, long endY, double durationSeconds, object callback);
  • trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h

    r249125 r249431  
    138138    virtual void singleTapAtPoint(long x, long y, JSValueRef callback) { notImplemented(); }
    139139    virtual void singleTapAtPointWithModifiers(long x, long y, JSValueRef modifierArray, JSValueRef callback) { notImplemented(); }
     140    virtual void twoFingerSingleTapAtPoint(long x, long y, JSValueRef callback) { notImplemented(); }
    140141    virtual void doubleTapAtPoint(long x, long y, float delay, JSValueRef callback) { notImplemented(); }
    141142    virtual void dragFromPointToPoint(long startX, long startY, long endX, long endY, double durationSeconds, JSValueRef callback) { notImplemented(); }
  • trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h

    r249125 r249431  
    5454    void singleTapAtPoint(long x, long y, JSValueRef) override;
    5555    void singleTapAtPointWithModifiers(long x, long y, JSValueRef modifierArray, JSValueRef) override;
     56    void twoFingerSingleTapAtPoint(long x, long y, JSValueRef callback) override;
    5657    void doubleTapAtPoint(long x, long y, float delay, JSValueRef) override;
    5758    void stylusDownAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef) override;
  • trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

    r249125 r249431  
    273273}
    274274
     275void UIScriptControllerIOS::twoFingerSingleTapAtPoint(long x, long y, JSValueRef callback)
     276{
     277    unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);
     278
     279    auto location = globalToContentCoordinates(webView(), x, y);
     280    [[HIDEventGenerator sharedHIDEventGenerator] twoFingerTap:location completionBlock:^{
     281        if (!m_context)
     282            return;
     283        m_context->asyncTaskComplete(callbackID);
     284    }];
     285}
     286
    275287void UIScriptControllerIOS::singleTapAtPointWithModifiers(long x, long y, JSValueRef modifierArray, JSValueRef callback)
    276288{
Note: See TracChangeset for help on using the changeset viewer.