Fix for bugs 13498, 14199, 8389, 13640.

This commit is contained in:
harishd%netscape.com 1999-09-21 00:24:28 +00:00
Родитель d292f84150
Коммит 908637f613
16 изменённых файлов: 68 добавлений и 32 удалений

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

@ -701,7 +701,7 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){
static eHTMLTags passThru[]= {
eHTMLTag_html,eHTMLTag_comment,eHTMLTag_newline,
eHTMLTag_whitespace,eHTMLTag_script,eHTMLTag_noscript,
eHTMLTag_userdefined};
eHTMLTag_nolayer,eHTMLTag_markupDecl,eHTMLTag_userdefined};
if(!FindTagInSet(theTag,passThru,sizeof(passThru)/sizeof(eHTMLTag_unknown))){
if(!gHTMLElements[eHTMLTag_html].SectionContains(theTag,PR_FALSE)) {
if((!mHadBody) && (!mHadFrameset)){
@ -1186,19 +1186,23 @@ nsresult CNavDTD::HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags
isNotWhiteSpace = mSaveBadTokens = PR_TRUE;
}
if(mSaveBadTokens) {
aToken->mRecycle=PR_FALSE;
mBodyContext->SaveToken(aToken,theBCIndex);
// If the token is attributed then save those attributes too.
if(attrCount > 0) {
nsCParserNode* theAttrNode = (nsCParserNode*)&aNode;
while(attrCount > 0){
mBodyContext->SaveToken(theAttrNode->PopAttributeToken(),theBCIndex);
CToken* theAttrToken=theAttrNode->PopAttributeToken();
if(theAttrToken) {
mBodyContext->SaveToken(theAttrToken,theBCIndex);
theAttrToken->mRecycle=PR_FALSE;
}
attrCount--;
}
}
if(!IsContainer(aChildTag) && isNotWhiteSpace) {
mSaveBadTokens = PR_FALSE;
}
result=NS_ERROR_HTMLPARSER_MISPLACED;
}
}
@ -1297,8 +1301,9 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
default:
{
if(theHeadIsParent)
if(theHeadIsParent) {
result=AddHeadLeaf(*theNode);
}
else result=HandleDefaultStartToken(aToken,theChildTag,*theNode);
}
break;
@ -1553,7 +1558,7 @@ nsresult CNavDTD::HandleSavedTokensAbove(eHTMLTags aTag)
}
theBadTokenCount--;
}
result=NavDispatchTokenHandler(theToken,this);
result=HandleToken(theToken,mParser);
}
}
theBadTokenCount--;

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

@ -200,6 +200,18 @@ nsDTDContext::nsDTDContext() : mStack(), mSkipped(0), mStyles(0) {
* @update gess9/10/98
*/
nsDTDContext::~nsDTDContext() {
PRInt32 theSize=mSkipped.GetSize();
if(theSize>0) {
CTokenDeallocator theDeallocator;
for(PRInt32 i=0;i<theSize;i++) {
nsDeque* theDeque=(nsDeque*)mSkipped.Pop();
if(theDeque) {
if(theDeque->GetSize()>0) theDeque->ForEach(theDeallocator);
delete theDeque;
theDeque=nsnull;
}
}
}
}
/**
@ -440,6 +452,7 @@ CTokenRecycler::~CTokenRecycler() {
}
}
class CTokenFinder: public nsDequeFunctor{
public:
CTokenFinder(CToken* aToken) {mToken=aToken;}

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

@ -1186,7 +1186,7 @@ nsHTMLElement gHTMLElements[] = {
/*special props, prop-range*/ 0, kNoPropRange,
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_mdo, // Markup Declaration Open, i.e., "<!"
{ /*tag*/ eHTMLTag_markupDecl,
/*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,

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

@ -874,7 +874,7 @@ void nsHTMLContentSinkStream::AddStartTag(const nsIParserNode& aNode)
{
eHTMLTags tag = (eHTMLTags)aNode.GetNodeType();
if(tag==eHTMLTag_mdo) {
if(tag==eHTMLTag_markupDecl) {
Write("<!"); // mdo => Markup Declaration Open.
return;
}
@ -966,7 +966,7 @@ void nsHTMLContentSinkStream::AddEndTag(const nsIParserNode& aNode)
{
tagName = "--";
}
else if(tag == eHTMLTag_mdo)
else if(tag == eHTMLTag_markupDecl)
{
// mod => Markup Declaration Open, i.e., "<!"
Write(kGreaterThan);

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

@ -40,7 +40,7 @@ enum nsHTMLTag {
/* The remaining enums are not for tags */
eHTMLTag_text, eHTMLTag_whitespace, eHTMLTag_newline,
eHTMLTag_comment, eHTMLTag_entity, eHTMLTag_mdo,
eHTMLTag_comment, eHTMLTag_entity, eHTMLTag_markupDecl,
eHTMLTag_userdefined
};
#undef HTML_TAG

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

@ -682,7 +682,7 @@ nsresult nsHTMLTokenizer::ConsumeSpecialMarkup(PRUnichar aChar,CToken*& aToken,n
if(theIndex==kNotFound)
aToken = theRecycler->CreateTokenOfType(eToken_comment,eHTMLTag_comment);
else
aToken = theRecycler->CreateTokenOfType(eToken_doctypeDecl,eHTMLTag_unknown);
aToken = theRecycler->CreateTokenOfType(eToken_doctypeDecl,eHTMLTag_markupDecl);
if(aToken) {
result=aToken->Consume(aChar,aScanner);

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

@ -85,7 +85,7 @@ nsXIFTagEntry gXIFTagTable[] =
{"leaf", eXIFTag_leaf},
{"link", eXIFTag_link},
{"markup_declaration", eXIFTag_mdo},
{"markup_declaration", eXIFTag_markupDecl},
{"section", eXIFTag_section},
{"section_body", eXIFTag_section_body},
@ -716,7 +716,7 @@ nsresult nsXIFDTD::HandleStartToken(CToken* aToken) {
AddCSSDeclaration(node);
break;
case eXIFTag_mdo:
case eXIFTag_markupDecl:
mSink->OpenContainer(node);
break;
@ -780,7 +780,7 @@ nsresult nsXIFDTD::HandleEndToken(CToken* aToken) {
EndCSSDeclarationList(node);
break;
case eXIFTag_mdo:
case eXIFTag_markupDecl:
mSink->CloseContainer(node);
default:

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

@ -83,9 +83,9 @@ enum eXIFTags
eXIFTag_url,
eXIFTag_xml,
eXIFTag_mdo = eHTMLTag_mdo,
eXIFTag_newline = eHTMLTag_newline,
eXIFTag_text = eHTMLTag_text,
eXIFTag_markupDecl = eHTMLTag_markupDecl,
eXIFTag_newline = eHTMLTag_newline,
eXIFTag_text = eHTMLTag_text,
eXIFTag_whitespace = eHTMLTag_whitespace,
eXIFTag_userdefined

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

@ -701,7 +701,7 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){
static eHTMLTags passThru[]= {
eHTMLTag_html,eHTMLTag_comment,eHTMLTag_newline,
eHTMLTag_whitespace,eHTMLTag_script,eHTMLTag_noscript,
eHTMLTag_userdefined};
eHTMLTag_nolayer,eHTMLTag_markupDecl,eHTMLTag_userdefined};
if(!FindTagInSet(theTag,passThru,sizeof(passThru)/sizeof(eHTMLTag_unknown))){
if(!gHTMLElements[eHTMLTag_html].SectionContains(theTag,PR_FALSE)) {
if((!mHadBody) && (!mHadFrameset)){
@ -1186,19 +1186,23 @@ nsresult CNavDTD::HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags
isNotWhiteSpace = mSaveBadTokens = PR_TRUE;
}
if(mSaveBadTokens) {
aToken->mRecycle=PR_FALSE;
mBodyContext->SaveToken(aToken,theBCIndex);
// If the token is attributed then save those attributes too.
if(attrCount > 0) {
nsCParserNode* theAttrNode = (nsCParserNode*)&aNode;
while(attrCount > 0){
mBodyContext->SaveToken(theAttrNode->PopAttributeToken(),theBCIndex);
CToken* theAttrToken=theAttrNode->PopAttributeToken();
if(theAttrToken) {
mBodyContext->SaveToken(theAttrToken,theBCIndex);
theAttrToken->mRecycle=PR_FALSE;
}
attrCount--;
}
}
if(!IsContainer(aChildTag) && isNotWhiteSpace) {
mSaveBadTokens = PR_FALSE;
}
result=NS_ERROR_HTMLPARSER_MISPLACED;
}
}
@ -1297,8 +1301,9 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
default:
{
if(theHeadIsParent)
if(theHeadIsParent) {
result=AddHeadLeaf(*theNode);
}
else result=HandleDefaultStartToken(aToken,theChildTag,*theNode);
}
break;
@ -1553,7 +1558,7 @@ nsresult CNavDTD::HandleSavedTokensAbove(eHTMLTags aTag)
}
theBadTokenCount--;
}
result=NavDispatchTokenHandler(theToken,this);
result=HandleToken(theToken,mParser);
}
}
theBadTokenCount--;

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

@ -200,6 +200,18 @@ nsDTDContext::nsDTDContext() : mStack(), mSkipped(0), mStyles(0) {
* @update gess9/10/98
*/
nsDTDContext::~nsDTDContext() {
PRInt32 theSize=mSkipped.GetSize();
if(theSize>0) {
CTokenDeallocator theDeallocator;
for(PRInt32 i=0;i<theSize;i++) {
nsDeque* theDeque=(nsDeque*)mSkipped.Pop();
if(theDeque) {
if(theDeque->GetSize()>0) theDeque->ForEach(theDeallocator);
delete theDeque;
theDeque=nsnull;
}
}
}
}
/**
@ -440,6 +452,7 @@ CTokenRecycler::~CTokenRecycler() {
}
}
class CTokenFinder: public nsDequeFunctor{
public:
CTokenFinder(CToken* aToken) {mToken=aToken;}

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

@ -1186,7 +1186,7 @@ nsHTMLElement gHTMLElements[] = {
/*special props, prop-range*/ 0, kNoPropRange,
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_mdo, // Markup Declaration Open, i.e., "<!"
{ /*tag*/ eHTMLTag_markupDecl,
/*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,

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

@ -874,7 +874,7 @@ void nsHTMLContentSinkStream::AddStartTag(const nsIParserNode& aNode)
{
eHTMLTags tag = (eHTMLTags)aNode.GetNodeType();
if(tag==eHTMLTag_mdo) {
if(tag==eHTMLTag_markupDecl) {
Write("<!"); // mdo => Markup Declaration Open.
return;
}
@ -966,7 +966,7 @@ void nsHTMLContentSinkStream::AddEndTag(const nsIParserNode& aNode)
{
tagName = "--";
}
else if(tag == eHTMLTag_mdo)
else if(tag == eHTMLTag_markupDecl)
{
// mod => Markup Declaration Open, i.e., "<!"
Write(kGreaterThan);

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

@ -40,7 +40,7 @@ enum nsHTMLTag {
/* The remaining enums are not for tags */
eHTMLTag_text, eHTMLTag_whitespace, eHTMLTag_newline,
eHTMLTag_comment, eHTMLTag_entity, eHTMLTag_mdo,
eHTMLTag_comment, eHTMLTag_entity, eHTMLTag_markupDecl,
eHTMLTag_userdefined
};
#undef HTML_TAG

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

@ -682,7 +682,7 @@ nsresult nsHTMLTokenizer::ConsumeSpecialMarkup(PRUnichar aChar,CToken*& aToken,n
if(theIndex==kNotFound)
aToken = theRecycler->CreateTokenOfType(eToken_comment,eHTMLTag_comment);
else
aToken = theRecycler->CreateTokenOfType(eToken_doctypeDecl,eHTMLTag_unknown);
aToken = theRecycler->CreateTokenOfType(eToken_doctypeDecl,eHTMLTag_markupDecl);
if(aToken) {
result=aToken->Consume(aChar,aScanner);

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

@ -85,7 +85,7 @@ nsXIFTagEntry gXIFTagTable[] =
{"leaf", eXIFTag_leaf},
{"link", eXIFTag_link},
{"markup_declaration", eXIFTag_mdo},
{"markup_declaration", eXIFTag_markupDecl},
{"section", eXIFTag_section},
{"section_body", eXIFTag_section_body},
@ -716,7 +716,7 @@ nsresult nsXIFDTD::HandleStartToken(CToken* aToken) {
AddCSSDeclaration(node);
break;
case eXIFTag_mdo:
case eXIFTag_markupDecl:
mSink->OpenContainer(node);
break;
@ -780,7 +780,7 @@ nsresult nsXIFDTD::HandleEndToken(CToken* aToken) {
EndCSSDeclarationList(node);
break;
case eXIFTag_mdo:
case eXIFTag_markupDecl:
mSink->CloseContainer(node);
default:

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

@ -83,9 +83,9 @@ enum eXIFTags
eXIFTag_url,
eXIFTag_xml,
eXIFTag_mdo = eHTMLTag_mdo,
eXIFTag_newline = eHTMLTag_newline,
eXIFTag_text = eHTMLTag_text,
eXIFTag_markupDecl = eHTMLTag_markupDecl,
eXIFTag_newline = eHTMLTag_newline,
eXIFTag_text = eHTMLTag_text,
eXIFTag_whitespace = eHTMLTag_whitespace,
eXIFTag_userdefined