Backed out changeset 1662b38e3107 (bug 1351148)

This commit is contained in:
Carsten "Tomcat" Book 2017-07-28 09:20:23 +02:00
Родитель 2ff6df9177
Коммит 6ddad46b40
7 изменённых файлов: 44 добавлений и 143 удалений

Просмотреть файл

@ -175,30 +175,6 @@ private:
nsSize mSize;
};
namespace {
class NativeInputRunnable final : public PrioritizableRunnable
{
explicit NativeInputRunnable(already_AddRefed<nsIRunnable>&& aEvent);
~NativeInputRunnable() {}
public:
static already_AddRefed<nsIRunnable> Create(already_AddRefed<nsIRunnable>&& aEvent);
};
NativeInputRunnable::NativeInputRunnable(already_AddRefed<nsIRunnable>&& aEvent)
: PrioritizableRunnable(Move(aEvent), nsIRunnablePriority::PRIORITY_INPUT)
{
}
/* static */ already_AddRefed<nsIRunnable>
NativeInputRunnable::Create(already_AddRefed<nsIRunnable>&& aEvent)
{
nsCOMPtr<nsIRunnable> event(new NativeInputRunnable(Move(aEvent)));
return event.forget();
}
} // unnamed namespace
LinkedList<OldWindowSize> 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<int32_t,
int32_t,
uint32_t,
@ -1158,7 +1134,7 @@ nsDOMWindowUtils::SendNativeKeyEvent(int32_t aNativeKeyboardLayout,
aModifiers,
aCharacters,
aUnmodifiedCharacters,
aObserver)));
aObserver));
return NS_OK;
}
@ -1175,7 +1151,7 @@ nsDOMWindowUtils::SendNativeMouseEvent(int32_t aScreenX,
if (!widget)
return NS_ERROR_FAILURE;
NS_DispatchToMainThread(NativeInputRunnable::Create(
NS_DispatchToMainThread(
NewRunnableMethod<LayoutDeviceIntPoint, int32_t, int32_t, nsIObserver*>(
"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<LayoutDeviceIntPoint, nsIObserver*>(
"nsIWidget::SynthesizeNativeMouseMove",
widget,
&nsIWidget::SynthesizeNativeMouseMove,
LayoutDeviceIntPoint(aScreenX, aScreenY),
aObserver)));
NS_DispatchToMainThread(NewRunnableMethod<LayoutDeviceIntPoint, nsIObserver*>(
"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<mozilla::LayoutDeviceIntPoint,
uint32_t,
double,
double,
double,
uint32_t,
uint32_t,
nsIObserver*>(
"nsIWidget::SynthesizeNativeMouseScrollEvent",
widget,
&nsIWidget::SynthesizeNativeMouseScrollEvent,
LayoutDeviceIntPoint(aScreenX, aScreenY),
aNativeMessage,
aDeltaX,
aDeltaY,
aDeltaZ,
aModifierFlags,
aAdditionalFlags,
aObserver)));
NS_DispatchToMainThread(NewRunnableMethod<mozilla::LayoutDeviceIntPoint,
uint32_t,
double,
double,
double,
uint32_t,
uint32_t,
nsIObserver*>(
"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<uint32_t,
nsIWidget::TouchPointerState,
LayoutDeviceIntPoint,
@ -1281,7 +1255,7 @@ nsDOMWindowUtils::SendNativeTouchPoint(uint32_t aPointerId,
LayoutDeviceIntPoint(aScreenX, aScreenY),
aPressure,
aOrientation,
aObserver)));
aObserver));
return NS_OK;
}
@ -1296,14 +1270,14 @@ nsDOMWindowUtils::SendNativeTouchTap(int32_t aScreenX,
return NS_ERROR_FAILURE;
}
NS_DispatchToMainThread(NativeInputRunnable::Create(
NS_DispatchToMainThread(
NewRunnableMethod<LayoutDeviceIntPoint, bool, nsIObserver*>(
"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<nsIObserver*>("nsIWidget::ClearNativeTouchSequence",
widget,
&nsIWidget::ClearNativeTouchSequence,
aObserver)));
aObserver));
return NS_OK;
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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;

Просмотреть файл

@ -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.

Просмотреть файл

@ -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<nsIRunnable> event(aEvent);
return mMainThread->DispatchFromScript(
new PrioritizableRunnable(event.forget(), aPriority), 0);
}
return mMainThread->DispatchFromScript(aEvent, 0);
}

Просмотреть файл

@ -88,47 +88,6 @@ already_AddRefed<nsITimer> CreateTimer()
} // namespace detail
} // namespace mozilla
NS_IMPL_ISUPPORTS_INHERITED(PrioritizableRunnable, Runnable,
nsIRunnablePriority)
PrioritizableRunnable::PrioritizableRunnable(already_AddRefed<nsIRunnable>&& aRunnable,
uint32_t aPriority)
// Real runnable name is managed by overridding the GetName function.
: Runnable("PrioritizableRunnable")
, mRunnable(Move(aRunnable))
, mPriority(aPriority)
{
#if DEBUG
nsCOMPtr<nsIRunnablePriority> runnablePrio = do_QueryInterface(mRunnable);
MOZ_ASSERT(!runnablePrio);
#endif
}
NS_IMETHODIMP
PrioritizableRunnable::GetName(nsACString& aName)
{
// Try to get a name from the underlying runnable.
nsCOMPtr<nsINamed> 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
//-----------------------------------------------------------------------------

Просмотреть файл

@ -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<nsIRunnable>&& aRunnable,
uint32_t aPriority);
NS_IMETHOD GetName(nsACString& aName) override;
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIRUNNABLE
NS_DECL_NSIRUNNABLEPRIORITY
protected:
virtual ~PrioritizableRunnable() {};
nsCOMPtr<nsIRunnable> mRunnable;
uint32_t mPriority;
};
namespace detail {
// An event that can be used to call a C++11 functions or function objects,