Bug 694867 - Part b: Pass a JSScript to nsXULPrototypeScript::Set; r=volkmar

This commit is contained in:
Ms2ger 2011-10-29 22:13:31 +02:00
parent 6bc6ac23b6
commit e566d3ad18
4 changed files with 15 additions and 8 deletions

View File

@ -3039,7 +3039,8 @@ nsXULPrototypeScript::DeserializeOutOfLine(nsIObjectInputStream* aInput,
if (useXULCache) {
PRUint32 newLangID = nsIProgrammingLanguage::UNKNOWN;
void *newScriptObject = cache->GetScript(mSrcURI, &newLangID);
JSScript* newScriptObject =
static_cast<JSScript*>(cache->GetScript(mSrcURI, &newLangID));
if (newScriptObject) {
// Things may blow here if we simply change the script
// language - other code may already have pre-fetched the
@ -3170,7 +3171,7 @@ nsXULPrototypeScript::UnlinkJSObjects()
}
void
nsXULPrototypeScript::Set(void *aObject)
nsXULPrototypeScript::Set(JSScript* aObject)
{
NS_ASSERTION(!mScriptObject.mObject, "Leaking script object.");
if (!aObject) {
@ -3184,7 +3185,7 @@ nsXULPrototypeScript::Set(void *aObject)
&NS_CYCLE_COLLECTION_NAME(nsXULPrototypeNode),
aObject, false);
if (NS_SUCCEEDED(rv)) {
mScriptObject.mObject = static_cast<JSScript*>(aObject);
mScriptObject.mObject = aObject;
}
}

View File

@ -342,9 +342,9 @@ public:
"Wrong language, this will leak the previous object.");
mScriptObject.mLangID = aHolder.getScriptTypeID();
Set((void*)aHolder);
Set(aHolder.getScript());
}
void Set(void *aObject);
void Set(JSScript* aObject);
struct ScriptObjectHolder
{

View File

@ -3383,10 +3383,11 @@ nsXULDocument::LoadScript(nsXULPrototypeScript* aScriptProto, bool* aBlock)
if (isChromeDoc && useXULCache) {
PRUint32 fetchedLang = nsIProgrammingLanguage::UNKNOWN;
void *newScriptObject =
nsXULPrototypeCache::GetInstance()->GetScript(
JSScript* newScriptObject =
static_cast<JSScript*>(
nsXULPrototypeCache::GetInstance()->GetScript(
aScriptProto->mSrcURI,
&fetchedLang);
&fetchedLang));
if (newScriptObject) {
// The script language for a proto must remain constant - we
// can't just change it for this unexpected language.

View File

@ -42,6 +42,8 @@
#include "nsIScriptContext.h"
#include "nsIDOMScriptObjectFactory.h"
#include "jspubtd.h"
// A thin class used to help with script object memory management. No virtual
// functions and a fully inline implementation should keep the cost down.
// [Note that a fully inline implementation is necessary for use by other
@ -81,6 +83,9 @@ public:
operator void *() const {
return mObject;
}
JSScript* getScript() const {
return static_cast<JSScript*>(mObject);
}
// Drop the script object - but *not* the nsIScriptContext.
nsresult drop() {