Bug 1935672 - Restore a chunk of code that is still needed apparently.

This fixes failures in test_input_datetime_focus_blur_events.html and
such, but it seems like the shadow DOM retargetting should handle
this?

MANUAL PUSH: Orange fix CLOSED TREE
This commit is contained in:
Emilio Cobos Álvarez
2025-01-03 15:36:41 +01:00
parent 2c1548f407
commit 19b8476a6c

View File

@@ -3266,6 +3266,30 @@ void HTMLInputElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
}
nsGenericHTMLFormControlElementWithState::GetEventTargetParent(aVisitor);
// Stop the event if the related target's first non-native ancestor is the
// same as the original target's first non-native ancestor (we are moving
// inside of the same element).
//
// FIXME(emilio): This seems like it shouldn't be needed now that we use
// Shadow DOM for this, but test_input_datetime_focus_blur_events.html fails
// without this.
if (CreatesDateTimeWidget() && aVisitor.mEvent->IsTrusted() &&
(aVisitor.mEvent->mMessage == eFocus ||
aVisitor.mEvent->mMessage == eFocusIn ||
aVisitor.mEvent->mMessage == eFocusOut ||
aVisitor.mEvent->mMessage == eBlur)) {
nsIContent* originalTarget = nsIContent::FromEventTargetOrNull(
aVisitor.mEvent->AsFocusEvent()->mOriginalTarget);
nsIContent* relatedTarget = nsIContent::FromEventTargetOrNull(
aVisitor.mEvent->AsFocusEvent()->mRelatedTarget);
if (originalTarget && relatedTarget &&
originalTarget->FindFirstNonChromeOnlyAccessContent() ==
relatedTarget->FindFirstNonChromeOnlyAccessContent()) {
aVisitor.mCanHandle = false;
}
}
}
void HTMLInputElement::LegacyPreActivationBehavior(