bug 908347 - make Open / Close Container() take an enum with only html and body elements r=mrbkap

This commit is contained in:
Trevor Saunders 2013-08-17 08:06:23 -04:00
parent 57645ed471
commit aa0b2562ae
3 changed files with 18 additions and 43 deletions

View File

@ -162,8 +162,8 @@ public:
virtual bool IsScriptExecuting();
// nsIHTMLContentSink
NS_IMETHOD OpenContainer(nsHTMLTag aNodeType);
NS_IMETHOD CloseContainer(const nsHTMLTag aTag);
NS_IMETHOD OpenContainer(ElementType aNodeType);
NS_IMETHOD CloseContainer(ElementType aTag);
#ifdef DEBUG
// nsIDebugDumpContent
@ -1412,24 +1412,15 @@ HTMLContentSink::CloseBody()
}
NS_IMETHODIMP
HTMLContentSink::OpenContainer(nsHTMLTag aNodeType)
HTMLContentSink::OpenContainer(ElementType aElementType)
{
nsresult rv = NS_OK;
switch (aNodeType) {
case eHTMLTag_frameset:
MOZ_CRASH("Must not use HTMLContentSink for frames.");
case eHTMLTag_head:
rv = OpenHeadContext();
if (NS_SUCCEEDED(rv)) {
mHaveSeenHead = true;
}
switch (aElementType) {
case eBody:
rv = OpenBody(eHTMLTag_body);
break;
case eHTMLTag_body:
rv = OpenBody(aNodeType);
break;
case eHTMLTag_html:
case eHTML:
if (mRoot) {
// If we've already hit this code once, then we're done
if (!mNotifiedRootInsertion) {
@ -1438,41 +1429,23 @@ HTMLContentSink::OpenContainer(nsHTMLTag aNodeType)
ProcessOfflineManifest(mRoot);
}
break;
case eHTMLTag_form:
MOZ_CRASH("Must not use HTMLContentSink for forms.");
default:
rv = mCurrentContext->OpenContainer(aNodeType);
break;
}
return rv;
}
NS_IMETHODIMP
HTMLContentSink::CloseContainer(const eHTMLTags aTag)
HTMLContentSink::CloseContainer(const ElementType aTag)
{
nsresult rv = NS_OK;
switch (aTag) {
case eHTMLTag_frameset:
MOZ_CRASH("Must not use HTMLContentSink for frames.");
case eHTMLTag_head:
CloseHeadContext();
break;
case eHTMLTag_body:
case eBody:
rv = CloseBody();
break;
case eHTMLTag_html:
case eHTML:
rv = CloseHTML();
break;
case eHTMLTag_form:
MOZ_CRASH("Must not use HTMLContentSink for forms.");
default:
rv = mCurrentContext->CloseContainer(aTag);
break;
}
return rv;

View File

@ -65,12 +65,14 @@ public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IHTML_CONTENT_SINK_IID)
enum ElementType { eHTML, eBody };
/**
* This method is used to open a generic container in the sink.
*
* @update 4/1/98 gess
*/
NS_IMETHOD OpenContainer(nsHTMLTag aNodeType) = 0;
NS_IMETHOD OpenContainer(ElementType aNodeType) = 0;
/**
* This method gets called by the parser when a close
@ -78,7 +80,7 @@ public:
*
* @param aTag - The tag to be closed.
*/
NS_IMETHOD CloseContainer(const nsHTMLTag aTag) = 0;
NS_IMETHOD CloseContainer(ElementType aTag) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLContentSink, NS_IHTML_CONTENT_SINK_IID)

View File

@ -41,14 +41,14 @@ CNavDTD::BuildModel(nsITokenizer* aTokenizer,
return NS_ERROR_HTMLPARSER_STOPPARSING;
}
nsresult rv = sink->OpenContainer(eHTMLTag_html);
nsresult rv = sink->OpenContainer(nsIHTMLContentSink::eHTML);
NS_ENSURE_SUCCESS(rv, rv);
rv = sink->OpenContainer(eHTMLTag_body);
rv = sink->OpenContainer(nsIHTMLContentSink::eBody);
NS_ENSURE_SUCCESS(rv, rv);
rv = sink->CloseContainer(eHTMLTag_body);
rv = sink->CloseContainer(nsIHTMLContentSink::eBody);
MOZ_ASSERT(NS_SUCCEEDED(rv));
rv = sink->CloseContainer(eHTMLTag_html);
rv = sink->CloseContainer(nsIHTMLContentSink::eHTML);
MOZ_ASSERT(NS_SUCCEEDED(rv));
return NS_OK;