From 057155e2c2fb28239ae2f89e523d713cdf16d842 Mon Sep 17 00:00:00 2001 From: "bzbarsky@mit.edu" Date: Sun, 2 Dec 2007 14:27:11 -0800 Subject: [PATCH] Relanding without the test just to make sure this is in fact what's breaking stuff --- content/xul/document/src/nsXULContentSink.cpp | 23 +++++++++++++++---- content/xul/document/src/nsXULContentSink.h | 6 +++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/content/xul/document/src/nsXULContentSink.cpp b/content/xul/document/src/nsXULContentSink.cpp index b10efda92ffe..48d257bd4b27 100644 --- a/content/xul/document/src/nsXULContentSink.cpp +++ b/content/xul/document/src/nsXULContentSink.cpp @@ -959,9 +959,16 @@ XULContentSinkImpl::OpenTag(const PRUnichar** aAttributes, // even though it is ignored (the nsPrototypeScriptElement // has its own script-type). element->mScriptTypeID = nsIProgrammingLanguage::JAVASCRIPT; - // OpenScript will push the nsPrototypeScriptElement onto the - // stack, so we're done after this. - return OpenScript(aAttributes, aLineNumber); + rv = OpenScript(aAttributes, aLineNumber); + NS_ENSURE_SUCCESS(rv, rv); + + NS_ASSERTION(mState == eInScript || mState == eInDocumentElement, + "Unexpected state"); + if (mState == eInScript) { + // OpenScript has pushed the nsPrototypeScriptElement onto the + // stack, so we're done. + return NS_OK; + } } // Set the correct script-type for the element. @@ -1004,7 +1011,15 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes, rv = mimeHdrParser->GetParameter(typeAndParams, nsnull, EmptyCString(), PR_FALSE, nsnull, mimeType); - NS_ENSURE_SUCCESS(rv, rv); + if (NS_FAILED(rv)) { + if (rv == NS_ERROR_INVALID_ARG) { + // Might as well bail out now instead of setting langID to + // nsIProgrammingLanguage::UNKNOWN and bailing out later. + return NS_OK; + } + // We do want the warning here + NS_ENSURE_SUCCESS(rv, rv); + } // Javascript keeps the fast path, optimized for most-likely type // Table ordered from most to least likely JS MIME types. For .xul diff --git a/content/xul/document/src/nsXULContentSink.h b/content/xul/document/src/nsXULContentSink.h index 9586840cfdb6..4e29f1927ca2 100644 --- a/content/xul/document/src/nsXULContentSink.h +++ b/content/xul/document/src/nsXULContentSink.h @@ -105,6 +105,12 @@ protected: const PRUint32 aLineNumber, nsINodeInfo *aNodeInfo); + // If OpenScript returns NS_OK and after it returns our state is eInScript, + // that means that we created a prototype script and stuck it on + // mContextStack. If NS_OK is returned but the state is still + // eInDocumentElement then we didn't create a prototype script (e.g. the + // script had an unknown type), and the caller should create a prototype + // element. nsresult OpenScript(const PRUnichar** aAttributes, const PRUint32 aLineNumber);