Bug 824864 - Remove unused optional arguments from nsIScriptContext::ExecuteScript. r=bz
authorBobby Holley <bobbyholley@gmail.com>
Wed, 16 Jan 2013 18:50:26 -0800
changeset 128983 badfbc904df619eb05a11de038eed1c9975ee554
parent 128982 22dc6532b40b06d9921dc4b366a0212838376b90
child 128984 43458e543877f651e213bd9fb1c6cefe67279ccc
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs824864
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
dom/base/nsIScriptContext.h
dom/base/nsJSEnvironment.cpp
dom/base/nsJSEnvironment.h
--- a/content/xul/document/src/nsXULDocument.cpp
+++ b/content/xul/document/src/nsXULDocument.cpp
@@ -3535,17 +3535,17 @@ nsXULDocument::ExecuteScript(nsIScriptCo
     NS_PRECONDITION(aScriptObject != nullptr && aContext != nullptr, "null ptr");
     if (! aScriptObject || ! aContext)
         return NS_ERROR_NULL_POINTER;
 
     NS_ENSURE_TRUE(mScriptGlobalObject, NS_ERROR_NOT_INITIALIZED);
 
     // 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
 nsXULDocument::ExecuteScript(nsXULPrototypeScript *aScript)
 {
     NS_PRECONDITION(aScript != nullptr, "null ptr");
     NS_ENSURE_TRUE(aScript, NS_ERROR_NULL_POINTER);
     NS_ENSURE_TRUE(mScriptGlobalObject, NS_ERROR_NOT_INITIALIZED);
--- a/dom/base/nsIScriptContext.h
+++ b/dom/base/nsIScriptContext.h
@@ -114,19 +114,17 @@ public:
    *                  which case no result string is computed
    * @param aIsUndefined true if the result of executing the script is the
    *                     undefined value, may be null for "don't care"
    *
    * @return NS_OK if the script was valid and got executed
    *
    */
   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
    * into a function object returned if ok via aHandler.  Does NOT bind the
    * function to anything - BindCompiledEventHandler() should be used for that
    * purpose.  Note that this event handler is always considered 'shared' and
    * hence is compiled without principals.  Never call the returned object
    * directly - it must be bound (and thereby cloned, and therefore have the 
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -1311,66 +1311,16 @@ nsJSContext::EvaluateStringWithValue(con
 
   // ScriptEvaluated needs to come after we pop the stack
   ScriptEvaluated(true);
 
   return rv;
 
 }
 
-// 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()
 {
   nsCOMPtr<nsIScriptObjectPrincipal> prin = do_QueryInterface(GetGlobalObject());
   return prin;
 }
 
 nsresult
@@ -1426,31 +1376,21 @@ nsJSContext::CompileScript(const PRUnich
   if (!script) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
   return aScriptObject.set(script);
 }
 
 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;
   }
 
   nsAutoMicroTask mt;
 
   if (!aScopeObject) {
     aScopeObject = JS_GetGlobalObject(mContext);
   }
@@ -1470,32 +1410,18 @@ nsJSContext::ExecuteScript(JSScript* aSc
   nsJSContext::TerminationFuncHolder holder(this);
   XPCAutoRequest ar(mContext);
   ++mExecuteDepth;
 
   // The result of evaluation, used only if there were no errors. This need
   // 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.
   if (NS_FAILED(stack->Pop(nullptr)))
     rv = NS_ERROR_FAILURE;
 
   // ScriptEvaluated needs to come after we pop the stack
   ScriptEvaluated(true);
--- a/dom/base/nsJSEnvironment.h
+++ b/dom/base/nsJSEnvironment.h
@@ -54,19 +54,17 @@ public:
                                  int32_t aTextLength,
                                  nsIPrincipal *principal,
                                  const char *aURL,
                                  uint32_t aLineNo,
                                  uint32_t aVersion,
                                  nsScriptObjectHolder<JSScript>& 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,
                                        const char** aArgNames,
                                        const nsAString& aBody,
                                        const char *aURL, uint32_t aLineNo,
                                        uint32_t aVersion,
                                        bool aIsXBL,