diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 5ec63503384b..133b6f15ae62 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -175,30 +175,6 @@ private: nsSize mSize; }; -namespace { - -class NativeInputRunnable final : public PrioritizableRunnable -{ - explicit NativeInputRunnable(already_AddRefed&& aEvent); - ~NativeInputRunnable() {} -public: - static already_AddRefed Create(already_AddRefed&& aEvent); -}; - -NativeInputRunnable::NativeInputRunnable(already_AddRefed&& aEvent) - : PrioritizableRunnable(Move(aEvent), nsIRunnablePriority::PRIORITY_INPUT) -{ -} - -/* static */ already_AddRefed -NativeInputRunnable::Create(already_AddRefed&& aEvent) -{ - nsCOMPtr event(new NativeInputRunnable(Move(aEvent))); - return event.forget(); -} - -} // unnamed namespace - LinkedList OldWindowSize::sList; NS_INTERFACE_MAP_BEGIN(nsDOMWindowUtils) @@ -1144,7 +1120,7 @@ nsDOMWindowUtils::SendNativeKeyEvent(int32_t aNativeKeyboardLayout, if (!widget) return NS_ERROR_FAILURE; - NS_DispatchToMainThread(NativeInputRunnable::Create( + NS_DispatchToMainThread( NewRunnableMethod( "nsIWidget::SynthesizeNativeMouseEvent", widget, @@ -1183,7 +1159,7 @@ nsDOMWindowUtils::SendNativeMouseEvent(int32_t aScreenX, LayoutDeviceIntPoint(aScreenX, aScreenY), aNativeMessage, aModifierFlags, - aObserver))); + aObserver)); return NS_OK; } @@ -1198,13 +1174,12 @@ nsDOMWindowUtils::SendNativeMouseMove(int32_t aScreenX, if (!widget) return NS_ERROR_FAILURE; - NS_DispatchToMainThread(NativeInputRunnable::Create( - NewRunnableMethod( - "nsIWidget::SynthesizeNativeMouseMove", - widget, - &nsIWidget::SynthesizeNativeMouseMove, - LayoutDeviceIntPoint(aScreenX, aScreenY), - aObserver))); + NS_DispatchToMainThread(NewRunnableMethod( + "nsIWidget::SynthesizeNativeMouseMove", + widget, + &nsIWidget::SynthesizeNativeMouseMove, + LayoutDeviceIntPoint(aScreenX, aScreenY), + aObserver)); return NS_OK; } @@ -1226,26 +1201,25 @@ nsDOMWindowUtils::SendNativeMouseScrollEvent(int32_t aScreenX, return NS_ERROR_FAILURE; } - NS_DispatchToMainThread(NativeInputRunnable::Create( - NewRunnableMethod( - "nsIWidget::SynthesizeNativeMouseScrollEvent", - widget, - &nsIWidget::SynthesizeNativeMouseScrollEvent, - LayoutDeviceIntPoint(aScreenX, aScreenY), - aNativeMessage, - aDeltaX, - aDeltaY, - aDeltaZ, - aModifierFlags, - aAdditionalFlags, - aObserver))); + NS_DispatchToMainThread(NewRunnableMethod( + "nsIWidget::SynthesizeNativeMouseScrollEvent", + widget, + &nsIWidget::SynthesizeNativeMouseScrollEvent, + LayoutDeviceIntPoint(aScreenX, aScreenY), + aNativeMessage, + aDeltaX, + aDeltaY, + aDeltaZ, + aModifierFlags, + aAdditionalFlags, + aObserver)); return NS_OK; } @@ -1267,7 +1241,7 @@ nsDOMWindowUtils::SendNativeTouchPoint(uint32_t aPointerId, return NS_ERROR_INVALID_ARG; } - NS_DispatchToMainThread(NativeInputRunnable::Create( + NS_DispatchToMainThread( NewRunnableMethod( "nsIWidget::SynthesizeNativeTouchTap", widget, &nsIWidget::SynthesizeNativeTouchTap, LayoutDeviceIntPoint(aScreenX, aScreenY), aLongTap, - aObserver))); + aObserver)); return NS_OK; } @@ -1325,11 +1299,11 @@ nsDOMWindowUtils::ClearNativeTouchSequence(nsIObserver* aObserver) return NS_ERROR_FAILURE; } - NS_DispatchToMainThread(NativeInputRunnable::Create( + NS_DispatchToMainThread( NewRunnableMethod("nsIWidget::ClearNativeTouchSequence", widget, &nsIWidget::ClearNativeTouchSequence, - aObserver))); + aObserver)); return NS_OK; } diff --git a/gfx/layers/apz/test/mochitest/helper_touch_action_regions.html b/gfx/layers/apz/test/mochitest/helper_touch_action_regions.html index 647e3fc0088a..0d1e90d7f5fa 100644 --- a/gfx/layers/apz/test/mochitest/helper_touch_action_regions.html +++ b/gfx/layers/apz/test/mochitest/helper_touch_action_regions.html @@ -93,11 +93,6 @@ function waitFor(eventType, count) { return true; } -function RunAfterProcessedQueuedInputEvents(aCallback) { - let tm = SpecialPowers.Services.tm; - tm.dispatchToMainThread(aCallback, SpecialPowers.Ci.nsIRunnablePriority.PRIORITY_INPUT); -} - function* test(testDriver) { // The main part of this test should run completely before the child process' // main-thread deals with the touch event, so check to make sure that happens. @@ -144,8 +139,8 @@ function* test(testDriver) { // scrolling even though we know we haven't yet processed the DOM touch events // in the child process yet. // - // Note that the "async callback" we use here is SpecialPowers.tm.dispatchToMainThread - // with priority = input, because nothing else does exactly what we want: + // Note that the "async callback" we use here is SpecialPowers.executeSoon, + // because nothing else does exactly what we want: // - setTimeout(..., 0) does not maintain ordering, because it respects the // time delta provided (i.e. the callback can jump the queue to meet its // deadline). @@ -154,9 +149,6 @@ function* test(testDriver) { // round-trip time. // - SimpleTest.executeSoon has a codepath that delegates to setTimeout, so // is less reliable if it ever decides to switch to that codepath. - // - SpecialPowers.executeSoon dispatches a task to main thread. However, - // normal runnables may be preempted by input events and be executed in an - // unexpected order. // The other problem we need to deal with is the asynchronicity in the chrome // process. That is, we might request a snapshot before the chrome process has @@ -177,13 +169,13 @@ function* test(testDriver) { // Set up the child process events and callbacks var scroller = document.getElementById('scroller'); synthesizeNativeTouch(scroller, 10, 110, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT, null, 0); - RunAfterProcessedQueuedInputEvents(testDriver); + SpecialPowers.executeSoon(testDriver); for (var i = 1; i < 10; i++) { synthesizeNativeTouch(scroller, 10, 110 - (i * 10), SpecialPowers.DOMWindowUtils.TOUCH_CONTACT, null, 0); - RunAfterProcessedQueuedInputEvents(testDriver); + SpecialPowers.executeSoon(testDriver); } synthesizeNativeTouch(scroller, 10, 10, SpecialPowers.DOMWindowUtils.TOUCH_REMOVE, null, 0); - RunAfterProcessedQueuedInputEvents(testDriver); + SpecialPowers.executeSoon(testDriver); ok(true, "Finished setting up event queue"); // Get our baseline snapshot diff --git a/xpcom/threads/nsIRunnable.idl b/xpcom/threads/nsIRunnable.idl index df5f642cc1bb..44b71e516127 100644 --- a/xpcom/threads/nsIRunnable.idl +++ b/xpcom/threads/nsIRunnable.idl @@ -18,7 +18,7 @@ interface nsIRunnable : nsISupports void run(); }; -[scriptable, uuid(e75aa42a-80a9-11e6-afb5-e89d87348e2c)] +[uuid(e75aa42a-80a9-11e6-afb5-e89d87348e2c)] interface nsIRunnablePriority : nsISupports { const unsigned short PRIORITY_NORMAL = 0; diff --git a/xpcom/threads/nsIThreadManager.idl b/xpcom/threads/nsIThreadManager.idl index 2b72215c72bb..177687406d3d 100644 --- a/xpcom/threads/nsIThreadManager.idl +++ b/xpcom/threads/nsIThreadManager.idl @@ -92,7 +92,7 @@ interface nsIThreadManager : nsISupports * .currentThread.dispatch(runnable, Ci.nsIEventTarget.DISPATCH_NORMAL); * C++ callers should instead use NS_DispatchToMainThread. */ - void dispatchToMainThread(in nsIRunnable event, [optional] in uint32_t priority); + void dispatchToMainThread(in nsIRunnable event); /** * This queues a runnable to the main thread's idle queue. diff --git a/xpcom/threads/nsThreadManager.cpp b/xpcom/threads/nsThreadManager.cpp index cbfa92382c68..bd2d689aca37 100644 --- a/xpcom/threads/nsThreadManager.cpp +++ b/xpcom/threads/nsThreadManager.cpp @@ -386,7 +386,7 @@ nsThreadManager::GetHighestNumberOfThreads() } NS_IMETHODIMP -nsThreadManager::DispatchToMainThread(nsIRunnable *aEvent, uint32_t aPriority) +nsThreadManager::DispatchToMainThread(nsIRunnable *aEvent) { // Note: C++ callers should instead use NS_DispatchToMainThread. MOZ_ASSERT(NS_IsMainThread()); @@ -395,11 +395,7 @@ nsThreadManager::DispatchToMainThread(nsIRunnable *aEvent, uint32_t aPriority) if (NS_WARN_IF(!mMainThread)) { return NS_ERROR_NOT_INITIALIZED; } - if (aPriority != nsIRunnablePriority::PRIORITY_NORMAL) { - nsCOMPtr event(aEvent); - return mMainThread->DispatchFromScript( - new PrioritizableRunnable(event.forget(), aPriority), 0); - } + return mMainThread->DispatchFromScript(aEvent, 0); } diff --git a/xpcom/threads/nsThreadUtils.cpp b/xpcom/threads/nsThreadUtils.cpp index 2810f951eaed..26c25d12b6e1 100644 --- a/xpcom/threads/nsThreadUtils.cpp +++ b/xpcom/threads/nsThreadUtils.cpp @@ -88,47 +88,6 @@ already_AddRefed CreateTimer() } // namespace detail } // namespace mozilla -NS_IMPL_ISUPPORTS_INHERITED(PrioritizableRunnable, Runnable, - nsIRunnablePriority) - -PrioritizableRunnable::PrioritizableRunnable(already_AddRefed&& aRunnable, - uint32_t aPriority) - // Real runnable name is managed by overridding the GetName function. - : Runnable("PrioritizableRunnable") - , mRunnable(Move(aRunnable)) - , mPriority(aPriority) -{ -#if DEBUG - nsCOMPtr runnablePrio = do_QueryInterface(mRunnable); - MOZ_ASSERT(!runnablePrio); -#endif -} - -NS_IMETHODIMP -PrioritizableRunnable::GetName(nsACString& aName) -{ - // Try to get a name from the underlying runnable. - nsCOMPtr named = do_QueryInterface(mRunnable); - if (named) { - named->GetName(aName); - } - return NS_OK; -} - -NS_IMETHODIMP -PrioritizableRunnable::Run() -{ - MOZ_RELEASE_ASSERT(NS_IsMainThread()); - return mRunnable->Run(); -} - -NS_IMETHODIMP -PrioritizableRunnable::GetPriority(uint32_t* aPriority) -{ - *aPriority = mPriority; - return NS_OK; -} - #endif // XPCOM_GLUE_AVOID_NSPR //----------------------------------------------------------------------------- diff --git a/xpcom/threads/nsThreadUtils.h b/xpcom/threads/nsThreadUtils.h index 7f565c04bdb5..e8b11fde75f6 100644 --- a/xpcom/threads/nsThreadUtils.h +++ b/xpcom/threads/nsThreadUtils.h @@ -486,26 +486,6 @@ private: IdleRunnable& operator=(const IdleRunnable&&) = delete; }; -// This class is designed to be a wrapper of a real runnable to support event -// prioritizable. -class PrioritizableRunnable : public Runnable, public nsIRunnablePriority -{ -public: - PrioritizableRunnable(already_AddRefed&& aRunnable, - uint32_t aPriority); - - NS_IMETHOD GetName(nsACString& aName) override; - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIRUNNABLE - NS_DECL_NSIRUNNABLEPRIORITY - -protected: - virtual ~PrioritizableRunnable() {}; - nsCOMPtr mRunnable; - uint32_t mPriority; -}; - namespace detail { // An event that can be used to call a C++11 functions or function objects,