Bug 1550462 - part 2: Make PresShell::HandleEvent dispatch preceding pointerrawupdate event r=smaug,dom-core,edgar

This patch tries to dispatch `ePointerRawUpdate` with
`PresShell::EventHandler::DispatchPrecedingPointerEvent` as same as usual
pointer events.

For using the path, this patch adds 2 internal events, `eMouseRawUpdate`
and `eTouchRawUpdate` which are never dispatched into the DOM because
`PresShell::EventHandler::DispatchPrecedingPointerEvent` will return `false`
for that and then the caller will stop handling the internal events.

There are 3 dispatchers of the internal raw update events.

One is `PresShell::EnsurePrecedingPointerRawUpdate()`.  This dispatches the
internal event if and only if the coming event of `PresShell::HandleEvent` will
cause `ePointerMove`.  The reason why `PresShell::HandleEvent` handles the
preceding raw-update event is, we should support `ePointerRawUpdate` events
for synthesized events for tests (in-process ones) and in the main process.
Additionally, if a `pointerrawupdate` event may destroy the target `<iframe>`.
In such ase, the following `pointermove` may need to be dispatched on its parent
window or another `<iframe>` window.  Therefore, we need to dispatch the
internal raw update event before considering the target window (`PresShell`) and
handling the capturing element.

The others are `BrowserChild::RecvRealMouseMoveEvent` and
`BrowserChild::RecvRealTouchMoveEvent`.  They dispatch the internal events
when they won't dispatch the received event immediately to coalesce with further
similar input.

For avoiding to dispatch the internal event for same source event, this adds
`WidgetPointerHelper::convertToPointerRawUpdate` member to check it in
`PresShell::HandlePrecedingPointerRawUpdate`.

Differential Revision: https://phabricator.services.mozilla.com/D243404
This commit is contained in:
Masayuki Nakano
2025-05-15 03:20:29 +00:00
committed by masayuki@d-toybox.com
parent 2b13850454
commit 502f22686c
24 changed files with 888 additions and 89 deletions

View File

@@ -4895,13 +4895,16 @@ void HTMLMediaElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
// element, allowing media control exclusive consumption on these events,
// and preventing the content from handling them.
switch (aVisitor.mEvent->mMessage) {
case ePointerDown:
case ePointerUp:
case eTouchEnd:
case eTouchRawUpdate:
MOZ_FALLTHROUGH_ASSERT(
"eTouchRawUpdate event shouldn't be dispatched into the DOM");
// Always prevent touchmove captured in video element from being handled by
// content, since we always do that for touchstart.
case eTouchMove:
case eTouchEnd:
case eTouchStart:
case ePointerDown:
case ePointerUp:
case ePointerClick:
case eMouseDoubleClick:
case eMouseDown:
@@ -4909,9 +4912,13 @@ void HTMLMediaElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
aVisitor.mCanHandle = false;
return;
// The *move events however are only comsumed when the range input is being
// The *move events however are only consumed when the range input is being
// dragged.
case eMouseRawUpdate:
MOZ_FALLTHROUGH_ASSERT(
"eMouseRawUpdate event shouldn't be dispatched into the DOM");
case ePointerMove:
case ePointerRawUpdate:
case eMouseMove: {
nsINode* node =
nsINode::FromEventTargetOrNull(aVisitor.mEvent->mOriginalTarget);