[webkit-changes] [WebKit/WebKit] e837c3: uievents/mouse/cancel-mousedown-in-subframe.html W...

Abrar Rahman Protyasha noreply at github.com
Thu Oct 12 05:32:36 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e837c341a756a244e94b2b2cdd166aa02b92e217
      https://github.com/WebKit/WebKit/commit/e837c341a756a244e94b2b2cdd166aa02b92e217
  Author: Abrar Rahman Protyasha <a_protyasha at apple.com>
  Date:   2023-10-12 (Thu, 12 Oct 2023)

  Changed paths:
    M LayoutTests/TestExpectations
    A LayoutTests/fast/events/cancel-mousedown-and-drag-from-frame-to-other-frame-expected.txt
    A LayoutTests/fast/events/cancel-mousedown-and-drag-from-frame-to-other-frame.html
    A LayoutTests/fast/events/cancel-mousedown-and-drag-to-frame-expected.txt
    A LayoutTests/fast/events/cancel-mousedown-and-drag-to-frame.html
    R LayoutTests/fast/events/mouse-drag-from-frame-expected.txt
    R LayoutTests/fast/events/mouse-drag-from-frame-to-other-frame-expected.txt
    R LayoutTests/fast/events/mouse-drag-from-frame-to-other-frame.html
    R LayoutTests/fast/events/mouse-drag-from-frame.html
    M LayoutTests/fast/events/resources/mouse-drag-from-frame-subframe.html
    M LayoutTests/fast/events/resources/mouse-drag-from-frame-target-subframe.html
    M LayoutTests/imported/w3c/web-platform-tests/uievents/mouse/cancel-mousedown-in-subframe-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/uievents/mouse/cancel-mousedown-in-subframe.html
    M LayoutTests/platform/ios/TestExpectations
    M LayoutTests/platform/mac-wk1/TestExpectations
    M LayoutTests/platform/wpe/TestExpectations
    M Source/WebCore/dom/Element.cpp
    M Source/WebCore/dom/Element.h
    M Source/WebCore/page/EventHandler.cpp
    M Source/WebCore/page/EventHandler.h

  Log Message:
  -----------
  uievents/mouse/cancel-mousedown-in-subframe.html WPT is failing
https://bugs.webkit.org/show_bug.cgi?id=262691
rdar://116516596

Reviewed by Wenson Hsieh.

This patch changes how we handle mouse events following preventDefault
on mousedown events. Following this patch, if we initiate a drag from a
cancelled mousedown event, we keep sending events to the originating
frame till the terminating mouseup corresponding to said drag gesture is
dispatched.

We do so by slightly adjusting our logic around the
`EventHandler::capturesDragging` state, which represents whether or not
we can capture the element under a mouse event during a drag.
Previously, for a mousedown event that was preventDefault-ed,
`capturesDragging` would be unconditionally set to false for the event
handler associated with said frame, which meant that we would not be
capturing the element under the mouse event in said frame, which
resulted in the bug (and the WPT failure).

Instead, this commit changes `capturesDragging` from a boolean flag to a
structure with a little more information. Namely, we keep track of the
reason why drag capture is not possible. This allows us to say that
`capturesDragging` is not possible _because_ the mousePress in question is
cancelled (`MousePressIsCancelled`). The main frame event handler can now
capture the right element when successfully passing a mouse press event to
a subframe. This is represented either as `localSubframe->ownerElement()`
or as the new boolean state `m_isCapturingRootElementForMouseEvent`;
since we now capture an element to keep sending events to when either
`capturesDragging` is true or when the reason drag capture is not possible is
`MousePressIsCancelled`.

This patch aligns our behavior with the Gecko engine, and gets us to pass
the `uievents/mouse/cancel-mousedown-in-subframe.html` web platform test.

* LayoutTests/TestExpectations:

Adjust test expectations now that we're passing the WPT.

* LayoutTests/fast/events/cancel-mousedown-and-drag-from-frame-to-other-frame-expected.txt: Added.
* LayoutTests/fast/events/cancel-mousedown-and-drag-from-frame-to-other-frame.html: Renamed from LayoutTests/fast/events/mouse-drag-from-frame-to-other-frame.html.
* LayoutTests/fast/events/cancel-mousedown-and-drag-to-frame-expected.txt: Added.
* LayoutTests/fast/events/cancel-mousedown-and-drag-to-frame.html: Renamed from LayoutTests/fast/events/mouse-drag-from-frame.html.
* LayoutTests/fast/events/mouse-drag-from-frame-expected.txt: Removed.
* LayoutTests/fast/events/mouse-drag-from-frame-to-other-frame-expected.txt: Removed.
* LayoutTests/fast/events/resources/mouse-drag-from-frame-subframe.html:
* LayoutTests/fast/events/resources/mouse-drag-from-frame-target-subframe.html:
* LayoutTests/imported/w3c/web-platform-tests/uievents/mouse/cancel-mousedown-in-subframe-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/uievents/mouse/cancel-mousedown-in-subframe.html:

Uncomment two assertion statements. This was probably an import mistake.

* LayoutTests/platform/ios/TestExpectations:
* LayoutTests/platform/mac-wk1/TestExpectations:
* LayoutTests/platform/wpe/TestExpectations:

Update two layout tests fast/events/mouse-drag-from-frame.html and
fast/events/mouse-drag-from-frame-to-other-frame.html to reflect the new
event retention behavior change introduced by this PR.

* Source/WebCore/dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent):
* Source/WebCore/dom/Element.h:

Introduce an overload for `dispatchMouseEvent` that accepts an outparam
`isEventCancelled` that a caller can use to learn if the provided mouse
event is preventDefault-ed.

* Source/WebCore/page/EventHandler.cpp:
(WebCore::EventHandler::clear):
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::handleMouseDoubleClickEvent):
(WebCore::EventHandler::handleMouseMoveEvent):
(WebCore::EventHandler::handleMouseReleaseEvent):
(WebCore::EventHandler::clearDragState):
(WebCore::EventHandler::setCapturingMouseEventsElement):
(WebCore::EventHandler::dispatchMouseEvent):

Event retention behavior adjustment as described in the commit message
above.

* Source/WebCore/page/EventHandler.h:
(WebCore::EventHandler::CapturesDragging::CapturesDragging):
(WebCore::EventHandler::CapturesDragging::operator=):
(WebCore::EventHandler::CapturesDragging::operator bool const):
(WebCore::EventHandler::CapturesDragging::inabilityReason const):
(WebCore::EventHandler::capturesDragging const):
(WebCore::EventHandler::isCapturingMouseEventsElement const):
(WebCore::EventHandler::resetCapturingMouseEventsElement):

Update the capturesDragging variable to act as a boolean flag but also
contain a reason if capturesDragging::operator bool() returns false.
Moreover, introduce an additional boolean state that indicates when
we're capturing the root HTML element, and not some subframe, for this
event retention behavior. This is necessary so we can make a distinction
between a null element and the root element.

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




More information about the webkit-changes mailing list