Bug 734472 - Pass JSObject to nsIScriptContext::SetProperty; r=jst

This commit is contained in:
Ms2ger 2012-03-11 09:50:22 +01:00
Родитель a2f1032bc7
Коммит edfd0f9e25
3 изменённых файлов: 12 добавлений и 14 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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<nsRootedJSValueArray> 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<JSObject *>(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<nsIArray> 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<nsISupports> arg;
jsval *thisval = argv + argCtr;
argsArray->QueryElementAt(argCtr, NS_GET_IID(nsISupports),

Просмотреть файл

@ -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);