From 8057b841d93f2e45763995aa0ffb57f10f001275 Mon Sep 17 00:00:00 2001 From: "kyle.yuan%sun.com" Date: Tue, 18 Jun 2002 02:06:29 +0000 Subject: [PATCH] Bug 133853 why always add token into Tokenizer even there is an token already? r=harishd, sr=jst Check in for Jerry Tan(jerry.tan@sun.com)'s fix. git-svn-id: svn://10.0.0.236/trunk@123490 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/htmlparser/src/CNavDTD.cpp | 18 +++++++++++++++--- mozilla/parser/htmlparser/src/CNavDTD.cpp | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/mozilla/htmlparser/src/CNavDTD.cpp b/mozilla/htmlparser/src/CNavDTD.cpp index 802a4519eb2..7d577e7d3e7 100644 --- a/mozilla/htmlparser/src/CNavDTD.cpp +++ b/mozilla/htmlparser/src/CNavDTD.cpp @@ -492,9 +492,21 @@ nsresult CNavDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsIToke mTokenizer->PushTokenFront(theToken); } //if the content model is empty, then begin by opening ... - theToken=NS_STATIC_CAST(CStartToken*,mTokenAllocator->CreateTokenOfType(eToken_start,eHTMLTag_html,NS_LITERAL_STRING("html"))); - if(theToken) { - mTokenizer->PushTokenFront(theToken); //this token should get pushed on the context stack. + theToken = (CStartToken*)mTokenizer->GetTokenAt(0); + if (theToken) { + eHTMLTags theTag = (eHTMLTags)theToken->GetTypeID(); + if (theTag != eHTMLTag_html) { + theToken = NS_STATIC_CAST(CStartToken*,mTokenAllocator->CreateTokenOfType(eToken_start,eHTMLTag_html,NS_LITERAL_STRING("html"))); + if (theToken) { + mTokenizer->PushTokenFront(theToken); //this token should get pushed on the context stack. + } + } + } + else { + theToken = NS_STATIC_CAST(CStartToken*,mTokenAllocator->CreateTokenOfType(eToken_start,eHTMLTag_html,NS_LITERAL_STRING("html"))); + if (theToken) { + mTokenizer->PushTokenFront(theToken); //this token should get pushed on the context stack. + } } } diff --git a/mozilla/parser/htmlparser/src/CNavDTD.cpp b/mozilla/parser/htmlparser/src/CNavDTD.cpp index 802a4519eb2..7d577e7d3e7 100644 --- a/mozilla/parser/htmlparser/src/CNavDTD.cpp +++ b/mozilla/parser/htmlparser/src/CNavDTD.cpp @@ -492,9 +492,21 @@ nsresult CNavDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsIToke mTokenizer->PushTokenFront(theToken); } //if the content model is empty, then begin by opening ... - theToken=NS_STATIC_CAST(CStartToken*,mTokenAllocator->CreateTokenOfType(eToken_start,eHTMLTag_html,NS_LITERAL_STRING("html"))); - if(theToken) { - mTokenizer->PushTokenFront(theToken); //this token should get pushed on the context stack. + theToken = (CStartToken*)mTokenizer->GetTokenAt(0); + if (theToken) { + eHTMLTags theTag = (eHTMLTags)theToken->GetTypeID(); + if (theTag != eHTMLTag_html) { + theToken = NS_STATIC_CAST(CStartToken*,mTokenAllocator->CreateTokenOfType(eToken_start,eHTMLTag_html,NS_LITERAL_STRING("html"))); + if (theToken) { + mTokenizer->PushTokenFront(theToken); //this token should get pushed on the context stack. + } + } + } + else { + theToken = NS_STATIC_CAST(CStartToken*,mTokenAllocator->CreateTokenOfType(eToken_start,eHTMLTag_html,NS_LITERAL_STRING("html"))); + if (theToken) { + mTokenizer->PushTokenFront(theToken); //this token should get pushed on the context stack. + } } }