зеркало из https://github.com/mozilla/pjs.git
Bug 744332 - Remove nsXULPrototypeScript::ScriptObjectHolder::mLangID. r=jst, f=Ms2ger
This commit is contained in:
Родитель
3f1cf1c796
Коммит
bb77f05714
|
@ -464,12 +464,13 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isJavaScript)
|
||||
typeID = nsIProgrammingLanguage::JAVASCRIPT;
|
||||
else {
|
||||
// Use the object factory to locate a matching language.
|
||||
nsCOMPtr<nsIScriptRuntime> runtime;
|
||||
rv = NS_GetScriptRuntime(mimeType, getter_AddRefs(runtime));
|
||||
rv = NS_GetJSRuntime(getter_AddRefs(runtime));
|
||||
if (NS_FAILED(rv) || runtime == nsnull) {
|
||||
// Failed to get the explicitly specified language
|
||||
NS_WARNING("Failed to find a scripting language");
|
||||
|
@ -477,6 +478,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
|
|||
} else
|
||||
typeID = nsIProgrammingLanguage::JAVASCRIPT;
|
||||
}
|
||||
|
||||
if (typeID != nsIProgrammingLanguage::UNKNOWN) {
|
||||
// Get the version string, and ensure the language supports it.
|
||||
nsAutoString versionName;
|
||||
|
@ -487,7 +489,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
|
|||
return false;
|
||||
} else {
|
||||
nsCOMPtr<nsIScriptRuntime> runtime;
|
||||
rv = NS_GetScriptRuntimeByID(typeID, getter_AddRefs(runtime));
|
||||
rv = NS_GetJSRuntime(getter_AddRefs(runtime));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Failed to locate the language with this ID");
|
||||
return false;
|
||||
|
|
|
@ -308,8 +308,7 @@ nsXBLDocGlobalObject::EnsureScriptEnvironment()
|
|||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIScriptRuntime> scriptRuntime;
|
||||
rv = NS_GetScriptRuntimeByID(nsIProgrammingLanguage::JAVASCRIPT,
|
||||
getter_AddRefs(scriptRuntime));
|
||||
rv = NS_GetJSRuntime(getter_AddRefs(scriptRuntime));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIScriptContext> newCtx = scriptRuntime->CreateContext();
|
||||
rv = SetScriptContext(newCtx);
|
||||
|
|
|
@ -2565,18 +2565,16 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_NATIVE_BEGIN(nsXULPrototypeNode)
|
|||
PRUint32 i;
|
||||
for (i = 0; i < elem->mNumAttributes; ++i) {
|
||||
JSObject* handler = elem->mAttributes[i].mEventHandler;
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_CALLBACK(nsIProgrammingLanguage::JAVASCRIPT,
|
||||
handler,
|
||||
"mAttributes[i].mEventHandler")
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(handler,
|
||||
"mAttributes[i].mEventHandler")
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tmp->mType == nsXULPrototypeNode::eType_Script) {
|
||||
nsXULPrototypeScript *script =
|
||||
static_cast<nsXULPrototypeScript*>(tmp);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_CALLBACK(script->mScriptObject.mLangID,
|
||||
script->mScriptObject.mObject,
|
||||
"mScriptObject.mObject")
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(script->mScriptObject.mObject,
|
||||
"mScriptObject.mObject")
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsXULPrototypeNode, AddRef)
|
||||
|
@ -2653,8 +2651,6 @@ nsXULPrototypeElement::Serialize(nsIObjectOutputStream* aStream,
|
|||
rv |= aStream->Write32(child->mType);
|
||||
nsXULPrototypeScript* script = static_cast<nsXULPrototypeScript*>(child);
|
||||
|
||||
rv |= aStream->Write32(script->mScriptObject.mLangID);
|
||||
|
||||
rv |= aStream->Write8(script->mOutOfLine);
|
||||
if (! script->mOutOfLine) {
|
||||
rv |= script->Serialize(aStream, aGlobal, aNodeInfos);
|
||||
|
@ -2760,11 +2756,8 @@ nsXULPrototypeElement::Deserialize(nsIObjectInputStream* aStream,
|
|||
aNodeInfos);
|
||||
break;
|
||||
case eType_Script: {
|
||||
PRUint32 langID = nsIProgrammingLanguage::UNKNOWN;
|
||||
rv |= aStream->Read32(&langID);
|
||||
|
||||
// language version/options obtained during deserialization.
|
||||
nsXULPrototypeScript* script = new nsXULPrototypeScript(langID, 0, 0);
|
||||
nsXULPrototypeScript* script = new nsXULPrototypeScript(0, 0);
|
||||
if (! script)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
child = script;
|
||||
|
@ -2882,17 +2875,15 @@ nsXULPrototypeElement::Unlink()
|
|||
// nsXULPrototypeScript
|
||||
//
|
||||
|
||||
nsXULPrototypeScript::nsXULPrototypeScript(PRUint32 aLangID, PRUint32 aLineNo, PRUint32 aVersion)
|
||||
nsXULPrototypeScript::nsXULPrototypeScript(PRUint32 aLineNo, PRUint32 aVersion)
|
||||
: nsXULPrototypeNode(eType_Script),
|
||||
mLineNo(aLineNo),
|
||||
mSrcLoading(false),
|
||||
mOutOfLine(true),
|
||||
mSrcLoadWaiters(nsnull),
|
||||
mLangVersion(aVersion),
|
||||
mScriptObject(aLangID)
|
||||
mScriptObject()
|
||||
{
|
||||
NS_ASSERTION(aLangID != nsIProgrammingLanguage::UNKNOWN,
|
||||
"The language ID must be known and constant");
|
||||
}
|
||||
|
||||
|
||||
|
@ -3023,23 +3014,10 @@ nsXULPrototypeScript::DeserializeOutOfLine(nsIObjectInputStream* aInput,
|
|||
useXULCache = cache->IsEnabled();
|
||||
|
||||
if (useXULCache) {
|
||||
PRUint32 newLangID = nsIProgrammingLanguage::UNKNOWN;
|
||||
JSScript* newScriptObject =
|
||||
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
|
||||
// global for the language. (You can see this code by
|
||||
// setting langID to UNKNOWN in the nsXULPrototypeScript
|
||||
// ctor and not setting it until the scriptObject is set -
|
||||
// code that pre-fetches these globals will then start
|
||||
// asserting.)
|
||||
if (mScriptObject.mLangID != newLangID) {
|
||||
NS_ERROR("XUL cache gave different language?");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
cache->GetScript(mSrcURI);
|
||||
if (newScriptObject)
|
||||
Set(newScriptObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3063,11 +3041,8 @@ nsXULPrototypeScript::DeserializeOutOfLine(nsIObjectInputStream* aInput,
|
|||
if (useXULCache && mSrcURI) {
|
||||
bool isChrome = false;
|
||||
mSrcURI->SchemeIs("chrome", &isChrome);
|
||||
if (isChrome) {
|
||||
cache->PutScript(mSrcURI,
|
||||
mScriptObject.mLangID,
|
||||
mScriptObject.mObject);
|
||||
}
|
||||
if (isChrome)
|
||||
cache->PutScript(mSrcURI, mScriptObject.mObject);
|
||||
}
|
||||
cache->FinishInputStream(mSrcURI);
|
||||
} else {
|
||||
|
|
|
@ -303,7 +303,7 @@ class nsXULDocument;
|
|||
class nsXULPrototypeScript : public nsXULPrototypeNode
|
||||
{
|
||||
public:
|
||||
nsXULPrototypeScript(PRUint32 aLangID, PRUint32 aLineNo, PRUint32 version);
|
||||
nsXULPrototypeScript(PRUint32 aLineNo, PRUint32 version);
|
||||
virtual ~nsXULPrototypeScript();
|
||||
|
||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||
|
@ -332,23 +332,18 @@ public:
|
|||
|
||||
void Set(nsScriptObjectHolder<JSScript>& aHolder)
|
||||
{
|
||||
NS_ASSERTION(mScriptObject.mLangID == aHolder.getScriptTypeID(),
|
||||
"Wrong language, this will leak the previous object.");
|
||||
|
||||
mScriptObject.mLangID = aHolder.getScriptTypeID();
|
||||
Set(aHolder.get());
|
||||
}
|
||||
void Set(JSScript* aObject);
|
||||
|
||||
struct ScriptObjectHolder
|
||||
{
|
||||
ScriptObjectHolder(PRUint32 aLangID) : mLangID(aLangID),
|
||||
mObject(nsnull)
|
||||
ScriptObjectHolder() : mObject(nsnull)
|
||||
{
|
||||
}
|
||||
PRUint32 mLangID;
|
||||
JSScript* mObject;
|
||||
};
|
||||
|
||||
nsCOMPtr<nsIURI> mSrcURI;
|
||||
PRUint32 mLineNo;
|
||||
bool mSrcLoading;
|
||||
|
|
|
@ -165,39 +165,6 @@ XULContentSinkImpl::ContextStack::GetTopChildren(nsPrototypeArray** aChildren)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
XULContentSinkImpl::ContextStack::GetTopNodeScriptType(PRUint32 *aScriptType)
|
||||
{
|
||||
if (mDepth == 0)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
// This would be much simpler if nsXULPrototypeNode itself
|
||||
// stored the language ID - but text elements don't need it!
|
||||
nsresult rv = NS_OK;
|
||||
nsRefPtr<nsXULPrototypeNode> node;
|
||||
rv = GetTopNode(node);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
switch (node->mType) {
|
||||
case nsXULPrototypeNode::eType_Element: {
|
||||
nsXULPrototypeElement *parent =
|
||||
reinterpret_cast<nsXULPrototypeElement*>(node.get());
|
||||
*aScriptType = nsIProgrammingLanguage::JAVASCRIPT;
|
||||
break;
|
||||
}
|
||||
case nsXULPrototypeNode::eType_Script: {
|
||||
nsXULPrototypeScript *parent =
|
||||
reinterpret_cast<nsXULPrototypeScript*>(node.get());
|
||||
*aScriptType = parent->mScriptObject.mLangID;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
NS_WARNING("Unexpected parent node type");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
XULContentSinkImpl::ContextStack::Clear()
|
||||
{
|
||||
|
@ -909,10 +876,9 @@ nsresult
|
|||
XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes,
|
||||
const PRUint32 aLineNumber)
|
||||
{
|
||||
PRUint32 langID;
|
||||
nsresult rv = mContextStack.GetTopNodeScriptType(&langID);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRUint32 langID = nsIProgrammingLanguage::JAVASCRIPT;
|
||||
PRUint32 version = 0;
|
||||
nsresult rv;
|
||||
|
||||
// Look for SRC attribute and look for a LANGUAGE attribute
|
||||
nsAutoString src;
|
||||
|
@ -964,7 +930,7 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes,
|
|||
} else {
|
||||
// Use the script object factory to locate the language.
|
||||
nsCOMPtr<nsIScriptRuntime> runtime;
|
||||
rv = NS_GetScriptRuntime(mimeType, getter_AddRefs(runtime));
|
||||
rv = NS_GetJSRuntime(getter_AddRefs(runtime));
|
||||
if (NS_FAILED(rv) || runtime == nsnull) {
|
||||
// Failed to get the explicitly specified language
|
||||
NS_WARNING("Failed to find a scripting language");
|
||||
|
@ -983,7 +949,7 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes,
|
|||
// no version specified - version remains the default.
|
||||
} else {
|
||||
nsCOMPtr<nsIScriptRuntime> runtime;
|
||||
rv = NS_GetScriptRuntimeByID(langID, getter_AddRefs(runtime));
|
||||
rv = NS_GetJSRuntime(getter_AddRefs(runtime));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = runtime->ParseVersion(versionName, &version);
|
||||
|
@ -1027,6 +993,7 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes,
|
|||
}
|
||||
aAttributes += 2;
|
||||
}
|
||||
|
||||
// Not all script languages have a "sandbox" concept. At time of
|
||||
// writing, Python is the only other language, and it does not.
|
||||
// For such languages, neither any inline script nor remote script are
|
||||
|
@ -1042,13 +1009,14 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes,
|
|||
langID = nsIProgrammingLanguage::UNKNOWN;
|
||||
NS_WARNING("Non JS language called from non chrome - ignored");
|
||||
}
|
||||
|
||||
// Don't process scripts that aren't known
|
||||
if (langID != nsIProgrammingLanguage::UNKNOWN) {
|
||||
nsIScriptGlobalObject* globalObject = nsnull; // borrowed reference
|
||||
if (doc)
|
||||
globalObject = doc->GetScriptGlobalObject();
|
||||
nsRefPtr<nsXULPrototypeScript> script =
|
||||
new nsXULPrototypeScript(langID, aLineNumber, version);
|
||||
new nsXULPrototypeScript(aLineNumber, version);
|
||||
if (! script)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
|
|
@ -162,7 +162,6 @@ protected:
|
|||
|
||||
nsresult GetTopNode(nsRefPtr<nsXULPrototypeNode>& aNode);
|
||||
nsresult GetTopChildren(nsPrototypeArray** aChildren);
|
||||
nsresult GetTopNodeScriptType(PRUint32 *aScriptType);
|
||||
|
||||
void Clear();
|
||||
};
|
||||
|
|
|
@ -3383,18 +3383,12 @@ nsXULDocument::LoadScript(nsXULPrototypeScript* aScriptProto, bool* aBlock)
|
|||
bool useXULCache = nsXULPrototypeCache::GetInstance()->IsEnabled();
|
||||
|
||||
if (isChromeDoc && useXULCache) {
|
||||
PRUint32 fetchedLang = nsIProgrammingLanguage::UNKNOWN;
|
||||
JSScript* newScriptObject =
|
||||
nsXULPrototypeCache::GetInstance()->GetScript(
|
||||
aScriptProto->mSrcURI,
|
||||
&fetchedLang);
|
||||
aScriptProto->mSrcURI);
|
||||
if (newScriptObject) {
|
||||
// The script language for a proto must remain constant - we
|
||||
// can't just change it for this unexpected language.
|
||||
if (aScriptProto->mScriptObject.mLangID != fetchedLang) {
|
||||
NS_ERROR("XUL cache gave me an incorrect script language");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
aScriptProto->Set(newScriptObject);
|
||||
}
|
||||
|
||||
|
@ -3558,7 +3552,6 @@ nsXULDocument::OnStreamComplete(nsIStreamLoader* aLoader,
|
|||
if (useXULCache && IsChromeURI(mDocumentURI)) {
|
||||
nsXULPrototypeCache::GetInstance()->PutScript(
|
||||
scriptProto->mSrcURI,
|
||||
scriptProto->mScriptObject.mLangID,
|
||||
scriptProto->mScriptObject.mObject);
|
||||
}
|
||||
|
||||
|
|
|
@ -227,14 +227,12 @@ nsXULPrototypeCache::PutStyleSheet(nsCSSStyleSheet* aStyleSheet)
|
|||
|
||||
|
||||
JSScript*
|
||||
nsXULPrototypeCache::GetScript(nsIURI* aURI, PRUint32 *aLangID)
|
||||
nsXULPrototypeCache::GetScript(nsIURI* aURI)
|
||||
{
|
||||
CacheScriptEntry entry;
|
||||
if (!mScriptTable.Get(aURI, &entry)) {
|
||||
*aLangID = nsIProgrammingLanguage::UNKNOWN;
|
||||
return nsnull;
|
||||
}
|
||||
*aLangID = entry.mScriptTypeID;
|
||||
return entry.mScriptObject;
|
||||
}
|
||||
|
||||
|
@ -244,13 +242,13 @@ static PLDHashOperator
|
|||
ReleaseScriptObjectCallback(nsIURI* aKey, CacheScriptEntry &aData, void* aClosure)
|
||||
{
|
||||
nsCOMPtr<nsIScriptRuntime> rt;
|
||||
if (NS_SUCCEEDED(NS_GetScriptRuntimeByID(aData.mScriptTypeID, getter_AddRefs(rt))))
|
||||
if (NS_SUCCEEDED(NS_GetJSRuntime(getter_AddRefs(rt))))
|
||||
rt->DropScriptObject(aData.mScriptObject);
|
||||
return PL_DHASH_REMOVE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXULPrototypeCache::PutScript(nsIURI* aURI, PRUint32 aLangID, JSScript* aScriptObject)
|
||||
nsXULPrototypeCache::PutScript(nsIURI* aURI, JSScript* aScriptObject)
|
||||
{
|
||||
CacheScriptEntry existingEntry;
|
||||
if (mScriptTable.Get(aURI, &existingEntry)) {
|
||||
|
@ -266,13 +264,13 @@ nsXULPrototypeCache::PutScript(nsIURI* aURI, PRUint32 aLangID, JSScript* aScript
|
|||
ReleaseScriptObjectCallback(aURI, existingEntry, nsnull);
|
||||
}
|
||||
|
||||
CacheScriptEntry entry = {aLangID, aScriptObject};
|
||||
CacheScriptEntry entry = {aScriptObject};
|
||||
|
||||
NS_ENSURE_TRUE(mScriptTable.Put(aURI, entry), NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// Lock the object from being gc'd until it is removed from the cache
|
||||
nsCOMPtr<nsIScriptRuntime> rt;
|
||||
nsresult rv = NS_GetScriptRuntimeByID(aLangID, getter_AddRefs(rt));
|
||||
nsresult rv = NS_GetJSRuntime(getter_AddRefs(rt));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = rt->HoldScriptObject(aScriptObject);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to GC lock the object");
|
||||
|
|
|
@ -64,7 +64,6 @@ class nsCSSStyleSheet;
|
|||
|
||||
struct CacheScriptEntry
|
||||
{
|
||||
PRUint32 mScriptTypeID; // the script language ID.
|
||||
JSScript* mScriptObject; // the script object.
|
||||
};
|
||||
|
||||
|
@ -107,8 +106,8 @@ public:
|
|||
nsXULPrototypeDocument* GetPrototype(nsIURI* aURI);
|
||||
nsresult PutPrototype(nsXULPrototypeDocument* aDocument);
|
||||
|
||||
JSScript* GetScript(nsIURI* aURI, PRUint32* langID);
|
||||
nsresult PutScript(nsIURI* aURI, PRUint32 langID, JSScript* aScriptObject);
|
||||
JSScript* GetScript(nsIURI* aURI);
|
||||
nsresult PutScript(nsIURI* aURI, JSScript* aScriptObject);
|
||||
|
||||
nsXBLDocumentInfo* GetXBLDocumentInfo(nsIURI* aURL) {
|
||||
return mXBLDocTable.GetWeak(aURL);
|
||||
|
|
|
@ -724,8 +724,7 @@ nsXULPDGlobalObject::EnsureScriptEnvironment()
|
|||
NS_ASSERTION(!mJSObject, "Have global without context?");
|
||||
|
||||
nsCOMPtr<nsIScriptRuntime> languageRuntime;
|
||||
nsresult rv = NS_GetScriptRuntimeByID(nsIProgrammingLanguage::JAVASCRIPT,
|
||||
getter_AddRefs(languageRuntime));
|
||||
nsresult rv = NS_GetJSRuntime(getter_AddRefs(languageRuntime));
|
||||
NS_ENSURE_SUCCESS(rv, NS_OK);
|
||||
|
||||
nsCOMPtr<nsIScriptContext> ctxNew = languageRuntime->CreateContext();
|
||||
|
|
|
@ -227,8 +227,8 @@ nsDOMScriptObjectFactory::RegisterDOMClassInfo(const char *aName,
|
|||
|
||||
|
||||
// Factories
|
||||
static nsresult
|
||||
GetJSRuntime(nsIScriptRuntime** aLanguage)
|
||||
nsresult
|
||||
NS_GetJSRuntime(nsIScriptRuntime** aLanguage)
|
||||
{
|
||||
nsCOMPtr<nsIDOMScriptObjectFactory> factory =
|
||||
do_GetService(kDOMScriptObjectFactoryCID);
|
||||
|
@ -246,7 +246,7 @@ nsresult NS_GetScriptRuntime(const nsAString &aLanguageName,
|
|||
NS_ENSURE_TRUE(aLanguageName.EqualsLiteral("application/javascript"),
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
return GetJSRuntime(aLanguage);
|
||||
return NS_GetJSRuntime(aLanguage);
|
||||
}
|
||||
|
||||
nsresult NS_GetScriptRuntimeByID(PRUint32 aScriptTypeID,
|
||||
|
@ -257,7 +257,7 @@ nsresult NS_GetScriptRuntimeByID(PRUint32 aScriptTypeID,
|
|||
NS_ENSURE_TRUE(aScriptTypeID == nsIProgrammingLanguage::JAVASCRIPT,
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
return GetJSRuntime(aLanguage);
|
||||
return NS_GetJSRuntime(aLanguage);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -99,8 +99,6 @@ public:
|
|||
}
|
||||
|
||||
nsresult set(T* object) {
|
||||
NS_ASSERTION(getScriptTypeID() != nsIProgrammingLanguage::UNKNOWN,
|
||||
"Must know the language!");
|
||||
nsresult rv = drop();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
@ -114,17 +112,12 @@ public:
|
|||
return rv;
|
||||
}
|
||||
nsresult set(const nsScriptObjectHolder<T> &other) {
|
||||
NS_ASSERTION(getScriptTypeID() == other.getScriptTypeID(),
|
||||
"Must have identical languages!");
|
||||
nsresult rv = drop();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
return set(other.mObject);
|
||||
}
|
||||
// Get the language ID.
|
||||
PRUint32 getScriptTypeID() const {
|
||||
return nsIProgrammingLanguage::JAVASCRIPT;
|
||||
}
|
||||
|
||||
protected:
|
||||
T* mObject;
|
||||
nsCOMPtr<nsIScriptContext> mContext;
|
||||
|
|
|
@ -1633,8 +1633,7 @@ nsGlobalWindow::EnsureScriptEnvironment()
|
|||
"mJSObject is null, but we have an inner window?");
|
||||
|
||||
nsCOMPtr<nsIScriptRuntime> scriptRuntime;
|
||||
nsresult rv = NS_GetScriptRuntimeByID(nsIProgrammingLanguage::JAVASCRIPT,
|
||||
getter_AddRefs(scriptRuntime));
|
||||
nsresult rv = NS_GetJSRuntime(getter_AddRefs(scriptRuntime));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIScriptContext> context = scriptRuntime->CreateContext();
|
||||
|
|
|
@ -74,6 +74,8 @@ public:
|
|||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptRuntime, NS_ISCRIPTRUNTIME_IID)
|
||||
|
||||
/* helper functions */
|
||||
nsresult NS_GetJSRuntime(nsIScriptRuntime** aLanguage);
|
||||
|
||||
nsresult NS_GetScriptRuntime(const nsAString &aLanguageName,
|
||||
nsIScriptRuntime **aRuntime);
|
||||
|
||||
|
|
|
@ -1543,8 +1543,6 @@ nsJSContext::CompileScript(const PRUnichar* aText,
|
|||
if (!script) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ASSERTION(aScriptObject.getScriptTypeID()==JAVASCRIPT,
|
||||
"Expecting JS script object holder");
|
||||
return aScriptObject.set(script);
|
||||
}
|
||||
|
||||
|
@ -1737,8 +1735,6 @@ nsJSContext::CompileEventHandler(nsIAtom *aName,
|
|||
}
|
||||
|
||||
JSObject *handler = ::JS_GetFunctionObject(fun);
|
||||
NS_ASSERTION(aHandler.getScriptTypeID()==JAVASCRIPT,
|
||||
"Expecting JS script object holder");
|
||||
return aHandler.set(handler);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче