mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-12-28 11:32:05 +00:00
#463: add IdleRequestCallback to nsTimeout
This commit is contained in:
parent
48db0951b8
commit
14b7123a72
@ -11537,10 +11537,20 @@ nsGlobalWindow::SetInterval(JSContext* aCx, const nsAString& aHandler,
|
||||
return SetTimeoutOrInterval(aCx, aHandler, timeout, isInterval, aError);
|
||||
}
|
||||
|
||||
// TenFourFox issue 463
|
||||
nsresult
|
||||
nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
|
||||
int32_t interval,
|
||||
bool aIsInterval, int32_t *aReturn)
|
||||
{
|
||||
return SetTimeoutOrIntervalOrIdleCallback(aHandler, interval, aIsInterval, aReturn, nullptr);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGlobalWindow::SetTimeoutOrIntervalOrIdleCallback(nsIScriptTimeoutHandler *aHandler,
|
||||
int32_t interval,
|
||||
bool aIsInterval, int32_t *aReturn,
|
||||
mozilla::dom::IdleRequestCallback *aCallback)
|
||||
{
|
||||
MOZ_ASSERT(IsInnerWindow());
|
||||
|
||||
@ -11565,7 +11575,10 @@ nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
|
||||
RefPtr<nsTimeout> timeout = new nsTimeout();
|
||||
timeout->mIsInterval = aIsInterval;
|
||||
timeout->mInterval = interval;
|
||||
timeout->mScriptHandler = aHandler;
|
||||
if (aCallback)
|
||||
timeout->mCallback = aCallback;
|
||||
else
|
||||
timeout->mScriptHandler = aHandler;
|
||||
|
||||
// Now clamp the actual interval we will use for the timer based on
|
||||
uint32_t nestingLevel = sNestingLevel + 1;
|
||||
@ -11754,6 +11767,13 @@ nsGlobalWindow::RunTimeoutHandler(nsTimeout* aTimeout,
|
||||
reason = "setTimeout handler";
|
||||
}
|
||||
|
||||
if (!timeout->mScriptHandler) {
|
||||
// Time to assess the conditions for requestIdleCallback (issue 463).
|
||||
MOZ_ASSERT(timeout->mCallback);
|
||||
MOZ_CRASH("RunTimeoutHandler triggered on requestIdleCallback");
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptTimeoutHandler> handler(timeout->mScriptHandler);
|
||||
RefPtr<Function> callback = handler->GetCallback();
|
||||
if (!callback) {
|
||||
|
@ -211,7 +211,10 @@ public:
|
||||
PopupControlState mPopupState;
|
||||
|
||||
// The language-specific information about the callback.
|
||||
// If there is an nsIScriptTimeoutHandler, this is a regular setTimeout.
|
||||
// If there is an IdleRequestCallback, this is requestIdleCallback (issue 463).
|
||||
nsCOMPtr<nsIScriptTimeoutHandler> mScriptHandler;
|
||||
RefPtr<mozilla::dom::IdleRequestCallback> mCallback;
|
||||
};
|
||||
|
||||
struct IdleObserverHolder
|
||||
@ -1411,6 +1414,12 @@ public:
|
||||
nsresult SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
|
||||
int32_t interval,
|
||||
bool aIsInterval, int32_t* aReturn) override;
|
||||
// TenFourFox issue 463
|
||||
nsresult SetTimeoutOrIntervalOrIdleCallback(nsIScriptTimeoutHandler *aHandler,
|
||||
int32_t interval,
|
||||
bool aIsInterval, int32_t *aReturn,
|
||||
mozilla::dom::IdleRequestCallback *aCallback);
|
||||
|
||||
int32_t SetTimeoutOrInterval(JSContext* aCx,
|
||||
mozilla::dom::Function& aFunction,
|
||||
int32_t aTimeout,
|
||||
|
Loading…
Reference in New Issue
Block a user