Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 54f983fffa579931c6ae07460a6c20835818d524
      
https://github.com/WebKit/WebKit/commit/54f983fffa579931c6ae07460a6c20835818d524
  Author: Lily Spiniolas <[email protected]>
  Date:   2025-09-18 (Thu, 18 Sep 2025)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_lostpointercapture_for_disconnected_node-expected.txt
    A 
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_lostpointercapture_for_disconnected_node-expected.txt
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/EventDispatcher.cpp
    M Source/WebCore/page/ChromeClient.h
    M Source/WebCore/page/PointerCaptureController.cpp
    M Source/WebCore/page/PointerCaptureController.h
    M Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h

  Log Message:
  -----------
  `lostpointercapture` may not be fired before other subsequent events for the 
pointer after capture is lost
https://bugs.webkit.org/show_bug.cgi?id=299000
rdar://160752786

Reviewed by Abrar Rahman Protyasha.

According to https://w3c.github.io/pointerevents/#dfn-lostpointercapture:
`lostpointercapture` "MUST be fired prior to any subsequent events for the
pointer after capture was released." This is not always the case in WebKit;
we fail the third subtest of the wpt test
pointerevents/pointerevent_lostpointercapture_for_disconnected_node.html
as a result.

The cause of this bug is that, when an element with pointer capture is removed,
PointerCaptureController::elementWasRemovedSlow is called, and it queues the
dispatch of a `lostpointercaptureEvent` rather than immediately dispatching
due to it being in a script disallowed context. This results in a timing issue
where other pointer events may fire before `lostpointercaptureEvent`. To resolve
this, immediately clear the pointer capture target and pending target in
`lostpointercaptureEvent`, and begin suppressing event processing until the
`lostpointercaptureEvent` is received.

Event suppression works on a per-pointer basis, and is synchronously enabled in
`PointerCaptureController::elementWasRemovedSlow`. In 
`Document::prepareMouseEvent,`
we now return an empty result when the suppression flag is result to prevent
events from processing. When the `lostpointercapture` event is actually 
dispatched,
we detect it in `EventDispatcher::dispatchEvent`, and clear event suppression
accordingly.

* 
LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_lostpointercapture_for_disconnected_node-expected.txt:
* 
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/pointerevents/pointerevent_lostpointercapture_for_disconnected_node-expected.txt:
 Copied from 
LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_lostpointercapture_for_disconnected_node-expected.txt.
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::prepareMouseEvent):
* Source/WebCore/dom/EventDispatcher.cpp:
(WebCore::EventDispatcher::dispatchEvent):
* Source/WebCore/page/ChromeClient.h:
(WebCore::ChromeClient::supportsEventSuppression):
* Source/WebCore/page/PointerCaptureController.cpp:
(WebCore::PointerCaptureController::elementWasRemovedSlow):
(WebCore::PointerCaptureController::clearEventSuppression):
(WebCore::PointerCaptureController::shouldSuppressEventProcessing const):
* Source/WebCore/page/PointerCaptureController.h:
* Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h:

Canonical link: https://commits.webkit.org/300168@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to