[AppKit Gestures] Double clicking a YouTube video pauses it - #75624
Conversation
|
EWS run on previous version of this PR (hash f5628fe) Details |
| if (protect([webView _impl])->ignoresAllEvents()) | ||
| return; | ||
|
|
||
| auto location = [gesture locationInView:webView]; | ||
| auto location = [_domDoubleClickGestureRecognizer locationInView:webView]; |
There was a problem hiding this comment.
Nit - do we need to protect _domDoubleClickGestureRecognizer on the stack, as gesture?
There was a problem hiding this comment.
good point. Yes, probably, given -locationInView: is non-trivial
| @@ -3449,6 +3450,16 @@ static void dispatchSyntheticMouseMove(LocalFrame& localFrame, const WebCore::Fl | |||
|
|
|||
| Awaitable<std::optional<WebCore::FrameIdentifier>> WebPage::commitPotentialTap(std::optional<WebCore::FrameIdentifier> frameID, OptionSet<WebEventModifier> modifiers, TransactionID lastLayerTreeTransactionId, WebCore::PointerID pointerId) | |||
| { | |||
| if (std::exchange(m_syntheticClickWasHandledAsDoubleClick, false)) { | |||
There was a problem hiding this comment.
I think this can drop a click that was delivered before this change because the commit is suppressed whenever a double click was sent anywhere, but the double click and the single click don't necessarily target the same node (for example elements within the 15px radius of each other)
There was a problem hiding this comment.
Yes, good catch. I fixed it with your suggestion below.
| @@ -1626,6 +1638,10 @@ - (void)_handleClickEnded:(NSGestureRecognizer *)gesture | |||
| return; | |||
| } | |||
|
|
|||
| // If this click completes a double click, send the double click first. The web process then only delivers this | |||
There was a problem hiding this comment.
Rather than sending both HandleDoubleClickForDoubleClickAtPoint and CommitPotentialClick and then deduplicating them with a flag the web process, maybe instead just send a single message, like CommitPotentialClick(…, isDoubleClick), and let a single handler choose between double-click and single-click dispatch?
There was a problem hiding this comment.
Done.
I added a CompletesDoubleClick value that we use as a signal in the web process.
|
EWS run on previous version of this PR (hash fe93eb6) Details |
|
EWS run on current version of this PR (hash a386f15) Details |
|
Thank you for the reviews! |
a386f15 to
634092e
Compare
https://bugs.webkit.org/show_bug.cgi?id=325977 rdar://187488912 Reviewed by Wenson Hsieh. We have a bug where a double click sequence produces this sequence: { click, click, dblclick, click }. Thus, content that toggles per click, such as the youtube.com video player, ends up in the wrong state after a double click sequence. Typically, the gesture that sends the double click would not recognize simultaneously with the single click gesture, so exactly one of them handles the second click. However, NSGestureRecognizer holds back events from other gestures while one that requires two clicks is pending (see 319115@main and rdar://184563102), and so we cannot establish the appropriate simultaneity relation between the two gestures. Instead, in this patch, we send the double click eagerly before committing to it, and we have the web process skip the click when it dispatches the double click. Some more details in-line. Instead, in this patch, when the second click completes a double click, we reflect that in the synthetic click commit: the web process dispatches it with a click count of 2 (a click with detail 2, followed by a dblclick) to the node the single click targets, if a dblclick listener can receive it there, and as a regular click otherwise. The second click is then delivered once, and to the same node either way. Test: AppKitGesturesTests.DoubleClick.doubleClickWithListenerOnUnselectableContentFiresOneClickPerPress AppKitGesturesTests.DoubleClick.doubleClickWithoutListenerOnUnselectableContentFiresTwoSingleClicks AppKitGesturesTests.DoubleClick.doubleClickWithAncestorListenerOnStyleAdjustedContentFiresOneClickPerPress AppKitGesturesTests.DoubleClick.doubleClickNextToClickableElementTargetsItWithBothClicks * Source/WebKit/Scripts/webkit/messages.py: (headers_for_type): * Source/WebKit/Shared/Cocoa/GestureTypes.h: * Source/WebKit/Shared/Cocoa/GestureTypes.serialization.in: * Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm: (WebKit::WebPageProxy::commitPotentialTap): * Source/WebKit/UIProcess/WebPageProxy.h: * Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _singleTapRecognized:]): * Source/WebKit/UIProcess/mac/AppKitGestures/WKAppKitGestureController.h: * Source/WebKit/UIProcess/mac/AppKitGestures/WKAppKitGestureController.mm: (-[WKAppKitGestureController domDoubleClickGestureRecognized:]): (-[WKAppKitGestureController _handleClickEnded:]): * Source/WebKit/UIProcess/mac/AppKitGestures/WKAppKitGestureController.swift: (WKAppKitGestureController.takeCompletedDOMDoubleClick): * Source/WebKit/UIProcess/mac/AppKitGestures/WKDOMDoubleClickGestureRecognizer.swift: (state): (reset): (takeCompletedDoubleClick): The two click gestures' actions for a second click can come in either order, and when the single click gesture's comes first, the DOM double click gesture's state does not reflect the double click yet. So, we now record whether a click completed a double click as soon as the click ends, and whichever action comes first sends the double click. * Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm: (WebKit::WebPage::commitPotentialTap): (WebKit::WebPage::completeSyntheticClick): * Source/WebKit/WebProcess/WebPage/WebPage.h: * Source/WebKit/WebProcess/WebPage/WebPage.messages.in: * Tools/TestWebKitAPI/Tests/WebKit/WebPage/AppKit Gesture Tests/DoubleClickGesturesTests.swift: (AppKitGesturesTests.doubleClickWithListenerOnUnselectableContentFiresOneClickPerPress): (AppKitGesturesTests.doubleClickWithoutListenerOnUnselectableContentFiresTwoSingleClicks): (AppKitGesturesTests.doubleClickWithAncestorListenerOnStyleAdjustedContentFiresOneClickPerPress): (AppKitGesturesTests.doubleClickNextToClickableElementTargetsItWithBothClicks): (AppKitGesturesTests.loadUnselectableHTML(_:)): Canonical link: https://commits.webkit.org/322530@main
634092e to
5863297
Compare
|
Committed 322530@main (5863297): https://commits.webkit.org/322530@main Reviewed commits have been landed. Closing PR #75624 and removing active labels. |
5863297
a386f15
🛠 ios🛠 mac🛠 win🧪 wpe-wk2🧪 win-tests🧪 ios-wk2🧪 api-mac🧪 api-ios🧪 mac-wk2🛠 ios-safer-cpp🧪 mac-AS-debug-wk2🧪 mac-wk2-stress🧪 gtk-wk2🛠 vision-sim🧪 mac-intel-wk2🧪 api-gtk🧪 vision-wk2🛠 mac-safer-cpp🧪 mac-site-isolation🛠 tv-sim🛠 watch