Bug 1952343 - Notify nsI{Color|File}PickerShownCallback asynchronously when picker is blocked; r=emilio
Otherwise, the HTMLInputElement doesn't handle the mPickerRunning flag right if it is in parent process. There is no such problem on content process because the IPC is async. Differential Revision: https://phabricator.services.mozilla.com/D241440
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "mozilla/dom/BrowsingContext.h"
|
#include "mozilla/dom/BrowsingContext.h"
|
||||||
#include "mozilla/dom/CanonicalBrowsingContext.h"
|
#include "mozilla/dom/CanonicalBrowsingContext.h"
|
||||||
|
#include "nsThreadUtils.h"
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsBaseColorPicker::Init(mozilla::dom::BrowsingContext* aBrowsingContext,
|
nsBaseColorPicker::Init(mozilla::dom::BrowsingContext* aBrowsingContext,
|
||||||
@@ -47,8 +48,10 @@ bool nsBaseColorPicker::MaybeBlockColorPicker(
|
|||||||
if (!mBrowsingContext->Canonical()->CanOpenModalPicker()) {
|
if (!mBrowsingContext->Canonical()->CanOpenModalPicker()) {
|
||||||
if (aCallback) {
|
if (aCallback) {
|
||||||
// Color pickers are disabled, so we answer the callback with
|
// Color pickers are disabled, so we answer the callback with
|
||||||
// returnCancel.
|
// empty string.
|
||||||
aCallback->Done(EmptyString());
|
NS_DispatchToCurrentThread(mozilla::NewRunnableMethod<const nsAString&>(
|
||||||
|
"nsBaseColorPicker::CallbackWithEmptyString", aCallback,
|
||||||
|
&nsIColorPickerShownCallback::Done, EmptyString()));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "WidgetUtils.h"
|
#include "WidgetUtils.h"
|
||||||
#include "nsSimpleEnumerator.h"
|
#include "nsSimpleEnumerator.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
|
#include "nsThreadUtils.h"
|
||||||
|
|
||||||
#include "nsBaseFilePicker.h"
|
#include "nsBaseFilePicker.h"
|
||||||
|
|
||||||
@@ -351,7 +352,10 @@ bool nsBaseFilePicker::MaybeBlockFilePicker(
|
|||||||
if (mozilla::StaticPrefs::widget_disable_file_pickers()) {
|
if (mozilla::StaticPrefs::widget_disable_file_pickers()) {
|
||||||
if (aCallback) {
|
if (aCallback) {
|
||||||
// File pickers are disabled, so we answer the callback with returnCancel.
|
// File pickers are disabled, so we answer the callback with returnCancel.
|
||||||
aCallback->Done(nsIFilePicker::returnCancel);
|
NS_DispatchToCurrentThread(
|
||||||
|
mozilla::NewRunnableMethod<nsIFilePicker::ResultCode>(
|
||||||
|
"nsBaseFilePicker::CallbackWithCancelResult", aCallback,
|
||||||
|
&nsIFilePickerShownCallback::Done, nsIFilePicker::returnCancel));
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Element> topFrameElement = mBrowsingContext->GetTopFrameElement();
|
RefPtr<Element> topFrameElement = mBrowsingContext->GetTopFrameElement();
|
||||||
@@ -372,7 +376,10 @@ bool nsBaseFilePicker::MaybeBlockFilePicker(
|
|||||||
if (aCallback) {
|
if (aCallback) {
|
||||||
// File pickers are not allowed to open, so we respond to the callback with
|
// File pickers are not allowed to open, so we respond to the callback with
|
||||||
// returnCancel.
|
// returnCancel.
|
||||||
aCallback->Done(nsIFilePicker::returnCancel);
|
NS_DispatchToCurrentThread(
|
||||||
|
mozilla::NewRunnableMethod<nsIFilePicker::ResultCode>(
|
||||||
|
"nsBaseFilePicker::CallbackWithCancelResult", aCallback,
|
||||||
|
&nsIFilePickerShownCallback::Done, nsIFilePicker::returnCancel));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user