Bug 282266 - Populate imageClickedPoint when submitter is an image button. r=dom-core,layout-reviewers,emilio,masayuki

If the form submission originated from an event dispatch, this patch
ensures that the submitted image button coordinate is not the default.

Differential Revision: https://phabricator.services.mozilla.com/D224651
This commit is contained in:
Zach Hoffman
2024-10-15 12:27:57 +00:00
parent f862603b75
commit b335283083
4 changed files with 79 additions and 11 deletions

View File

@@ -23,6 +23,7 @@
#include "mozilla/dom/WindowContext.h"
#include "mozilla/dom/InputType.h"
#include "mozilla/dom/UserActivation.h"
#include "mozilla/dom/MouseEvent.h"
#include "mozilla/dom/MutationEventBinding.h"
#include "mozilla/dom/WheelEventBinding.h"
#include "mozilla/dom/WindowGlobalChild.h"
@@ -3353,6 +3354,18 @@ void HTMLInputElement::LegacyPreActivationBehavior(
// latest one will be deferred until after the exit point of the
// handler.
mForm->OnSubmitClickBegin(this);
if (aVisitor.mDOMEvent) {
if (auto* mouseEvent = aVisitor.mDOMEvent->AsMouseEvent()) {
CSSIntPoint pt = mouseEvent->OffsetPoint();
if (auto* imageClickedPoint = static_cast<CSSIntPoint*>(
GetProperty(nsGkAtoms::imageClickedPoint))) {
// Ensures that a dispatched event's clicked point is not the default
// value.
*imageClickedPoint = pt;
}
}
}
}
}