Backed out changeset a00be88f3708 (bug 1877969) for causing multiple failures. CLOSED TREE

This commit is contained in:
Iulian Moraru 2024-06-04 16:49:11 +03:00
parent 08324af1aa
commit 51e39ebc5a
2 changed files with 11 additions and 23 deletions

View file

@ -677,11 +677,16 @@ nsColorPickerShownCallback::Done(const nsAString& aColor) {
NS_IMPL_ISUPPORTS(nsColorPickerShownCallback, nsIColorPickerShownCallback)
static bool IsPickerBlocked(Document* aDoc) {
static bool IsPopupBlocked(Document* aDoc) {
if (aDoc->ConsumeTransientUserGestureActivation()) {
return false;
}
WindowContext* wc = aDoc->GetWindowContext();
if (wc && wc->CanShowPopup()) {
return false;
}
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "DOM"_ns, aDoc,
nsContentUtils::eDOM_PROPERTIES,
"InputPickerBlockedNoUserActivation");
@ -730,7 +735,7 @@ nsresult HTMLInputElement::InitColorPicker() {
return NS_ERROR_FAILURE;
}
if (IsPickerBlocked(doc)) {
if (IsPopupBlocked(doc)) {
return NS_OK;
}
@ -778,7 +783,7 @@ nsresult HTMLInputElement::InitFilePicker(FilePickerType aType) {
return NS_ERROR_FAILURE;
}
if (IsPickerBlocked(doc)) {
if (IsPopupBlocked(doc)) {
return NS_OK;
}
@ -3572,7 +3577,7 @@ nsresult HTMLInputElement::MaybeInitPickers(EventChainPostVisitor& aVisitor) {
// open a color picker when we receive a click on a <input type='color'>.
// 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 check and consume user activation.
// .click(). However, the pickers will follow the rules of popup-blocking.
WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent();
if (!(mouseEvent && mouseEvent->IsLeftClickEvent())) {
return NS_OK;
@ -5840,11 +5845,7 @@ void HTMLInputElement::ShowPicker(ErrorResult& aRv) {
// Step 2. If element is not mutable, then return.
// (See above.)
// Step 3. Consume user activation given element's relevant global object.
// InitFilePicker() and InitColorPicker() consume it themselves,
// so only consume in this function if not those.
// Step 4. If element's type attribute is in the File Upload state, then run
// Step 3. If element's type attribute is in the File Upload state, then run
// these steps in parallel:
if (mType == FormControlType::InputFile) {
FilePickerType type = FILE_PICKER_FILE;
@ -5856,7 +5857,7 @@ void HTMLInputElement::ShowPicker(ErrorResult& aRv) {
return;
}
// Step 5. Otherwise, the user agent should show any relevant user interface
// Step 4. Otherwise, the user agent should show any relevant user interface
// for selecting a value for element, in the way it normally would when the
// user interacts with the control
if (mType == FormControlType::InputColor) {
@ -5864,9 +5865,6 @@ void HTMLInputElement::ShowPicker(ErrorResult& aRv) {
return;
}
// See Step 3.
OwnerDoc()->ConsumeTransientUserGestureActivation();
if (!IsInComposedDoc()) {
return;
}

View file

@ -201,16 +201,6 @@ void HTMLSelectElement::ShowPicker(ErrorResult& aRv) {
}
// Step 5. Show the picker, if applicable, for this.
// https://html.spec.whatwg.org/multipage/input.html#show-the-picker,-if-applicable
// To show the picker, if applicable for an input element element:
// We already checked if mutable and user activation earlier, so skip 1 & 2.
// Step 3. Consume user activation given element's relevant global object.
OwnerDoc()->ConsumeTransientUserGestureActivation();
// Step 5. Otherwise, the user agent should show any relevant user interface
// for selecting a value for element, in the way it normally would when the
// user interacts with the control.
#if !defined(ANDROID)
if (!IsCombobox()) {
return;