From fb9a3df8f48e98df829a8c15982a5a0d26f1b22e Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 29 Oct 2011 22:13:31 +0200 Subject: [PATCH] Bug 694867 - Part b: Pass a JSScript to nsXULPrototypeScript::Set; r=volkmar --- content/xul/content/src/nsXULElement.cpp | 7 ++++--- content/xul/content/src/nsXULElement.h | 4 ++-- content/xul/document/src/nsXULDocument.cpp | 7 ++++--- dom/base/nsDOMScriptObjectHolder.h | 5 +++++ 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index a8a3ce282241..01833e1d7620 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -3039,7 +3039,8 @@ nsXULPrototypeScript::DeserializeOutOfLine(nsIObjectInputStream* aInput, if (useXULCache) { PRUint32 newLangID = nsIProgrammingLanguage::UNKNOWN; - void *newScriptObject = cache->GetScript(mSrcURI, &newLangID); + JSScript* newScriptObject = + static_cast(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(aObject); + mScriptObject.mObject = aObject; } } diff --git a/content/xul/content/src/nsXULElement.h b/content/xul/content/src/nsXULElement.h index dc7fa555e65d..85627351467e 100644 --- a/content/xul/content/src/nsXULElement.h +++ b/content/xul/content/src/nsXULElement.h @@ -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 { diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 04ec6d97c430..92c5c3ff598a 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -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( + 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. diff --git a/dom/base/nsDOMScriptObjectHolder.h b/dom/base/nsDOMScriptObjectHolder.h index d4dad35f1138..cbcefec4fef0 100644 --- a/dom/base/nsDOMScriptObjectHolder.h +++ b/dom/base/nsDOMScriptObjectHolder.h @@ -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(mObject); + } // Drop the script object - but *not* the nsIScriptContext. nsresult drop() {