backing out changes to fix 74728 as they are causing assertion death spirals in todays builds.

This commit is contained in:
valeski%netscape.com 2001-04-05 17:53:18 +00:00
Родитель d72ada3b53
Коммит 2d60423422
14 изменённых файлов: 110 добавлений и 150 удалений

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

@ -952,7 +952,7 @@ nsresult CNavDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){
const nsString& theString=aNode.GetSkippedContent();
if(0<theString.Length()) {
CTextToken *theToken=NS_STATIC_CAST(CTextToken*,mTokenAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text,theString));
nsCParserNode theNode(theToken,0,mTokenAllocator);
nsCParserNode theNode(theToken,0);
result=mSink->AddLeaf(theNode); //when the node get's destructed, so does the new token
}
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::DidHandleStartTag(), this=%p\n", this));
@ -971,7 +971,7 @@ nsresult CNavDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){
CTextToken theToken(theNumber);
PRInt32 theLineNumber=0;
nsCParserNode theNode(&theToken,theLineNumber,mTokenAllocator);
nsCParserNode theNode(&theToken,theLineNumber);
result=mSink->AddLeaf(theNode);
}
break;
@ -1420,7 +1420,7 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsIParserNode
//because this code calls CloseHead() directly, stack-based token/nodes are ok.
CEndToken theToken(eHTMLTag_head);
nsCParserNode theNode(&theToken,mLineNumber,mTokenAllocator);
nsCParserNode theNode(&theToken,mLineNumber);
result=CloseHead(&theNode);
}
}
@ -1903,7 +1903,7 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) {
case eHTMLTag_form:
{
//this is safe because we call close container directly. This node/token is not cached.
nsCParserNode theNode((CHTMLToken*)aToken,mLineNumber,mTokenAllocator);
nsCParserNode theNode((CHTMLToken*)aToken,mLineNumber);
result=CloseContainer(&theNode,theChildTag,PR_FALSE);
}
break;

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

@ -250,14 +250,14 @@ public:
nsresult result=NS_OK;
CStartToken theToken(*aTagList);
nsCParserNode theNode(&theToken,theLineNumber,aContext->mTokenAllocator);
nsCParserNode theNode(&theToken,theLineNumber);
result=OpenContainer(&theNode,*aTagList,aContext,aSink);
if(eHTMLTag_unknown!=*(aTagList+1)) {
AutoGenerateStructure(++aTagList,aContext,aSink);
}
CEndToken theEndToken(*aTagList--);
nsCParserNode theEndNode(&theEndToken,theLineNumber,aContext->mTokenAllocator);
nsCParserNode theEndNode(&theEndToken,theLineNumber);
result=CloseContainer(&theEndNode,*aTagList,aContext,aSink);
return result;
@ -1005,7 +1005,7 @@ public:
CTextToken theToken(theNumber);
PRInt32 theLineNumber=0;
nsCParserNode theNewNode(&theToken,theLineNumber,aContext->mTokenAllocator);
nsCParserNode theNewNode(&theToken,theLineNumber);
result=aSink->AddLeaf(theNewNode);
return result;
}

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

@ -455,7 +455,7 @@ NS_IMETHODIMP nsExpatDTD::HandleToken(CToken* aToken,nsIParser* aParser) {
mParser=(nsParser*)aParser;
mSink=aParser->GetContentSink();
nsCParserNode theNode(theToken,mLineNumber,mTokenizer->GetTokenAllocator());
nsCParserNode theNode(theToken,mLineNumber);
switch(theType) {
case eToken_newline:

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

@ -40,25 +40,7 @@ const nsString& GetEmptyString() {
/**
* Default Constructor
*/
nsCParserNode::nsCParserNode()
: mLineNumber(1),
mToken(nsnull),
mAttributes(nsnull),
mSkippedContent(nsnull),
mUseCount(0),
mGenericState(PR_FALSE),
mTokenAllocator(nsnull)
{
MOZ_COUNT_CTOR(nsCParserNode);
#ifdef HEAP_ALLOCATED_NODES
mNodeAllocator=nsnull;
#endif
}
/**
* Constructor
* Default constructor
*
* @update gess 3/25/98
* @param aToken -- token to init internal token
@ -361,11 +343,13 @@ void nsCParserNode::GetSource(nsString& aString) {
* @return void
*/
nsresult nsCParserNode::ReleaseAll() {
NS_ASSERTION(mTokenAllocator != nsnull, "aiee! no token allocator!");
if(mAttributes) {
CToken* theAttrToken=0;
while((theAttrToken=NS_STATIC_CAST(CToken*,mAttributes->Pop()))) {
IF_FREE(theAttrToken, mTokenAllocator);
// nsViewSourceHTML.cpp:513 creates nsCParserNodes with a NULL token allocator
// need to check to see if mTokenAllocator is non-null
if(mTokenAllocator)
IF_FREE(theAttrToken, mTokenAllocator);
}
delete mAttributes;
mAttributes=0;

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

@ -108,15 +108,10 @@ class nsCParserNode : public nsIParserNode {
/**
* Default constructor
*/
nsCParserNode();
/**
* Constructor
* @update gess5/11/98
* @param aToken is the token this node "refers" to
*/
nsCParserNode(CToken* aToken,PRInt32 aLineNumber,nsTokenAllocator* aTokenAllocator,nsNodeAllocator* aNodeAllocator=0);
nsCParserNode(CToken* aToken=nsnull,PRInt32 aLineNumber=1,nsTokenAllocator* aTokenAllocator=0,nsNodeAllocator* aNodeAllocator=0);
/**
* Destructor
@ -128,7 +123,7 @@ class nsCParserNode : public nsIParserNode {
* Init
* @update gess5/11/98
*/
virtual nsresult Init(CToken* aToken,PRInt32 aLineNumber,nsTokenAllocator* aTokenAllocator,nsNodeAllocator* aNodeAllocator=0);
virtual nsresult Init(CToken* aToken=nsnull,PRInt32 aLineNumber=1,nsTokenAllocator* aTokenAllocator=0,nsNodeAllocator* aNodeAllocator=0);
/**
* Retrieve the name of the node

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

@ -141,7 +141,7 @@ class CToken {
* @update harishd 08/02/00
*/
void Release(nsFixedSizeAllocator& aArenaPool) {
if(--mUseCount==0)
if(--mUseCount==0)
Destroy(this, aArenaPool);
}

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

@ -188,12 +188,15 @@ class CSharedVSContext {
public:
CSharedVSContext() :
mEndNode(),
mEndNode(),
mStartNode(),
mTokenNode(),
mErrorNode(),
mITextToken(),
mErrorToken(NS_ConvertASCIItoUCS2("error")) {
mITextNode(&mITextToken),
mTextToken(),
mErrorToken(NS_ConvertASCIItoUCS2("error")),
mTextNode(&mTextToken){
}
~CSharedVSContext() {
@ -209,7 +212,10 @@ public:
nsCParserNode mTokenNode;
nsCParserNode mErrorNode;
CIndirectTextToken mITextToken;
nsCParserNode mITextNode;
CTextToken mTextToken;
CTextToken mErrorToken;
nsCParserNode mTextNode;
};
#ifdef VIEW_SOURCE_HTML
@ -443,6 +449,24 @@ nsresult CViewSourceHTML::WillBuildModel( const CParserContext& aParserContext,
mErrorCount=0;
mTagCount=0;
#ifdef VIEW_SOURCE_HTML
nsAutoString tag;
tag.AssignWithConversion("HTML");
CStartToken htmlToken(tag, eHTMLTag_html);
nsCParserNode htmlNode(&htmlToken,0);
mSink->OpenHTML(htmlNode);
tag.AssignWithConversion("BODY");
CStartToken bodyToken(tag, eHTMLTag_body);
nsCParserNode bodyNode(&bodyToken,0);
mSink->OpenBody(bodyNode);
#else
CCommentToken ssToken(NS_LITERAL_STRING("<?xml version=\"1.0\"?>"));
nsCParserNode ssNode(&ssToken);
result= mSink->AddCharacterData(ssNode);
#endif // VIEW_SOURCE_HTML
#ifdef rickgdebug
(*gDumpFile) << theHeader << endl;
(*gDumpFile) << "<viewsource xmlns=\"viewsource\">" << endl;
@ -479,37 +503,17 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
if(!mHasOpenRoot) {
#ifdef VIEW_SOURCE_HTML
// For the stack-allocated tokens below, it's safe to pass a null
// token allocator, because there are no attributes on the tokens.
nsAutoString tag;
tag.AssignWithConversion("HTML");
CStartToken htmlToken(tag, eHTMLTag_html);
nsCParserNode htmlNode(&htmlToken,0,mTokenizer->GetTokenAllocator());
mSink->OpenHTML(htmlNode);
tag.AssignWithConversion("BODY");
CStartToken bodyToken(tag, eHTMLTag_body);
nsCParserNode bodyNode(&bodyToken,0,mTokenizer->GetTokenAllocator());
mSink->OpenBody(bodyNode);
#else
CCommentToken ssToken(NS_LITERAL_STRING("<?xml version=\"1.0\"?>"));
nsCParserNode ssNode(&ssToken,0,nsnull);
result= mSink->AddCharacterData(ssNode,0,mTokenizer->GetTokenAllocator());
#endif // VIEW_SOURCE_HTML
#ifdef VIEW_SOURCE_HTML
tag.AssignWithConversion("PRE");
CStartToken theToken(tag, eHTMLTag_pre);
#else
//now let's automatically open the root container...
CStartToken theToken(NS_LITERAL_STRING("viewsource"));
#endif // VIEW_SOURCE_HTML
nsCParserNode theNode(&theToken,0);
CAttributeToken *theAttr=nsnull;
nsTokenAllocator* theAllocator=mTokenizer->GetTokenAllocator();
nsCParserNode theNode(&theToken,0,theAllocator);
if(theAllocator) {
#ifdef VIEW_SOURCE_HTML
theAttr=(CAttributeToken*)theAllocator->CreateTokenOfType(eToken_attribute,eHTMLTag_unknown,NS_ConvertASCIItoUCS2(kPreStyle));
@ -603,15 +607,15 @@ NS_IMETHODIMP CViewSourceHTML::DidBuildModel(nsresult anErrorCode,PRBool aNotify
if(ePlainText!=mDocType) {
#ifdef VIEW_SOURCE_HTML
CEndToken theToken(eHTMLTag_pre);
nsCParserNode preNode(&theToken,0,mTokenizer->GetTokenAllocator());
nsCParserNode preNode(&theToken,0);
mSink->CloseContainer(preNode);
CEndToken bodyToken(eHTMLTag_body);
nsCParserNode bodyNode(&bodyToken,0,mTokenizer->GetTokenAllocator());
nsCParserNode bodyNode(&bodyToken,0);
mSink->CloseBody(bodyNode);
CEndToken htmlToken(eHTMLTag_html);
nsCParserNode htmlNode(&htmlToken,0,mTokenizer->GetTokenAllocator());
nsCParserNode htmlNode(&htmlToken,0);
mSink->CloseHTML(htmlNode);
#else
//now let's automatically close the root container...
@ -882,8 +886,7 @@ nsresult CViewSourceHTML::WriteTag(nsString &theXMLTagName,const nsAReadableStri
nsAutoString beforeText;
beforeText.AssignWithConversion(kBeforeText[aTagType]);
theContext.mITextToken.SetIndirectString(beforeText);
nsCParserNode theNode(&theContext.mITextToken,0,mTokenizer->GetTokenAllocator());
mSink->AddLeaf(theNode);
mSink->AddLeaf(theContext.mITextNode);
}
#ifdef VIEW_SOURCE_COLORING
@ -897,7 +900,7 @@ nsresult CViewSourceHTML::WriteTag(nsString &theXMLTagName,const nsAReadableStri
#ifdef VIEW_SOURCE_COLORING
if (syntaxHighlight)
{
theContext.mStartNode.Init(&theTagToken,mLineNumber,mTokenizer->GetTokenAllocator());
theContext.mStartNode.Init(&theTagToken,mLineNumber);
#ifdef VIEW_SOURCE_HTML
nsTokenAllocator* theAllocator=mTokenizer->GetTokenAllocator();
if(theAllocator) {
@ -928,8 +931,7 @@ nsresult CViewSourceHTML::WriteTag(nsString &theXMLTagName,const nsAReadableStri
theContext.mITextToken.SetIndirectString(aText); //now emit the tag name...
nsCParserNode theNode(&theContext.mITextToken,0,mTokenizer->GetTokenAllocator());
mSink->AddLeaf(theNode);
mSink->AddLeaf(theContext.mITextNode);
if(attrCount){
result=WriteAttributes(attrCount);
@ -941,7 +943,7 @@ nsresult CViewSourceHTML::WriteTag(nsString &theXMLTagName,const nsAReadableStri
{
theContext.mStartNode.ReleaseAll();
CEndToken theEndToken(eHTMLTag_span);
theContext.mEndNode.Init(&theEndToken,mLineNumber,mTokenizer->GetTokenAllocator());
theContext.mEndNode.Init(&theEndToken,mLineNumber);
mSink->CloseContainer(theContext.mEndNode); //emit </starttag>...
}
#endif // VIEW_SOURCE_COLORING
@ -949,8 +951,7 @@ nsresult CViewSourceHTML::WriteTag(nsString &theXMLTagName,const nsAReadableStri
nsAutoString afterText;
afterText.AssignWithConversion(kAfterText[aTagType]);
theContext.mITextToken.SetIndirectString(afterText);
nsCParserNode theNode(&theContext.mITextToken,0,mTokenizer->GetTokenAllocator());
mSink->AddLeaf(theNode);
mSink->AddLeaf(theContext.mITextNode);
}
#else
theContext.mEndNode.Init(&theTagToken,mLineNumber);
@ -989,7 +990,7 @@ nsresult CViewSourceHTML::WriteTagWithError(nsString &theXMLTagName,const nsARea
//first write the error tag itself...
theContext.mErrorNode.Init(&theContext.mErrorToken,mLineNumber,mTokenizer->GetTokenAllocator());
theContext.mErrorNode.Init(&theContext.mErrorToken,mLineNumber);
result=mSink->OpenContainer(theContext.mErrorNode); //emit <error>...
}
@ -1004,7 +1005,7 @@ nsresult CViewSourceHTML::WriteTagWithError(nsString &theXMLTagName,const nsARea
//now close the error tag...
STOP_TIMER();
theContext.mErrorNode.Init(&theContext.mErrorToken,mLineNumber,mTokenizer->GetTokenAllocator());
theContext.mErrorNode.Init(&theContext.mErrorToken,mLineNumber);
mSink->CloseContainer(theContext.mErrorNode);
START_TIMER();
}
@ -1056,7 +1057,7 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) {
#endif // VIEW_SOURCE_HTML
CSharedVSContext& theContext=CSharedVSContext::GetSharedContext();
theContext.mTokenNode.Init(theToken,mLineNumber,mTokenizer->GetTokenAllocator());
theContext.mTokenNode.Init(theToken,mLineNumber);
eHTMLTags theParent=(mTags.Length()) ? (eHTMLTags)mTags.Last() : eHTMLTag_unknown;
eHTMLTags theChild=(eHTMLTags)aToken->GetTypeID();

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

@ -952,7 +952,7 @@ nsresult CNavDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){
const nsString& theString=aNode.GetSkippedContent();
if(0<theString.Length()) {
CTextToken *theToken=NS_STATIC_CAST(CTextToken*,mTokenAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text,theString));
nsCParserNode theNode(theToken,0,mTokenAllocator);
nsCParserNode theNode(theToken,0);
result=mSink->AddLeaf(theNode); //when the node get's destructed, so does the new token
}
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::DidHandleStartTag(), this=%p\n", this));
@ -971,7 +971,7 @@ nsresult CNavDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){
CTextToken theToken(theNumber);
PRInt32 theLineNumber=0;
nsCParserNode theNode(&theToken,theLineNumber,mTokenAllocator);
nsCParserNode theNode(&theToken,theLineNumber);
result=mSink->AddLeaf(theNode);
}
break;
@ -1420,7 +1420,7 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsIParserNode
//because this code calls CloseHead() directly, stack-based token/nodes are ok.
CEndToken theToken(eHTMLTag_head);
nsCParserNode theNode(&theToken,mLineNumber,mTokenAllocator);
nsCParserNode theNode(&theToken,mLineNumber);
result=CloseHead(&theNode);
}
}
@ -1903,7 +1903,7 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) {
case eHTMLTag_form:
{
//this is safe because we call close container directly. This node/token is not cached.
nsCParserNode theNode((CHTMLToken*)aToken,mLineNumber,mTokenAllocator);
nsCParserNode theNode((CHTMLToken*)aToken,mLineNumber);
result=CloseContainer(&theNode,theChildTag,PR_FALSE);
}
break;

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

@ -250,14 +250,14 @@ public:
nsresult result=NS_OK;
CStartToken theToken(*aTagList);
nsCParserNode theNode(&theToken,theLineNumber,aContext->mTokenAllocator);
nsCParserNode theNode(&theToken,theLineNumber);
result=OpenContainer(&theNode,*aTagList,aContext,aSink);
if(eHTMLTag_unknown!=*(aTagList+1)) {
AutoGenerateStructure(++aTagList,aContext,aSink);
}
CEndToken theEndToken(*aTagList--);
nsCParserNode theEndNode(&theEndToken,theLineNumber,aContext->mTokenAllocator);
nsCParserNode theEndNode(&theEndToken,theLineNumber);
result=CloseContainer(&theEndNode,*aTagList,aContext,aSink);
return result;
@ -1005,7 +1005,7 @@ public:
CTextToken theToken(theNumber);
PRInt32 theLineNumber=0;
nsCParserNode theNewNode(&theToken,theLineNumber,aContext->mTokenAllocator);
nsCParserNode theNewNode(&theToken,theLineNumber);
result=aSink->AddLeaf(theNewNode);
return result;
}

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

@ -455,7 +455,7 @@ NS_IMETHODIMP nsExpatDTD::HandleToken(CToken* aToken,nsIParser* aParser) {
mParser=(nsParser*)aParser;
mSink=aParser->GetContentSink();
nsCParserNode theNode(theToken,mLineNumber,mTokenizer->GetTokenAllocator());
nsCParserNode theNode(theToken,mLineNumber);
switch(theType) {
case eToken_newline:

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

@ -40,25 +40,7 @@ const nsString& GetEmptyString() {
/**
* Default Constructor
*/
nsCParserNode::nsCParserNode()
: mLineNumber(1),
mToken(nsnull),
mAttributes(nsnull),
mSkippedContent(nsnull),
mUseCount(0),
mGenericState(PR_FALSE),
mTokenAllocator(nsnull)
{
MOZ_COUNT_CTOR(nsCParserNode);
#ifdef HEAP_ALLOCATED_NODES
mNodeAllocator=nsnull;
#endif
}
/**
* Constructor
* Default constructor
*
* @update gess 3/25/98
* @param aToken -- token to init internal token
@ -361,11 +343,13 @@ void nsCParserNode::GetSource(nsString& aString) {
* @return void
*/
nsresult nsCParserNode::ReleaseAll() {
NS_ASSERTION(mTokenAllocator != nsnull, "aiee! no token allocator!");
if(mAttributes) {
CToken* theAttrToken=0;
while((theAttrToken=NS_STATIC_CAST(CToken*,mAttributes->Pop()))) {
IF_FREE(theAttrToken, mTokenAllocator);
// nsViewSourceHTML.cpp:513 creates nsCParserNodes with a NULL token allocator
// need to check to see if mTokenAllocator is non-null
if(mTokenAllocator)
IF_FREE(theAttrToken, mTokenAllocator);
}
delete mAttributes;
mAttributes=0;

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

@ -108,15 +108,10 @@ class nsCParserNode : public nsIParserNode {
/**
* Default constructor
*/
nsCParserNode();
/**
* Constructor
* @update gess5/11/98
* @param aToken is the token this node "refers" to
*/
nsCParserNode(CToken* aToken,PRInt32 aLineNumber,nsTokenAllocator* aTokenAllocator,nsNodeAllocator* aNodeAllocator=0);
nsCParserNode(CToken* aToken=nsnull,PRInt32 aLineNumber=1,nsTokenAllocator* aTokenAllocator=0,nsNodeAllocator* aNodeAllocator=0);
/**
* Destructor
@ -128,7 +123,7 @@ class nsCParserNode : public nsIParserNode {
* Init
* @update gess5/11/98
*/
virtual nsresult Init(CToken* aToken,PRInt32 aLineNumber,nsTokenAllocator* aTokenAllocator,nsNodeAllocator* aNodeAllocator=0);
virtual nsresult Init(CToken* aToken=nsnull,PRInt32 aLineNumber=1,nsTokenAllocator* aTokenAllocator=0,nsNodeAllocator* aNodeAllocator=0);
/**
* Retrieve the name of the node

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

@ -141,7 +141,7 @@ class CToken {
* @update harishd 08/02/00
*/
void Release(nsFixedSizeAllocator& aArenaPool) {
if(--mUseCount==0)
if(--mUseCount==0)
Destroy(this, aArenaPool);
}

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

@ -188,12 +188,15 @@ class CSharedVSContext {
public:
CSharedVSContext() :
mEndNode(),
mEndNode(),
mStartNode(),
mTokenNode(),
mErrorNode(),
mITextToken(),
mErrorToken(NS_ConvertASCIItoUCS2("error")) {
mITextNode(&mITextToken),
mTextToken(),
mErrorToken(NS_ConvertASCIItoUCS2("error")),
mTextNode(&mTextToken){
}
~CSharedVSContext() {
@ -209,7 +212,10 @@ public:
nsCParserNode mTokenNode;
nsCParserNode mErrorNode;
CIndirectTextToken mITextToken;
nsCParserNode mITextNode;
CTextToken mTextToken;
CTextToken mErrorToken;
nsCParserNode mTextNode;
};
#ifdef VIEW_SOURCE_HTML
@ -443,6 +449,24 @@ nsresult CViewSourceHTML::WillBuildModel( const CParserContext& aParserContext,
mErrorCount=0;
mTagCount=0;
#ifdef VIEW_SOURCE_HTML
nsAutoString tag;
tag.AssignWithConversion("HTML");
CStartToken htmlToken(tag, eHTMLTag_html);
nsCParserNode htmlNode(&htmlToken,0);
mSink->OpenHTML(htmlNode);
tag.AssignWithConversion("BODY");
CStartToken bodyToken(tag, eHTMLTag_body);
nsCParserNode bodyNode(&bodyToken,0);
mSink->OpenBody(bodyNode);
#else
CCommentToken ssToken(NS_LITERAL_STRING("<?xml version=\"1.0\"?>"));
nsCParserNode ssNode(&ssToken);
result= mSink->AddCharacterData(ssNode);
#endif // VIEW_SOURCE_HTML
#ifdef rickgdebug
(*gDumpFile) << theHeader << endl;
(*gDumpFile) << "<viewsource xmlns=\"viewsource\">" << endl;
@ -479,37 +503,17 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
if(!mHasOpenRoot) {
#ifdef VIEW_SOURCE_HTML
// For the stack-allocated tokens below, it's safe to pass a null
// token allocator, because there are no attributes on the tokens.
nsAutoString tag;
tag.AssignWithConversion("HTML");
CStartToken htmlToken(tag, eHTMLTag_html);
nsCParserNode htmlNode(&htmlToken,0,mTokenizer->GetTokenAllocator());
mSink->OpenHTML(htmlNode);
tag.AssignWithConversion("BODY");
CStartToken bodyToken(tag, eHTMLTag_body);
nsCParserNode bodyNode(&bodyToken,0,mTokenizer->GetTokenAllocator());
mSink->OpenBody(bodyNode);
#else
CCommentToken ssToken(NS_LITERAL_STRING("<?xml version=\"1.0\"?>"));
nsCParserNode ssNode(&ssToken,0,nsnull);
result= mSink->AddCharacterData(ssNode,0,mTokenizer->GetTokenAllocator());
#endif // VIEW_SOURCE_HTML
#ifdef VIEW_SOURCE_HTML
tag.AssignWithConversion("PRE");
CStartToken theToken(tag, eHTMLTag_pre);
#else
//now let's automatically open the root container...
CStartToken theToken(NS_LITERAL_STRING("viewsource"));
#endif // VIEW_SOURCE_HTML
nsCParserNode theNode(&theToken,0);
CAttributeToken *theAttr=nsnull;
nsTokenAllocator* theAllocator=mTokenizer->GetTokenAllocator();
nsCParserNode theNode(&theToken,0,theAllocator);
if(theAllocator) {
#ifdef VIEW_SOURCE_HTML
theAttr=(CAttributeToken*)theAllocator->CreateTokenOfType(eToken_attribute,eHTMLTag_unknown,NS_ConvertASCIItoUCS2(kPreStyle));
@ -603,15 +607,15 @@ NS_IMETHODIMP CViewSourceHTML::DidBuildModel(nsresult anErrorCode,PRBool aNotify
if(ePlainText!=mDocType) {
#ifdef VIEW_SOURCE_HTML
CEndToken theToken(eHTMLTag_pre);
nsCParserNode preNode(&theToken,0,mTokenizer->GetTokenAllocator());
nsCParserNode preNode(&theToken,0);
mSink->CloseContainer(preNode);
CEndToken bodyToken(eHTMLTag_body);
nsCParserNode bodyNode(&bodyToken,0,mTokenizer->GetTokenAllocator());
nsCParserNode bodyNode(&bodyToken,0);
mSink->CloseBody(bodyNode);
CEndToken htmlToken(eHTMLTag_html);
nsCParserNode htmlNode(&htmlToken,0,mTokenizer->GetTokenAllocator());
nsCParserNode htmlNode(&htmlToken,0);
mSink->CloseHTML(htmlNode);
#else
//now let's automatically close the root container...
@ -882,8 +886,7 @@ nsresult CViewSourceHTML::WriteTag(nsString &theXMLTagName,const nsAReadableStri
nsAutoString beforeText;
beforeText.AssignWithConversion(kBeforeText[aTagType]);
theContext.mITextToken.SetIndirectString(beforeText);
nsCParserNode theNode(&theContext.mITextToken,0,mTokenizer->GetTokenAllocator());
mSink->AddLeaf(theNode);
mSink->AddLeaf(theContext.mITextNode);
}
#ifdef VIEW_SOURCE_COLORING
@ -897,7 +900,7 @@ nsresult CViewSourceHTML::WriteTag(nsString &theXMLTagName,const nsAReadableStri
#ifdef VIEW_SOURCE_COLORING
if (syntaxHighlight)
{
theContext.mStartNode.Init(&theTagToken,mLineNumber,mTokenizer->GetTokenAllocator());
theContext.mStartNode.Init(&theTagToken,mLineNumber);
#ifdef VIEW_SOURCE_HTML
nsTokenAllocator* theAllocator=mTokenizer->GetTokenAllocator();
if(theAllocator) {
@ -928,8 +931,7 @@ nsresult CViewSourceHTML::WriteTag(nsString &theXMLTagName,const nsAReadableStri
theContext.mITextToken.SetIndirectString(aText); //now emit the tag name...
nsCParserNode theNode(&theContext.mITextToken,0,mTokenizer->GetTokenAllocator());
mSink->AddLeaf(theNode);
mSink->AddLeaf(theContext.mITextNode);
if(attrCount){
result=WriteAttributes(attrCount);
@ -941,7 +943,7 @@ nsresult CViewSourceHTML::WriteTag(nsString &theXMLTagName,const nsAReadableStri
{
theContext.mStartNode.ReleaseAll();
CEndToken theEndToken(eHTMLTag_span);
theContext.mEndNode.Init(&theEndToken,mLineNumber,mTokenizer->GetTokenAllocator());
theContext.mEndNode.Init(&theEndToken,mLineNumber);
mSink->CloseContainer(theContext.mEndNode); //emit </starttag>...
}
#endif // VIEW_SOURCE_COLORING
@ -949,8 +951,7 @@ nsresult CViewSourceHTML::WriteTag(nsString &theXMLTagName,const nsAReadableStri
nsAutoString afterText;
afterText.AssignWithConversion(kAfterText[aTagType]);
theContext.mITextToken.SetIndirectString(afterText);
nsCParserNode theNode(&theContext.mITextToken,0,mTokenizer->GetTokenAllocator());
mSink->AddLeaf(theNode);
mSink->AddLeaf(theContext.mITextNode);
}
#else
theContext.mEndNode.Init(&theTagToken,mLineNumber);
@ -989,7 +990,7 @@ nsresult CViewSourceHTML::WriteTagWithError(nsString &theXMLTagName,const nsARea
//first write the error tag itself...
theContext.mErrorNode.Init(&theContext.mErrorToken,mLineNumber,mTokenizer->GetTokenAllocator());
theContext.mErrorNode.Init(&theContext.mErrorToken,mLineNumber);
result=mSink->OpenContainer(theContext.mErrorNode); //emit <error>...
}
@ -1004,7 +1005,7 @@ nsresult CViewSourceHTML::WriteTagWithError(nsString &theXMLTagName,const nsARea
//now close the error tag...
STOP_TIMER();
theContext.mErrorNode.Init(&theContext.mErrorToken,mLineNumber,mTokenizer->GetTokenAllocator());
theContext.mErrorNode.Init(&theContext.mErrorToken,mLineNumber);
mSink->CloseContainer(theContext.mErrorNode);
START_TIMER();
}
@ -1056,7 +1057,7 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) {
#endif // VIEW_SOURCE_HTML
CSharedVSContext& theContext=CSharedVSContext::GetSharedContext();
theContext.mTokenNode.Init(theToken,mLineNumber,mTokenizer->GetTokenAllocator());
theContext.mTokenNode.Init(theToken,mLineNumber);
eHTMLTags theParent=(mTags.Length()) ? (eHTMLTags)mTags.Last() : eHTMLTag_unknown;
eHTMLTags theChild=(eHTMLTags)aToken->GetTypeID();