From edfd0f9e253dd70c4e2123c2cbe4e486d3e499a4 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sun, 11 Mar 2012 09:50:22 +0100 Subject: [PATCH] Bug 734472 - Pass JSObject to nsIScriptContext::SetProperty; r=jst --- dom/base/nsIScriptContext.h | 6 +++--- dom/base/nsJSEnvironment.cpp | 18 ++++++++---------- dom/base/nsJSEnvironment.h | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/dom/base/nsIScriptContext.h b/dom/base/nsIScriptContext.h index d388ade667f..14cc2e9132d 100644 --- a/dom/base/nsIScriptContext.h +++ b/dom/base/nsIScriptContext.h @@ -76,8 +76,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptContextPrincipal, NS_ISCRIPTCONTEXTPRINCIPAL_IID) #define NS_ISCRIPTCONTEXT_IID \ -{ 0xb0eca8ac, 0x2a77, 0x4d04, \ - { 0xaf, 0x71, 0xca, 0x86, 0x98, 0xa4, 0xc3, 0xe7 } } +{ 0x6a536a37, 0x9773, 0x467e, \ + { 0x93, 0xb2, 0xdb, 0xe6, 0xe6, 0xec, 0x24, 0xc3 } } /* This MUST match JSVERSION_DEFAULT. This version stuff if we don't know what language we have is a little silly... */ @@ -401,7 +401,7 @@ public: // SetProperty is suspect and jst believes should not be needed. Currenly // used only for "arguments". - virtual nsresult SetProperty(void *aTarget, const char *aPropName, nsISupports *aVal) = 0; + virtual nsresult SetProperty(JSObject* aTarget, const char* aPropName, nsISupports* aVal) = 0; /** * Called to set/get information if the script context is * currently processing a script tag diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 371423ef9dc..71a63b63e10 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -2293,7 +2293,7 @@ nsJSContext::InitializeExternalClasses() } nsresult -nsJSContext::SetProperty(void *aTarget, const char *aPropName, nsISupports *aArgs) +nsJSContext::SetProperty(JSObject* aTarget, const char* aPropName, nsISupports* aArgs) { PRUint32 argc; jsval *argv = nsnull; @@ -2302,8 +2302,8 @@ nsJSContext::SetProperty(void *aTarget, const char *aPropName, nsISupports *aArg Maybe tempStorage; - nsresult rv; - rv = ConvertSupportsTojsvals(aArgs, GetNativeGlobal(), &argc, &argv, tempStorage); + nsresult rv = + ConvertSupportsTojsvals(aArgs, GetNativeGlobal(), &argc, &argv, tempStorage); NS_ENSURE_SUCCESS(rv, rv); jsval vargs; @@ -2327,11 +2327,9 @@ nsJSContext::SetProperty(void *aTarget, const char *aPropName, nsISupports *aArg // Make sure to use JS_DefineProperty here so that we can override // readonly XPConnect properties here as well (read dialogArguments). - rv = ::JS_DefineProperty(mContext, reinterpret_cast(aTarget), - aPropName, vargs, nsnull, nsnull, 0) ? - NS_OK : NS_ERROR_FAILURE; - - return rv; + return JS_DefineProperty(mContext, aTarget, aPropName, vargs, NULL, NULL, 0) + ? NS_OK + : NS_ERROR_FAILURE; } nsresult @@ -2360,7 +2358,7 @@ nsJSContext::ConvertSupportsTojsvals(nsISupports *aArgs, if (!aArgs) return NS_OK; - PRUint32 argCtr, argCount; + PRUint32 argCount; // This general purpose function may need to convert an arg array // (window.arguments, event-handler args) and a generic property. nsCOMPtr argsArray(do_QueryInterface(aArgs)); @@ -2381,7 +2379,7 @@ nsJSContext::ConvertSupportsTojsvals(nsISupports *aArgs, jsval *argv = aTempStorage.ref().Elements(); if (argsArray) { - for (argCtr = 0; argCtr < argCount && NS_SUCCEEDED(rv); argCtr++) { + for (PRUint32 argCtr = 0; argCtr < argCount && NS_SUCCEEDED(rv); argCtr++) { nsCOMPtr arg; jsval *thisval = argv + argCtr; argsArray->QueryElementAt(argCtr, NS_GET_IID(nsISupports), diff --git a/dom/base/nsJSEnvironment.h b/dom/base/nsJSEnvironment.h index 91fd110c5a0..55334fc386d 100644 --- a/dom/base/nsJSEnvironment.h +++ b/dom/base/nsJSEnvironment.h @@ -151,7 +151,7 @@ public: virtual bool GetScriptsEnabled(); virtual void SetScriptsEnabled(bool aEnabled, bool aFireTimeouts); - virtual nsresult SetProperty(void *aTarget, const char *aPropName, nsISupports *aVal); + virtual nsresult SetProperty(JSObject* aTarget, const char* aPropName, nsISupports* aVal); virtual bool GetProcessingScriptTag(); virtual void SetProcessingScriptTag(bool aResult);