mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-11-19 02:13:04 +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);
|
return SetTimeoutOrInterval(aCx, aHandler, timeout, isInterval, aError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TenFourFox issue 463
|
||||||
nsresult
|
nsresult
|
||||||
nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
|
nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
|
||||||
int32_t interval,
|
int32_t interval,
|
||||||
bool aIsInterval, int32_t *aReturn)
|
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());
|
MOZ_ASSERT(IsInnerWindow());
|
||||||
|
|
||||||
@ -11565,7 +11575,10 @@ nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
|
|||||||
RefPtr<nsTimeout> timeout = new nsTimeout();
|
RefPtr<nsTimeout> timeout = new nsTimeout();
|
||||||
timeout->mIsInterval = aIsInterval;
|
timeout->mIsInterval = aIsInterval;
|
||||||
timeout->mInterval = interval;
|
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
|
// Now clamp the actual interval we will use for the timer based on
|
||||||
uint32_t nestingLevel = sNestingLevel + 1;
|
uint32_t nestingLevel = sNestingLevel + 1;
|
||||||
@ -11754,6 +11767,13 @@ nsGlobalWindow::RunTimeoutHandler(nsTimeout* aTimeout,
|
|||||||
reason = "setTimeout handler";
|
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);
|
nsCOMPtr<nsIScriptTimeoutHandler> handler(timeout->mScriptHandler);
|
||||||
RefPtr<Function> callback = handler->GetCallback();
|
RefPtr<Function> callback = handler->GetCallback();
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
|
@ -211,7 +211,10 @@ public:
|
|||||||
PopupControlState mPopupState;
|
PopupControlState mPopupState;
|
||||||
|
|
||||||
// The language-specific information about the callback.
|
// 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;
|
nsCOMPtr<nsIScriptTimeoutHandler> mScriptHandler;
|
||||||
|
RefPtr<mozilla::dom::IdleRequestCallback> mCallback;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IdleObserverHolder
|
struct IdleObserverHolder
|
||||||
@ -1411,6 +1414,12 @@ public:
|
|||||||
nsresult SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
|
nsresult SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
|
||||||
int32_t interval,
|
int32_t interval,
|
||||||
bool aIsInterval, int32_t* aReturn) override;
|
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,
|
int32_t SetTimeoutOrInterval(JSContext* aCx,
|
||||||
mozilla::dom::Function& aFunction,
|
mozilla::dom::Function& aFunction,
|
||||||
int32_t aTimeout,
|
int32_t aTimeout,
|
||||||
|
Loading…
Reference in New Issue
Block a user