Bug 1675847 - part 3: Make ePointerClick event dispatchers and handlers use WidgetPointerEvent r=smaug,search-reviewers,devtools-reviewers,nchevobbe,jteow
This patch makes the all `ePointerClick` event dispatcher in C++ code use `WidgetPointerEvent` instead of `WidgetMouseEvent`. Then, this patch also makes the all `click` event dispatcher in chrome code use `PointerEvent` instead of `MouseEvent`. For detecting wrong trusted event dispatching of `click` event, this patch adds assertion into `MouseEvent`. Therefore, all chrome test dispatchers also changed to use `PointerEvent`. Finally, this patch includes a change of a WPT. That checks the `pointerId` caused by executing an access key. In this case, the value should be `-1` rather than the default value `0` because Pointer Event spec defines so for synthetic pointer events caused by non-pointing devices [1]. Chrome also sets it to `-1` and fails [2]. Therefore, the new assertion will pass on both Firefox and Chrome. 1. https://w3c.github.io/pointerevents/#dom-pointerevent-pointerid 2. https://wpt.fyi/results/uievents/interface/keyboard-accesskey-click-event.html?run_id=5087897523060736&run_id=5136270464647168&run_id=5163620816388096&run_id=5201281304231936 Differential Revision: https://phabricator.services.mozilla.com/D213001
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
#include "mozilla/dom/WheelEventBinding.h"
|
||||
#include "mozilla/dom/WindowGlobalChild.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/StaticPrefs_signon.h"
|
||||
@@ -2987,8 +2989,20 @@ void HTMLInputElement::MaybeSubmitForm(nsPresContext* aPresContext) {
|
||||
// Get the default submit element
|
||||
if (RefPtr<nsGenericHTMLFormElement> submitContent =
|
||||
mForm->GetDefaultSubmitElement()) {
|
||||
WidgetMouseEvent event(true, ePointerClick, nullptr,
|
||||
WidgetMouseEvent::eReal);
|
||||
Maybe<WidgetPointerEvent> pointerEvent;
|
||||
Maybe<WidgetMouseEvent> mouseEvent;
|
||||
if (StaticPrefs::dom_w3c_pointer_events_dispatch_click_as_pointer_event()) {
|
||||
pointerEvent.emplace(true, ePointerClick, nullptr);
|
||||
} else {
|
||||
mouseEvent.emplace(true, ePointerClick, nullptr, WidgetMouseEvent::eReal);
|
||||
}
|
||||
WidgetMouseEvent& event =
|
||||
pointerEvent.isSome() ? pointerEvent.ref() : mouseEvent.ref();
|
||||
event.mInputSource = MouseEvent_Binding::MOZ_SOURCE_KEYBOARD;
|
||||
// pointerId definition in Pointer Events:
|
||||
// > The pointerId value of -1 MUST be reserved and used to indicate events
|
||||
// > that were generated by something other than a pointing device.
|
||||
event.pointerId = -1;
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
presShell->HandleDOMEventWithTarget(submitContent, &event, &status);
|
||||
} else if (!mForm->ImplicitSubmissionIsDisabled()) {
|
||||
|
||||
Reference in New Issue
Block a user