Bug 669012 - Part d: Make nsIScriptElement::MaybeProcessScript return a boolean; r=smaug+hsivonen.

This commit is contained in:
Ms2ger 2011-11-16 08:50:18 +01:00
parent 4e03d81337
commit b13169bd39
4 changed files with 13 additions and 33 deletions

View File

@ -49,8 +49,8 @@
#include "nsIDOMHTMLScriptElement.h"
#define NS_ISCRIPTELEMENT_IID \
{ 0xac4c7e7f, 0x0c4a, 0x4796, \
{ 0xb4, 0xb7, 0x54, 0xbd, 0x13, 0x0f, 0x95, 0x9e } }
{ 0x5bb3b905, 0x5988, 0x476f, \
{ 0x95, 0x4f, 0x99, 0x02, 0x59, 0x82, 0x24, 0x67 } }
/**
* Internal interface implemented by script elements
@ -227,13 +227,13 @@ public:
bool AttemptToExecute()
{
mDoneAddingChildren = true;
nsresult rv = MaybeProcessScript();
bool block = MaybeProcessScript();
if (!mAlreadyStarted) {
// Need to lose parser-insertedness here to allow another script to cause
// execution later.
LoseParserInsertedness();
}
return rv == NS_ERROR_HTMLPARSER_BLOCK;
return block;
}
protected:
@ -249,8 +249,11 @@ protected:
* fallback mechanism of using both inline script and linked script you have
* to add all attributes and childNodes before adding the element to the
* document-tree.
*
* @return whether the parser will be blocked while this script is being
* loaded
*/
virtual nsresult MaybeProcessScript() = 0;
virtual bool MaybeProcessScript() = 0;
/**
* The start line number of the script.

View File

@ -147,7 +147,7 @@ nsScriptElement::ContentInserted(nsIDocument *aDocument,
MaybeProcessScript();
}
nsresult
bool
nsScriptElement::MaybeProcessScript()
{
nsCOMPtr<nsIContent> cont =
@ -158,7 +158,7 @@ nsScriptElement::MaybeProcessScript()
if (mAlreadyStarted || !mDoneAddingChildren || !cont->IsInDoc() ||
mMalformed || !HasScriptContent()) {
return NS_OK;
return false;
}
FreezeUriAsyncDefer();
@ -173,21 +173,12 @@ nsScriptElement::MaybeProcessScript()
nsCOMPtr<nsIDocument> parserDoc = do_QueryInterface(sink->GetTarget());
if (ownerDoc != parserDoc) {
// Willful violation of HTML5 as of 2010-12-01
return NS_OK;
return false;
}
}
}
nsRefPtr<nsScriptLoader> loader = ownerDoc->ScriptLoader();
nsresult scriptresult = loader->ProcessScriptElement(this);
// The only error we don't ignore is NS_ERROR_HTMLPARSER_BLOCK
// However we don't want to override other success values
// (such as NS_CONTENT_SCRIPT_IS_EVENTHANDLER)
if (NS_FAILED(scriptresult) &&
scriptresult != NS_ERROR_HTMLPARSER_BLOCK) {
scriptresult = NS_OK;
}
return scriptresult;
return scriptresult == NS_ERROR_HTMLPARSER_BLOCK;
}

View File

@ -72,5 +72,5 @@ protected:
*/
virtual bool HasScriptContent() = 0;
virtual nsresult MaybeProcessScript();
virtual bool MaybeProcessScript();
};

View File

@ -122,11 +122,8 @@ public:
virtual nsXPCClassInfo* GetClassInfo();
protected:
bool IsOnloadEventForWindow();
// nsScriptElement
virtual bool HasScriptContent();
virtual nsresult MaybeProcessScript();
};
@ -320,14 +317,3 @@ nsHTMLScriptElement::HasScriptContent()
return (mFrozen ? mExternal : HasAttr(kNameSpaceID_None, nsGkAtoms::src)) ||
nsContentUtils::HasNonEmptyTextContent(this);
}
nsresult
nsHTMLScriptElement::MaybeProcessScript()
{
nsresult rv = nsScriptElement::MaybeProcessScript();
if (rv == NS_CONTENT_SCRIPT_IS_EVENTHANDLER)
// Don't return NS_CONTENT_SCRIPT_IS_EVENTHANDLER since callers can't deal
rv = NS_OK;
return rv;
}