Bug 1774035 - Stop opening pickers from disabled input elements r=smaug,emilio

Differential Revision: https://phabricator.services.mozilla.com/D149157
This commit is contained in:
Kagami Sascha Rosylight
2022-06-14 17:27:22 +00:00
parent 6e773cf588
commit 86fe2bd8dc
2 changed files with 23 additions and 7 deletions

View File

@@ -3490,14 +3490,10 @@ bool HTMLInputElement::ShouldPreventDOMActivateDispatch(
nsresult HTMLInputElement::MaybeInitPickers(EventChainPostVisitor& aVisitor) {
// Open a file picker when we receive a click on a <input type='file'>, or
// open a color picker when we receive a click on a <input type='color'>.
// A click is handled in the following cases:
// - preventDefault() has not been called (or something similar);
// - it's the left mouse button.
// A click is handled if it's the left mouse button.
// We do not prevent non-trusted click because authors can already use
// .click(). However, the pickers will follow the rules of popup-blocking.
if (aVisitor.mEvent->DefaultPrevented()) {
return NS_OK;
}
MOZ_ASSERT(IsMutable());
WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent();
if (!(mouseEvent && mouseEvent->IsLeftClickEvent())) {
return NS_OK;
@@ -4055,7 +4051,10 @@ nsresult HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
PostHandleEventForRangeThumb(aVisitor);
}
return MaybeInitPickers(aVisitor);
if (!preventDefault) {
MOZ_TRY(MaybeInitPickers(aVisitor));
}
return NS_OK;
}
enum class RadioButtonMove { Back, Forward, None };