Bug 1947446 - Part 1: Input element should always have activation behavior; r=smaug

See https://html.spec.whatwg.org/multipage/input.html#the-input-element.

Differential Revision: https://phabricator.services.mozilla.com/D238780
This commit is contained in:
Edgar Chen
2025-02-25 22:30:47 +00:00
parent 4411cd4ee7
commit 9f0edddf04
2 changed files with 48 additions and 25 deletions

View File

@@ -3152,32 +3152,18 @@ bool HTMLInputElement::IsDisabledForEvents(WidgetEvent* aEvent) {
bool HTMLInputElement::CheckActivationBehaviorPreconditions(
EventChainVisitor& aVisitor) const {
switch (mType) {
case FormControlType::InputColor:
case FormControlType::InputCheckbox:
case FormControlType::InputRadio:
case FormControlType::InputFile:
case FormControlType::InputSubmit:
case FormControlType::InputImage:
case FormControlType::InputReset:
case FormControlType::InputButton: {
// Track whether we're in the outermost Dispatch invocation that will
// cause activation of the input. That is, if we're a click event, or a
// DOMActivate that was dispatched directly, this will be set, but if
// we're a DOMActivate dispatched from click handling, it will not be set.
WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent();
bool outerActivateEvent =
(mouseEvent && mouseEvent->IsLeftClickEvent()) ||
(aVisitor.mEvent->mMessage == eLegacyDOMActivate &&
!mInInternalActivate);
if (outerActivateEvent) {
aVisitor.mItemFlags |= NS_OUTER_ACTIVATE_EVENT;
}
return outerActivateEvent;
}
default:
return false;
// Track whether we're in the outermost Dispatch invocation that will
// cause activation of the input. That is, if we're a click event, or a
// DOMActivate that was dispatched directly, this will be set, but if
// we're a DOMActivate dispatched from click handling, it will not be set.
WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent();
bool outerActivateEvent =
(mouseEvent && mouseEvent->IsLeftClickEvent()) ||
(aVisitor.mEvent->mMessage == eLegacyDOMActivate && !mInInternalActivate);
if (outerActivateEvent) {
aVisitor.mItemFlags |= NS_OUTER_ACTIVATE_EVENT;
}
return outerActivateEvent;
}
void HTMLInputElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {