bug 308140: Make sure to match open and close head calls in the fragment sink, so that other elements don't get closed too early. r+sr=jst

This commit is contained in:
mrbkap%gmail.com 2005-09-21 18:11:05 +00:00
Родитель 99ab5fc8af
Коммит ef1465b508
1 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -147,6 +147,7 @@ public:
PRPackedBool mProcessing; PRPackedBool mProcessing;
PRPackedBool mSeenBody; PRPackedBool mSeenBody;
PRPackedBool mIgnoreContainer; PRPackedBool mIgnoreContainer;
PRPackedBool mIgnoreNextCloseHead;
nsCOMPtr<nsIContent> mRoot; nsCOMPtr<nsIContent> mRoot;
nsCOMPtr<nsIParser> mParser; nsCOMPtr<nsIParser> mParser;
@ -199,6 +200,7 @@ nsHTMLFragmentContentSink::nsHTMLFragmentContentSink(PRBool aAllContent)
mProcessing(aAllContent), mProcessing(aAllContent),
mSeenBody(!aAllContent), mSeenBody(!aAllContent),
mIgnoreContainer(PR_FALSE), mIgnoreContainer(PR_FALSE),
mIgnoreNextCloseHead(PR_FALSE),
mContentStack(nsnull), mContentStack(nsnull),
mText(nsnull), mText(nsnull),
mTextLength(0), mTextLength(0),
@ -318,14 +320,18 @@ nsHTMLFragmentContentSink::OpenHead(const nsIParserNode& aNode)
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLFragmentContentSink::OpenHead() nsHTMLFragmentContentSink::OpenHead()
{ {
// The DTD uses this function when the head is being forced open by a tag in mIgnoreNextCloseHead = PR_TRUE;
// the body. We can safely ignore it, for now.
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLFragmentContentSink::CloseHead() nsHTMLFragmentContentSink::CloseHead()
{ {
if (mIgnoreNextCloseHead) {
mIgnoreNextCloseHead = PR_FALSE;
return NS_OK;
}
return CloseContainer(eHTMLTag_head); return CloseContainer(eHTMLTag_head);
} }