зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1297472 - Improve nsIScriptTimeoutHandler::GetHandlerText(), r=bz
This commit is contained in:
Родитель
60d03b201e
Коммит
1738225353
|
@ -12218,8 +12218,7 @@ nsGlobalWindow::RunTimeoutHandler(nsTimeout* aTimeout,
|
|||
RefPtr<Function> callback = handler->GetCallback();
|
||||
if (!callback) {
|
||||
// Evaluate the timeout expression.
|
||||
nsAutoString script;
|
||||
handler->GetHandlerText(script);
|
||||
const nsAString& script = handler->GetHandlerText();
|
||||
|
||||
const char* filename = nullptr;
|
||||
uint32_t lineNo = 0, dummyColumn = 0;
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
virtual mozilla::dom::Function *GetCallback() = 0;
|
||||
|
||||
// Get the handler text of not a compiled object.
|
||||
virtual void GetHandlerText(nsAString& aString) = 0;
|
||||
virtual const nsAString& GetHandlerText() = 0;
|
||||
|
||||
// Get the location of the script.
|
||||
// Note: The memory pointed to by aFileName is owned by the
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
nsJSScriptTimeoutHandler(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
|
||||
const nsAString& aExpression);
|
||||
|
||||
virtual void GetHandlerText(nsAString& aString) override;
|
||||
virtual const nsAString& GetHandlerText() override;
|
||||
virtual Function* GetCallback() override
|
||||
{
|
||||
return mFunction;
|
||||
|
@ -308,11 +308,11 @@ nsJSScriptTimeoutHandler::ReleaseJSObjects()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsJSScriptTimeoutHandler::GetHandlerText(nsAString& aString)
|
||||
const nsAString&
|
||||
nsJSScriptTimeoutHandler::GetHandlerText()
|
||||
{
|
||||
NS_ASSERTION(!mFunction, "No expression, so no handler text!");
|
||||
aString = mExpr;
|
||||
return mExpr;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIScriptTimeoutHandler>
|
||||
|
|
|
@ -5920,8 +5920,7 @@ WorkerPrivate::RunExpiredTimeouts(JSContext* aCx)
|
|||
AutoEntryScript aes(global, reason, false);
|
||||
|
||||
// Evaluate the timeout expression.
|
||||
nsAutoString script;
|
||||
info->mHandler->GetHandlerText(script);
|
||||
const nsAString& script = info->mHandler->GetHandlerText();
|
||||
|
||||
const char* filename = nullptr;
|
||||
uint32_t lineNo = 0, dummyColumn = 0;
|
||||
|
@ -5932,7 +5931,7 @@ WorkerPrivate::RunExpiredTimeouts(JSContext* aCx)
|
|||
|
||||
JS::Rooted<JS::Value> unused(aes.cx());
|
||||
|
||||
if (!JS::Evaluate(aes.cx(), options, script.get(),
|
||||
if (!JS::Evaluate(aes.cx(), options, script.BeginReading(),
|
||||
script.Length(), &unused) &&
|
||||
!JS_IsExceptionPending(aCx)) {
|
||||
retval = false;
|
||||
|
|
Загрузка…
Ссылка в новой задаче