diff --git a/htmlparser/src/CNavDTD.cpp b/htmlparser/src/CNavDTD.cpp index a76dd427c700..4992562b3ee2 100644 --- a/htmlparser/src/CNavDTD.cpp +++ b/htmlparser/src/CNavDTD.cpp @@ -39,6 +39,7 @@ #include "nsHTMLContentSink.h" #include "nsScanner.h" #include "nsParserTypes.h" +#include "nsVoidArray.h" #include "prenv.h" //this is here for debug reasons... #include "prtypes.h" //this is here for debug reasons... @@ -235,9 +236,6 @@ CNavDTD::CNavDTD() : nsIDTD(), mTokenDeque(gTokenKiller) { mFilename=0; mSink = nsnull; mDTDDebug=0; - nsCRT::zero(mLeafBits,sizeof(mLeafBits)); - nsCRT::zero(mContextStack,sizeof(mContextStack)); - nsCRT::zero(mStyleStack,sizeof(mStyleStack)); nsCRT::zero(mTokenHandlers,sizeof(mTokenHandlers)); mContextStackPos=0; mStyleStackPos=0; @@ -389,13 +387,13 @@ PRInt32 CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsCP } if(IsContainer(aChildTag)){ - if(PR_TRUE==mLeafBits[mContextStackPos-1]) { + if(PR_TRUE==(PRBool)mLeafBits[mContextStackPos-1]) { CloseTransientStyles(aChildTag); } result=OpenContainer(aNode,PR_TRUE); } else { - if(PR_FALSE==mLeafBits[mContextStackPos-1]) { + if(PR_FALSE==(PRBool)mLeafBits[mContextStackPos-1]) { OpenTransientStyles(aChildTag); } result=AddLeaf(aNode); @@ -1661,7 +1659,7 @@ PRBool CNavDTD::HasOpenContainer(eHTMLTags aContainer) const { */ eHTMLTags CNavDTD::GetTopNode() const { if(mContextStackPos) - return mContextStack[mContextStackPos-1]; + return (eHTMLTags)(int)mContextStack[mContextStackPos-1]; return eHTMLTag_unknown; } @@ -1677,7 +1675,7 @@ eHTMLTags CNavDTD::GetTopNode() const { PRInt32 CNavDTD::GetTopmostIndexOf(eHTMLTags aTag) const { int i=0; for(i=mContextStackPos-1;i>=0;i--){ - if(mContextStack[i]==aTag) + if((eHTMLTags)(int)mContextStack[i]==aTag) return i; } return kNotFound; @@ -1709,7 +1707,7 @@ PRInt32 CNavDTD::OpenTransientStyles(eHTMLTags aTag){ eHTMLTags parentTag=(eHTMLTags)GetTopNode(); if(CanContainStyles(parentTag)) { for(pos=0;pos0) && (mLeafBits[mContextStackPos-1])) { if(0==strchr(gWhitespaceTags,aTag)){ - result=CloseContainersTo(mStyleStack[0],PR_FALSE); - mLeafBits[mContextStackPos-1]=PR_FALSE; + result=CloseContainersTo((eHTMLTags)(int)mStyleStack[0],PR_FALSE); + mLeafBits.InsertElementAt((void*)PR_FALSE,mContextStackPos); }//if }//if @@ -1773,7 +1771,7 @@ PRInt32 CNavDTD::OpenHTML(const nsIParserNode& aNode){ NS_PRECONDITION(mContextStackPos >= 0, kInvalidTagStackPos); PRInt32 result=mSink->OpenHTML(aNode); - mContextStack[mContextStackPos++]=(eHTMLTags)aNode.GetNodeType(); + mContextStack.InsertElementAt((void*)aNode.GetNodeType(),mContextStackPos++); return result; } @@ -1789,7 +1787,7 @@ PRInt32 CNavDTD::OpenHTML(const nsIParserNode& aNode){ PRInt32 CNavDTD::CloseHTML(const nsIParserNode& aNode){ NS_PRECONDITION(mContextStackPos > 0, kInvalidTagStackPos); PRInt32 result=mSink->CloseHTML(aNode); - mContextStack[--mContextStackPos]=eHTMLTag_unknown; + mContextStack.InsertElementAt((void*)eHTMLTag_unknown,--mContextStackPos); return result; } @@ -1803,7 +1801,7 @@ PRInt32 CNavDTD::CloseHTML(const nsIParserNode& aNode){ * @return TRUE if ok, FALSE if error */ PRInt32 CNavDTD::OpenHead(const nsIParserNode& aNode){ - mContextStack[mContextStackPos++]=eHTMLTag_head; + mContextStack.InsertElementAt((void*)eHTMLTag_head,++mContextStackPos); PRInt32 result=mSink->OpenHead(aNode); return result; } @@ -1818,7 +1816,7 @@ PRInt32 CNavDTD::OpenHead(const nsIParserNode& aNode){ */ PRInt32 CNavDTD::CloseHead(const nsIParserNode& aNode){ PRInt32 result=mSink->CloseHead(aNode); - mContextStack[--mContextStackPos]=eHTMLTag_unknown; + mContextStack.InsertElementAt((void*)eHTMLTag_unknown,--mContextStackPos); return result; } @@ -1863,7 +1861,7 @@ PRInt32 CNavDTD::OpenBody(const nsIParserNode& aNode){ if(kNoError==result) { result=mSink->OpenBody(aNode); - mContextStack[mContextStackPos++]=(eHTMLTags)aNode.GetNodeType(); + mContextStack.InsertElementAt((void*)aNode.GetNodeType(),mContextStackPos++); } return result; } @@ -1879,7 +1877,7 @@ PRInt32 CNavDTD::OpenBody(const nsIParserNode& aNode){ PRInt32 CNavDTD::CloseBody(const nsIParserNode& aNode){ NS_PRECONDITION(mContextStackPos >= 0, kInvalidTagStackPos); PRInt32 result=mSink->CloseBody(aNode); - mContextStack[--mContextStackPos]=eHTMLTag_unknown; + mContextStack.InsertElementAt((void*)eHTMLTag_unknown,--mContextStackPos); return result; } @@ -1970,7 +1968,7 @@ PRInt32 CNavDTD::CloseMap(const nsIParserNode& aNode){ PRInt32 CNavDTD::OpenFrameset(const nsIParserNode& aNode){ NS_PRECONDITION(mContextStackPos >= 0, kInvalidTagStackPos); PRInt32 result=mSink->OpenFrameset(aNode); - mContextStack[mContextStackPos++]=(eHTMLTags)aNode.GetNodeType(); + mContextStack.InsertElementAt((void*)aNode.GetNodeType(),mContextStackPos++); return result; } @@ -1985,7 +1983,7 @@ PRInt32 CNavDTD::OpenFrameset(const nsIParserNode& aNode){ PRInt32 CNavDTD::CloseFrameset(const nsIParserNode& aNode){ NS_PRECONDITION(mContextStackPos > 0, kInvalidTagStackPos); PRInt32 result=mSink->CloseFrameset(aNode); - mContextStack[--mContextStackPos]=eHTMLTag_unknown; + mContextStack.InsertElementAt((void*)eHTMLTag_unknown,--mContextStackPos); return result; } @@ -2025,7 +2023,7 @@ PRInt32 CNavDTD::OpenContainer(const nsIParserNode& aNode,PRBool aUpdateStyleSta default: result=mSink->OpenContainer(aNode); - mContextStack[mContextStackPos++]=nodeType; + mContextStack.InsertElementAt((void*)nodeType,mContextStackPos++); break; } @@ -2073,11 +2071,11 @@ PRInt32 CNavDTD::CloseContainer(const nsIParserNode& aNode,eHTMLTags aTag,PRBool case eHTMLTag_title: default: result=mSink->CloseContainer(aNode); - mContextStack[--mContextStackPos]=eHTMLTag_unknown; + mContextStack.InsertElementAt((void*)eHTMLTag_unknown,--mContextStackPos); break; } - mLeafBits[mContextStackPos]=PR_FALSE; + mLeafBits.InsertElementAt((void*)PR_FALSE, mContextStackPos); if((kNoError==result) && (PR_TRUE==aUpdateStyles)){ UpdateStyleStackForCloseTag(nodeType,aTag); } @@ -2102,7 +2100,7 @@ PRInt32 CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag,PRBool aUpdate if((anIndex=0)) { while(mContextStackPos>anIndex) { - eHTMLTags theTag=mContextStack[mContextStackPos-1]; + eHTMLTags theTag=(eHTMLTags)(int)mContextStack[mContextStackPos-1]; aToken.SetTypeID(theTag); result=CloseContainer(theNode,aTag,aUpdateStyles); } @@ -2163,7 +2161,7 @@ PRInt32 CNavDTD::CloseTopmostContainer(){ NS_PRECONDITION(mContextStackPos > 0, kInvalidTagStackPos); CEndToken aToken(gEmpty); - eHTMLTags theTag=(eHTMLTags)mContextStack[mContextStackPos-1]; + eHTMLTags theTag=(eHTMLTags)(int)mContextStack[mContextStackPos-1]; aToken.SetTypeID(theTag); nsCParserNode theNode(&aToken); return CloseContainer(theNode,theTag,PR_TRUE); @@ -2205,7 +2203,7 @@ PRInt32 CNavDTD::CreateContextStackFor(eHTMLTags aChildTag){ //add code here to build up context stack based on forward propagated context vector... pos=0; cnt=theVector.Length()-1; - if(mContextStack[mContextStackPos-1]==theVector[cnt]) + if(mContextStack[mContextStackPos-1]==(void*)theVector[cnt]) result=kNoError; else result=kContextMismatch; } @@ -2225,7 +2223,7 @@ PRInt32 CNavDTD::CreateContextStackFor(eHTMLTags aChildTag){ cnt=theVector.Length(); result=kNoError; while(posVerify(this, mParser, mContextStackPos, mContextStack, mFilename); +// if (mDTDDebug) +// mDTDDebug->Verify(this, mParser, mContextStackPos, mContextStack, mFilename); } }//if diff --git a/htmlparser/src/nsDTDDebug.cpp b/htmlparser/src/nsDTDDebug.cpp index 7e4f2fd0be03..a67ad7ac4752 100644 --- a/htmlparser/src/nsDTDDebug.cpp +++ b/htmlparser/src/nsDTDDebug.cpp @@ -27,6 +27,7 @@ #include "CNavDTD.h" #include "nsHTMLTokens.h" +#include "nsVoidArray.h" #include "nsParser.h" #include "nsIDTDDebug.h" #include "nsCRT.h" @@ -66,7 +67,7 @@ public: void SetVerificationDirectory(char * verify_dir); void SetRecordStatistics(PRBool bval); - PRBool Verify(nsIDTD * aDTD, nsParser * aParser, int ContextStackPos, eHTMLTags aContextStack[], char * aURLRef); + PRBool Verify(nsIDTD * aDTD, nsParser * aParser, int ContextStackPos, nsVoidArray &aContextStack, char * aURLRef); void DumpVectorRecord(void); // global table for storing vector statistics and the size @@ -78,7 +79,7 @@ private: PRBool mRecordingStatistics; PRBool DebugRecord(char * path, char * pURLRef, char * filename); - void NoteVector(eHTMLTags aTags[],PRInt32 count, PRBool good_vector); + void NoteVector(nsVoidArray & aTags,PRInt32 count, PRBool good_vector); void MakeVectorString(char * vector_string, VectorInfo * pInfo); }; @@ -309,7 +310,7 @@ static int compare( const void *arg1, const void *arg2 ) * @return */ -void CDTDDebug::NoteVector(eHTMLTags aTags[],PRInt32 count, PRBool good_vector) +void CDTDDebug::NoteVector(nsVoidArray & aTags,PRInt32 count, PRBool good_vector) { // if the table doesn't exist, create it if (!mVectorInfoArray) { @@ -317,17 +318,26 @@ void CDTDDebug::NoteVector(eHTMLTags aTags[],PRInt32 count, PRBool good_vector) } else { // attempt to look up the vector - for (PRInt32 i = 0; i < mVectorCount; i++) + for (PRInt32 i = 0; i < mVectorCount; i++) // check the vector only if they are the same size, if they // match then just return without doing further work - if (mVectorInfoArray[i]->count == count) - if (!memcmp(mVectorInfoArray[i]->vector, aTags, sizeof(eHTMLTags)*count)) { + if (mVectorInfoArray[i]->count == count) { + PRBool match = PR_TRUE; + + for (PRInt32 j = 0; j < count; j++) + if (mVectorInfoArray[i]->vector[j] != (eHTMLTags)(int)aTags[j]) { + match = PR_FALSE; + break; + } + + if (match) { // bzzzt. and we have a winner.. bump the ref count mVectorInfoArray[i]->references++; return; - } + } + } } // the context vector hasn't been noted, so allocate it and @@ -337,7 +347,8 @@ void CDTDDebug::NoteVector(eHTMLTags aTags[],PRInt32 count, PRBool good_vector) pVectorInfo->count = count; pVectorInfo->good_vector = good_vector; pVectorInfo->vector = (eHTMLTags*)PR_Malloc(count*sizeof(eHTMLTags)); - memcpy(pVectorInfo->vector,aTags,sizeof(eHTMLTags)*count); + for (PRInt32 i = 0; i < count; i++) + pVectorInfo->vector[i] = (eHTMLTags)(int)aTags[i]; mVectorInfoArray[mVectorCount++] = pVectorInfo; // have we maxed out the table? grow it.. sort it.. love it. @@ -456,7 +467,7 @@ void CDTDDebug::DumpVectorRecord(void) * @return TRUE if we know how to handle it, else false */ -PRBool CDTDDebug::Verify(nsIDTD * aDTD, nsParser * aParser, int aContextStackPos, eHTMLTags aContextStack[], char * aURLRef) +PRBool CDTDDebug::Verify(nsIDTD * aDTD, nsParser * aParser, int aContextStackPos, nsVoidArray &aContextStack, char * aURLRef) { PRBool result=PR_TRUE; @@ -466,7 +477,7 @@ PRBool CDTDDebug::Verify(nsIDTD * aDTD, nsParser * aParser, int aContextStackPo if(aDTD && aContextStackPos>1) { for (int i = 0; i < aContextStackPos-1; i++) - if (!aDTD->CanContain(aContextStack[i],aContextStack[i+1])) { + if (!aDTD->CanContain((eHTMLTags)(int)aContextStack[i],(eHTMLTags)(int)aContextStack[i+1])) { result = PR_FALSE; break; } @@ -484,7 +495,7 @@ PRBool CDTDDebug::Verify(nsIDTD * aDTD, nsParser * aParser, int aContextStackPo int i=0; for(i=0;i=0;i--){ - if(mContextStack[i]==aTag) + if((eHTMLTags)(int)mContextStack[i]==aTag) return i; } return kNotFound; @@ -1709,7 +1707,7 @@ PRInt32 CNavDTD::OpenTransientStyles(eHTMLTags aTag){ eHTMLTags parentTag=(eHTMLTags)GetTopNode(); if(CanContainStyles(parentTag)) { for(pos=0;pos0) && (mLeafBits[mContextStackPos-1])) { if(0==strchr(gWhitespaceTags,aTag)){ - result=CloseContainersTo(mStyleStack[0],PR_FALSE); - mLeafBits[mContextStackPos-1]=PR_FALSE; + result=CloseContainersTo((eHTMLTags)(int)mStyleStack[0],PR_FALSE); + mLeafBits.InsertElementAt((void*)PR_FALSE,mContextStackPos); }//if }//if @@ -1773,7 +1771,7 @@ PRInt32 CNavDTD::OpenHTML(const nsIParserNode& aNode){ NS_PRECONDITION(mContextStackPos >= 0, kInvalidTagStackPos); PRInt32 result=mSink->OpenHTML(aNode); - mContextStack[mContextStackPos++]=(eHTMLTags)aNode.GetNodeType(); + mContextStack.InsertElementAt((void*)aNode.GetNodeType(),mContextStackPos++); return result; } @@ -1789,7 +1787,7 @@ PRInt32 CNavDTD::OpenHTML(const nsIParserNode& aNode){ PRInt32 CNavDTD::CloseHTML(const nsIParserNode& aNode){ NS_PRECONDITION(mContextStackPos > 0, kInvalidTagStackPos); PRInt32 result=mSink->CloseHTML(aNode); - mContextStack[--mContextStackPos]=eHTMLTag_unknown; + mContextStack.InsertElementAt((void*)eHTMLTag_unknown,--mContextStackPos); return result; } @@ -1803,7 +1801,7 @@ PRInt32 CNavDTD::CloseHTML(const nsIParserNode& aNode){ * @return TRUE if ok, FALSE if error */ PRInt32 CNavDTD::OpenHead(const nsIParserNode& aNode){ - mContextStack[mContextStackPos++]=eHTMLTag_head; + mContextStack.InsertElementAt((void*)eHTMLTag_head,++mContextStackPos); PRInt32 result=mSink->OpenHead(aNode); return result; } @@ -1818,7 +1816,7 @@ PRInt32 CNavDTD::OpenHead(const nsIParserNode& aNode){ */ PRInt32 CNavDTD::CloseHead(const nsIParserNode& aNode){ PRInt32 result=mSink->CloseHead(aNode); - mContextStack[--mContextStackPos]=eHTMLTag_unknown; + mContextStack.InsertElementAt((void*)eHTMLTag_unknown,--mContextStackPos); return result; } @@ -1863,7 +1861,7 @@ PRInt32 CNavDTD::OpenBody(const nsIParserNode& aNode){ if(kNoError==result) { result=mSink->OpenBody(aNode); - mContextStack[mContextStackPos++]=(eHTMLTags)aNode.GetNodeType(); + mContextStack.InsertElementAt((void*)aNode.GetNodeType(),mContextStackPos++); } return result; } @@ -1879,7 +1877,7 @@ PRInt32 CNavDTD::OpenBody(const nsIParserNode& aNode){ PRInt32 CNavDTD::CloseBody(const nsIParserNode& aNode){ NS_PRECONDITION(mContextStackPos >= 0, kInvalidTagStackPos); PRInt32 result=mSink->CloseBody(aNode); - mContextStack[--mContextStackPos]=eHTMLTag_unknown; + mContextStack.InsertElementAt((void*)eHTMLTag_unknown,--mContextStackPos); return result; } @@ -1970,7 +1968,7 @@ PRInt32 CNavDTD::CloseMap(const nsIParserNode& aNode){ PRInt32 CNavDTD::OpenFrameset(const nsIParserNode& aNode){ NS_PRECONDITION(mContextStackPos >= 0, kInvalidTagStackPos); PRInt32 result=mSink->OpenFrameset(aNode); - mContextStack[mContextStackPos++]=(eHTMLTags)aNode.GetNodeType(); + mContextStack.InsertElementAt((void*)aNode.GetNodeType(),mContextStackPos++); return result; } @@ -1985,7 +1983,7 @@ PRInt32 CNavDTD::OpenFrameset(const nsIParserNode& aNode){ PRInt32 CNavDTD::CloseFrameset(const nsIParserNode& aNode){ NS_PRECONDITION(mContextStackPos > 0, kInvalidTagStackPos); PRInt32 result=mSink->CloseFrameset(aNode); - mContextStack[--mContextStackPos]=eHTMLTag_unknown; + mContextStack.InsertElementAt((void*)eHTMLTag_unknown,--mContextStackPos); return result; } @@ -2025,7 +2023,7 @@ PRInt32 CNavDTD::OpenContainer(const nsIParserNode& aNode,PRBool aUpdateStyleSta default: result=mSink->OpenContainer(aNode); - mContextStack[mContextStackPos++]=nodeType; + mContextStack.InsertElementAt((void*)nodeType,mContextStackPos++); break; } @@ -2073,11 +2071,11 @@ PRInt32 CNavDTD::CloseContainer(const nsIParserNode& aNode,eHTMLTags aTag,PRBool case eHTMLTag_title: default: result=mSink->CloseContainer(aNode); - mContextStack[--mContextStackPos]=eHTMLTag_unknown; + mContextStack.InsertElementAt((void*)eHTMLTag_unknown,--mContextStackPos); break; } - mLeafBits[mContextStackPos]=PR_FALSE; + mLeafBits.InsertElementAt((void*)PR_FALSE, mContextStackPos); if((kNoError==result) && (PR_TRUE==aUpdateStyles)){ UpdateStyleStackForCloseTag(nodeType,aTag); } @@ -2102,7 +2100,7 @@ PRInt32 CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag,PRBool aUpdate if((anIndex=0)) { while(mContextStackPos>anIndex) { - eHTMLTags theTag=mContextStack[mContextStackPos-1]; + eHTMLTags theTag=(eHTMLTags)(int)mContextStack[mContextStackPos-1]; aToken.SetTypeID(theTag); result=CloseContainer(theNode,aTag,aUpdateStyles); } @@ -2163,7 +2161,7 @@ PRInt32 CNavDTD::CloseTopmostContainer(){ NS_PRECONDITION(mContextStackPos > 0, kInvalidTagStackPos); CEndToken aToken(gEmpty); - eHTMLTags theTag=(eHTMLTags)mContextStack[mContextStackPos-1]; + eHTMLTags theTag=(eHTMLTags)(int)mContextStack[mContextStackPos-1]; aToken.SetTypeID(theTag); nsCParserNode theNode(&aToken); return CloseContainer(theNode,theTag,PR_TRUE); @@ -2205,7 +2203,7 @@ PRInt32 CNavDTD::CreateContextStackFor(eHTMLTags aChildTag){ //add code here to build up context stack based on forward propagated context vector... pos=0; cnt=theVector.Length()-1; - if(mContextStack[mContextStackPos-1]==theVector[cnt]) + if(mContextStack[mContextStackPos-1]==(void*)theVector[cnt]) result=kNoError; else result=kContextMismatch; } @@ -2225,7 +2223,7 @@ PRInt32 CNavDTD::CreateContextStackFor(eHTMLTags aChildTag){ cnt=theVector.Length(); result=kNoError; while(posVerify(this, mParser, mContextStackPos, mContextStack, mFilename); +// if (mDTDDebug) +// mDTDDebug->Verify(this, mParser, mContextStackPos, mContextStack, mFilename); } }//if diff --git a/parser/htmlparser/src/nsDTDDebug.cpp b/parser/htmlparser/src/nsDTDDebug.cpp index 7e4f2fd0be03..a67ad7ac4752 100644 --- a/parser/htmlparser/src/nsDTDDebug.cpp +++ b/parser/htmlparser/src/nsDTDDebug.cpp @@ -27,6 +27,7 @@ #include "CNavDTD.h" #include "nsHTMLTokens.h" +#include "nsVoidArray.h" #include "nsParser.h" #include "nsIDTDDebug.h" #include "nsCRT.h" @@ -66,7 +67,7 @@ public: void SetVerificationDirectory(char * verify_dir); void SetRecordStatistics(PRBool bval); - PRBool Verify(nsIDTD * aDTD, nsParser * aParser, int ContextStackPos, eHTMLTags aContextStack[], char * aURLRef); + PRBool Verify(nsIDTD * aDTD, nsParser * aParser, int ContextStackPos, nsVoidArray &aContextStack, char * aURLRef); void DumpVectorRecord(void); // global table for storing vector statistics and the size @@ -78,7 +79,7 @@ private: PRBool mRecordingStatistics; PRBool DebugRecord(char * path, char * pURLRef, char * filename); - void NoteVector(eHTMLTags aTags[],PRInt32 count, PRBool good_vector); + void NoteVector(nsVoidArray & aTags,PRInt32 count, PRBool good_vector); void MakeVectorString(char * vector_string, VectorInfo * pInfo); }; @@ -309,7 +310,7 @@ static int compare( const void *arg1, const void *arg2 ) * @return */ -void CDTDDebug::NoteVector(eHTMLTags aTags[],PRInt32 count, PRBool good_vector) +void CDTDDebug::NoteVector(nsVoidArray & aTags,PRInt32 count, PRBool good_vector) { // if the table doesn't exist, create it if (!mVectorInfoArray) { @@ -317,17 +318,26 @@ void CDTDDebug::NoteVector(eHTMLTags aTags[],PRInt32 count, PRBool good_vector) } else { // attempt to look up the vector - for (PRInt32 i = 0; i < mVectorCount; i++) + for (PRInt32 i = 0; i < mVectorCount; i++) // check the vector only if they are the same size, if they // match then just return without doing further work - if (mVectorInfoArray[i]->count == count) - if (!memcmp(mVectorInfoArray[i]->vector, aTags, sizeof(eHTMLTags)*count)) { + if (mVectorInfoArray[i]->count == count) { + PRBool match = PR_TRUE; + + for (PRInt32 j = 0; j < count; j++) + if (mVectorInfoArray[i]->vector[j] != (eHTMLTags)(int)aTags[j]) { + match = PR_FALSE; + break; + } + + if (match) { // bzzzt. and we have a winner.. bump the ref count mVectorInfoArray[i]->references++; return; - } + } + } } // the context vector hasn't been noted, so allocate it and @@ -337,7 +347,8 @@ void CDTDDebug::NoteVector(eHTMLTags aTags[],PRInt32 count, PRBool good_vector) pVectorInfo->count = count; pVectorInfo->good_vector = good_vector; pVectorInfo->vector = (eHTMLTags*)PR_Malloc(count*sizeof(eHTMLTags)); - memcpy(pVectorInfo->vector,aTags,sizeof(eHTMLTags)*count); + for (PRInt32 i = 0; i < count; i++) + pVectorInfo->vector[i] = (eHTMLTags)(int)aTags[i]; mVectorInfoArray[mVectorCount++] = pVectorInfo; // have we maxed out the table? grow it.. sort it.. love it. @@ -456,7 +467,7 @@ void CDTDDebug::DumpVectorRecord(void) * @return TRUE if we know how to handle it, else false */ -PRBool CDTDDebug::Verify(nsIDTD * aDTD, nsParser * aParser, int aContextStackPos, eHTMLTags aContextStack[], char * aURLRef) +PRBool CDTDDebug::Verify(nsIDTD * aDTD, nsParser * aParser, int aContextStackPos, nsVoidArray &aContextStack, char * aURLRef) { PRBool result=PR_TRUE; @@ -466,7 +477,7 @@ PRBool CDTDDebug::Verify(nsIDTD * aDTD, nsParser * aParser, int aContextStackPo if(aDTD && aContextStackPos>1) { for (int i = 0; i < aContextStackPos-1; i++) - if (!aDTD->CanContain(aContextStack[i],aContextStack[i+1])) { + if (!aDTD->CanContain((eHTMLTags)(int)aContextStack[i],(eHTMLTags)(int)aContextStack[i+1])) { result = PR_FALSE; break; } @@ -484,7 +495,7 @@ PRBool CDTDDebug::Verify(nsIDTD * aDTD, nsParser * aParser, int aContextStackPo int i=0; for(i=0;i