Bug 1891304 - Make APZEventState manage whether the pointerdown was consumed by content or not r=smaug,hiro

The Pointer Events spec defines that:

> Authors can prevent the firing of certain compatibility mouse events by
> canceling the pointerdown event (if the isPrimary property is true).
> <snip>
> Note, however, that this does not prevent the mouseover, mouseenter, mouseout,
> or mouseleave events from firing.
https://w3c.github.io/pointerevents/#the-pointerdown-event

The other browsers conform to this.  Therefore, we should stop dispatching
compatibility mouse events only if the preceding `pointerdown` is consumed by
content.  I.e., we need to keep dispatching touch events and `click` etc which
indicate what should happen on the element.

Currently, `APZEventState` does not manage whether the preceding `pointerdown`
is canceled or not.  So, it dispatches compatibility mouse events via
`APZCCallbackHelper` after the consumed pointer is removed.  Therefore, we
need to make it manage whether the preceding `pointerdown` of the first touch
is consumed or not and `APZCCallbackHelper` needs an option to dispatch the
compatibility mouse events only to chrome (they are required to dispatch
`click` etc).

However, if `APZEventState` is not available like test API used in the
remote process, `TouchManager` needs to manage it instead of `APZEventState`.

I don't think only `TouchManager` should manage it because `APZEventState`
manages complicated state of touch gestures and that can know whether the
synthesizing compatibility mouse events related to the consumed `pointerdown`
or not strictly.  Therefore, this patch makes the `TouchManager` state used
only in the path handling synthesized events for tests.

Differential Revision: https://phabricator.services.mozilla.com/D208706
This commit is contained in:
Masayuki Nakano
2024-05-14 01:07:49 +00:00
parent 523b587326
commit 33274b20c7
8 changed files with 114 additions and 28 deletions

View File

@@ -7746,6 +7746,10 @@ void PresShell::EventHandler::MaybeSynthesizeCompatMouseEventsForTouchEnd(
event.mClickCount = message == eMouseMove ? 0 : 1;
event.mModifiers = aTouchEndEvent->mModifiers;
event.convertToPointer = false;
if (TouchManager::IsPrecedingTouchPointerDownConsumedByContent()) {
event.PreventDefault(false);
event.mFlags.mOnlyChromeDispatch = true;
}
nsEventStatus mouseEventStatus = nsEventStatus_eIgnore;
presShell->HandleEvent(frameForPresShell, &event, false, &mouseEventStatus);
}