From 5dfabb90ca36834b20802a50989df83247860dd6 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 16 Jan 2013 18:50:26 -0800 Subject: [PATCH] Bug 824864 - Remove unused optional arguments from nsIScriptContext::ExecuteScript. r=bz This lets us get rid of a bunch of junk. --- content/xul/document/src/nsXULDocument.cpp | 2 +- dom/base/nsIScriptContext.h | 4 +- dom/base/nsJSEnvironment.cpp | 78 +--------------------- dom/base/nsJSEnvironment.h | 4 +- 4 files changed, 5 insertions(+), 83 deletions(-) diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index dfdffbd5797..03bd77b75d6 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -3540,7 +3540,7 @@ nsXULDocument::ExecuteScript(nsIScriptContext * aContext, JSScript* aScriptObjec // Execute the precompiled script with the given version JSObject* global = mScriptGlobalObject->GetGlobalJSObject(); - return aContext->ExecuteScript(aScriptObject, global, nullptr, nullptr); + return aContext->ExecuteScript(aScriptObject, global); } nsresult diff --git a/dom/base/nsIScriptContext.h b/dom/base/nsIScriptContext.h index bcce9b41469..56e90c996b8 100644 --- a/dom/base/nsIScriptContext.h +++ b/dom/base/nsIScriptContext.h @@ -119,9 +119,7 @@ public: * */ virtual nsresult ExecuteScript(JSScript* aScriptObject, - JSObject* aScopeObject, - nsAString* aRetValue, - bool* aIsUndefined) = 0; + JSObject* aScopeObject) = 0; /** * Compile the event handler named by atom aName, with function body aBody diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index a4d5b26a0e8..1a900f68695 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -1316,56 +1316,6 @@ nsJSContext::EvaluateStringWithValue(const nsAString& aScript, } -// Helper function to convert a jsval to an nsAString, and set -// exception flags if the conversion fails. -static nsresult -JSValueToAString(JSContext *cx, jsval val, nsAString *result, - bool *isUndefined) -{ - if (isUndefined) { - *isUndefined = JSVAL_IS_VOID(val); - } - - if (!result) { - return NS_OK; - } - - JSString* jsstring = ::JS_ValueToString(cx, val); - if (!jsstring) { - goto error; - } - - size_t length; - const jschar *chars; - chars = ::JS_GetStringCharsAndLength(cx, jsstring, &length); - if (!chars) { - goto error; - } - - result->Assign(chars, length); - return NS_OK; - -error: - // We failed to convert val to a string. We're either OOM, or the - // security manager denied access to .toString(), or somesuch, on - // an object. Treat this case as if the result were undefined. - - result->Truncate(); - - if (isUndefined) { - *isUndefined = true; - } - - if (!::JS_IsExceptionPending(cx)) { - // JS_ValueToString()/JS_GetStringCharsAndLength returned null w/o an - // exception pending. That means we're OOM. - - return NS_ERROR_OUT_OF_MEMORY; - } - - return NS_OK; -} - nsIScriptObjectPrincipal* nsJSContext::GetObjectPrincipal() { @@ -1431,21 +1381,11 @@ nsJSContext::CompileScript(const PRUnichar* aText, nsresult nsJSContext::ExecuteScript(JSScript* aScriptObject, - JSObject* aScopeObject, - nsAString* aRetValue, - bool* aIsUndefined) + JSObject* aScopeObject) { NS_ENSURE_TRUE(mIsInitialized, NS_ERROR_NOT_INITIALIZED); if (!mScriptsEnabled) { - if (aIsUndefined) { - *aIsUndefined = true; - } - - if (aRetValue) { - aRetValue->Truncate(); - } - return NS_OK; } @@ -1475,22 +1415,8 @@ nsJSContext::ExecuteScript(JSScript* aScriptObject, // not be a GC root currently, provided we run the GC only from the // operation callback or from ScriptEvaluated. jsval val; - bool ok = JS_ExecuteScript(mContext, aScopeObject, aScriptObject, &val); - if (ok) { - // If all went well, convert val to a string (XXXbe unless undefined?). - rv = JSValueToAString(mContext, val, aRetValue, aIsUndefined); - } else { + if (!JS_ExecuteScript(mContext, aScopeObject, aScriptObject, &val)) ReportPendingException(); - - if (aIsUndefined) { - *aIsUndefined = true; - } - - if (aRetValue) { - aRetValue->Truncate(); - } - } - --mExecuteDepth; // Pop here, after JS_ValueToString and any other possible evaluation. diff --git a/dom/base/nsJSEnvironment.h b/dom/base/nsJSEnvironment.h index 19ab28ec65c..b097f12f2f2 100644 --- a/dom/base/nsJSEnvironment.h +++ b/dom/base/nsJSEnvironment.h @@ -59,9 +59,7 @@ public: nsScriptObjectHolder& aScriptObject, bool aSaveSource = false); virtual nsresult ExecuteScript(JSScript* aScriptObject, - JSObject* aScopeObject, - nsAString* aRetValue, - bool* aIsUndefined); + JSObject* aScopeObject); virtual nsresult CompileEventHandler(nsIAtom *aName, uint32_t aArgCount,