Bug 1362382 - Move RegisterDragDrop to be called during idle time, if possible r=jimm

Additionally, do not call RegisterDragDrop for hidden windows.

MozReview-Commit-ID: Fv8j9FntGGT
This commit is contained in:
Kirk Steuber
2017-08-30 11:18:25 -07:00
parent 56493a67bb
commit 1a30465ba0
5 changed files with 27 additions and 2 deletions

View File

@@ -125,6 +125,11 @@ int32_t nsIWidget::sPointerIdCounter = 0;
/*static*/ uint64_t AutoObserverNotifier::sObserverId = 0;
/*static*/ nsDataHashtable<nsUint64HashKey, nsCOMPtr<nsIObserver>> AutoObserverNotifier::sSavedObservers;
// The maximum amount of time to let the EnableDragDrop runnable wait in the
// idle queue before timing out and moving it to the regular queue. Value is in
// milliseconds.
const uint32_t kAsyncDragDropTimeout = 1000;
namespace mozilla {
namespace widget {
@@ -2229,6 +2234,18 @@ nsBaseWidget::UnregisterPluginWindowForRemoteUpdates()
#endif
}
nsresult
nsBaseWidget::AsyncEnableDragDrop(bool aEnable)
{
RefPtr<nsBaseWidget> kungFuDeathGrip = this;
return NS_IdleDispatchToCurrentThread(
NS_NewRunnableFunction("AsyncEnableDragDropFn",
[this, aEnable, kungFuDeathGrip]() {
EnableDragDrop(aEnable);
}),
kAsyncDragDropTimeout);
}
// static
nsIWidget*
nsIWidget::LookupRegisteredPluginWindow(uintptr_t aWindowID)