Changeset 265088 in webkit


Ignore:
Timestamp:
Jul 30, 2020 10:12:33 AM (4 years ago)
Author:
graouts@webkit.org
Message:

[iOS] Unable to swipe on IMDB.com after long press on image
https://bugs.webkit.org/show_bug.cgi?id=214968
<rdar://problem/66234421>

Reviewed by Wenson Hsieh.

Source/WebCore:

When a long press occurs on an <img>, a system drag interaction is initiated on iOS. In WebCore,
EventHandler::tryToBeginDragAtPoint() is called and a synthetic mouse event is produced, causing
handleMousePressEvent() to be called. Further down the call chain, dispatchPointerEventIfNeeded()
is called and a valid PointerEvent is generated in PointerCaptureController::pointerEventForMouseEvent()
with "pointerType" set to "mouse", even though there is already a touch interaction initiated.

We now check whether there are known touches before generating a PointerEvent for a MouseEvent.

In the case of IMDb, the page would keep track of "pointerdown" events to track whether a multi-touch
user gesture is in progress so that their slide shows can support two-finger zooming as well as
single-finger swiping. In the case of a long press, the second "pointerdown" event would trick
the code in thinking a zoom gesture was initiated and it never recovered.

Test: pointerevents/ios/long-press-yields-single-pointerdown-event.html

  • page/PointerCaptureController.cpp:

(WebCore::PointerCaptureController::pointerEventForMouseEvent):

LayoutTests:

Add a test that triggers a long press gesture on an <img> and checks a single "pointerdown" event
was dispatched. Prior to the WebCore change in this patch, two events would be dispatched.

  • pointerevents/ios/long-press-yields-single-pointerdown-event-expected.txt: Added.
  • pointerevents/ios/long-press-yields-single-pointerdown-event.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r265083 r265088  
     12020-07-30  Antoine Quint  <graouts@webkit.org>
     2
     3        [iOS] Unable to swipe on IMDB.com after long press on image
     4        https://bugs.webkit.org/show_bug.cgi?id=214968
     5        <rdar://problem/66234421>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        Add a test that triggers a long press gesture on an <img> and checks a single "pointerdown" event
     10        was dispatched. Prior to the WebCore change in this patch, two events would be dispatched.
     11
     12        * pointerevents/ios/long-press-yields-single-pointerdown-event-expected.txt: Added.
     13        * pointerevents/ios/long-press-yields-single-pointerdown-event.html: Added.
     14
    1152020-07-30  Hector Lopez  <hector_i_lopez@apple.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r265086 r265088  
     12020-07-30  Antoine Quint  <graouts@webkit.org>
     2
     3        [iOS] Unable to swipe on IMDB.com after long press on image
     4        https://bugs.webkit.org/show_bug.cgi?id=214968
     5        <rdar://problem/66234421>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        When a long press occurs on an <img>, a system drag interaction is initiated on iOS. In WebCore,
     10        EventHandler::tryToBeginDragAtPoint() is called and a synthetic mouse event is produced, causing
     11        handleMousePressEvent() to be called. Further down the call chain, dispatchPointerEventIfNeeded()
     12        is called and a valid PointerEvent is generated in PointerCaptureController::pointerEventForMouseEvent()
     13        with "pointerType" set to "mouse", even though there is already a touch interaction initiated.
     14
     15        We now check whether there are known touches before generating a PointerEvent for a MouseEvent.
     16
     17        In the case of IMDb, the page would keep track of "pointerdown" events to track whether a multi-touch
     18        user gesture is in progress so that their slide shows can support two-finger zooming as well as
     19        single-finger swiping. In the case of a long press, the second "pointerdown" event would trick
     20        the code in thinking a zoom gesture was initiated and it never recovered.
     21
     22        Test: pointerevents/ios/long-press-yields-single-pointerdown-event.html
     23
     24        * page/PointerCaptureController.cpp:
     25        (WebCore::PointerCaptureController::pointerEventForMouseEvent):
     26
    1272020-07-30  Chris Dumez  <cdumez@apple.com>
    228
  • trunk/Source/WebCore/page/PointerCaptureController.cpp

    r261961 r265088  
    302302RefPtr<PointerEvent> PointerCaptureController::pointerEventForMouseEvent(const MouseEvent& mouseEvent)
    303303{
     304    // If we already have known touches then we cannot dispatch a mouse event,
     305    // for instance in the case of a long press to initiate a system drag.
     306    for (auto& capturingData : m_activePointerIdsToCapturingData.values()) {
     307        if (capturingData.pointerType != PointerEvent::mousePointerType())
     308            return nullptr;
     309    }
     310
    304311    const auto& type = mouseEvent.type();
    305312    const auto& names = eventNames();
Note: See TracChangeset for help on using the changeset viewer.