diff --git a/mozilla/base/src/nsDeque.cpp b/mozilla/base/src/nsDeque.cpp index 1185aa3c25c..c221ec9aaf3 100644 --- a/mozilla/base/src/nsDeque.cpp +++ b/mozilla/base/src/nsDeque.cpp @@ -219,13 +219,15 @@ nsDequeIterator nsDeque::End(void) const{ * @param aFunctor object to call for each member * @return *this */ -const nsDeque& nsDeque::ForEach(nsDequeFunctor& aFunctor) const{ +const void* nsDeque::ForEach(nsDequeFunctor& aFunctor) const{ int i=0; for(i=0;iQueryInterface(kIStreamListenerIID, (void**)aDocListener); if (NS_OK == rv) { + + //The following lines were added by Rick. + //These perform "dynamic" DTD registration, allowing + //the caller total control over process, and decoupling + //parser from any given grammar. + + nsIDTD* theDTD=0; + NS_NewNavHTMLDTD(&theDTD); + parser->RegisterDTD(theDTD); + parser->RegisterDTD(theDTD); + parser->SetContentSink(sink); parser->BeginParse(aURL); } diff --git a/mozilla/htmlparser/src/CNavDTD.cpp b/mozilla/htmlparser/src/CNavDTD.cpp index 2025b4b7517..6382f19b7f7 100644 --- a/mozilla/htmlparser/src/CNavDTD.cpp +++ b/mozilla/htmlparser/src/CNavDTD.cpp @@ -40,6 +40,7 @@ #include "nsScanner.h" #include "nsParserTypes.h" #include "nsVoidArray.h" +#include "nsTokenHandler.h" #include "prenv.h" //this is here for debug reasons... #include "prtypes.h" //this is here for debug reasons... @@ -61,6 +62,7 @@ static const char* kNullFilename= "Error: Null filename given"; static const char* kNullTokenizer = "Error: Unable to construct tokenizer"; static const char* kNullToken = "Error: Null token given"; static const char* kInvalidTagStackPos = "Error: invalid tag stack position"; +static const char* kHTMLTextContentType = "text/html"; static nsAutoString gEmpty; @@ -78,7 +80,8 @@ static char gStyleTags[]={ eHTMLTag_a, eHTMLTag_bold, eHTMLTag_big, eHTMLTag_blink, eHTMLTag_cite, eHTMLTag_em, eHTMLTag_font, eHTMLTag_italic, eHTMLTag_kbd, - eHTMLTag_small, eHTMLTag_spell, eHTMLTag_strike, + eHTMLTag_s, eHTMLTag_small, + eHTMLTag_spell, eHTMLTag_strike, eHTMLTag_strong, eHTMLTag_sub, eHTMLTag_sup, eHTMLTag_tt, eHTMLTag_u, eHTMLTag_var, 0}; @@ -215,9 +218,10 @@ void CNavDTD::InitializeDefaultTokenHandlers() { class CNavTokenDeallocator: public nsDequeFunctor{ public: - virtual void operator()(void* anObject) { + virtual void* operator()(void* anObject) { CToken* aToken = (CToken*)anObject; delete aToken; + return 0; } }; @@ -277,6 +281,20 @@ void CNavDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug) NS_ADDREF(mDTDDebug); } +/** + * This method gets called by the parser to determine if this DTD can handle + * the requested process for the requested content type. + * + * @update gess6/24/98 + * @param + * @return TRUE if the DTD can handle the process for this type; FALSE otherwise. + */ +PRBool CNavDTD::IsCapableOf(eProcessType aProcessType, nsString& aContentType,PRInt32 aVersion){ + PRBool result=aContentType.Equals(kHTMLTextContentType); + return result; +} + + /** * * @update gess5/18/98 @@ -337,10 +355,10 @@ PRInt32 CNavDTD::HandleToken(CToken* aToken){ if(aToken) { CHTMLToken* theToken= (CHTMLToken*)(aToken); eHTMLTokenTypes theType=eHTMLTokenTypes(theToken->GetTokenType()); - CTokenHandler* aHandler=GetTokenHandler(theType); + CITokenHandler* theHandler=GetTokenHandler(theType); - if(aHandler) { - result=(*aHandler)(theToken,this); + if(theHandler) { + result=(*theHandler)(theToken,this); if (mDTDDebug) mDTDDebug->Verify(this, mParser, mContextStackPos, mContextStack, mFilename); } @@ -365,10 +383,10 @@ PRInt32 CNavDTD::HandleToken(CToken* aToken){ * @param aNode -- CParserNode representing this start token * @return PR_TRUE if all went well; PR_FALSE if error occured */ -PRInt32 CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode) { +PRInt32 CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsIParserNode& aNode) { NS_PRECONDITION(0!=aToken,kNullToken); - eHTMLTags parentTag=(eHTMLTags)GetTopNode(); + eHTMLTags parentTag=GetTopNode(); PRInt32 result=kNoError; PRBool contains=CanContain(parentTag,aChildTag); @@ -487,30 +505,7 @@ PRInt32 CNavDTD::HandleStartToken(CToken* aToken) { break; case eHTMLTag_script: - { - PRInt32 pos=GetTopmostIndexOf(eHTMLTag_body); - nsCParserNode theNode((CHTMLToken*)aToken); - if (kNotFound == pos) { - // We're in the HEAD - result=OpenHead(theNode); - if(kNoError==result) { - mParser->CollectSkippedContent(attrNode,theCount); - if(kNoError==result) { - result=AddLeaf(attrNode); - if(kNoError==result) - result=CloseHead(theNode); - } - } - } - else { - // We're in the BODY - mParser->CollectSkippedContent(attrNode,theCount); - if(kNoError==result) { - result=AddLeaf(attrNode); - } - } - break; - } + result=HandleScriptToken(st); break; case eHTMLTag_head: break; //ignore head tags... @@ -570,7 +565,7 @@ PRInt32 CNavDTD::HandleEndToken(CToken* aToken) { /* if(0!=strchr(gStyleTags,tokenTagType)){ - eHTMLTags topTag=(eHTMLTags)GetTopNode(); + eHTMLTags topTag=GetTopNode(); if(0!=strchr(gStyleTags,topTag)){ tokenTagType=topTag; } @@ -704,10 +699,32 @@ PRInt32 CNavDTD::HandleAttributeToken(CToken* aToken) { */ PRInt32 CNavDTD::HandleScriptToken(CToken* aToken) { NS_PRECONDITION(0!=aToken,kNullToken); + PRInt32 result=kNoError; + PRInt32 pos=GetTopmostIndexOf(eHTMLTag_body); nsCParserNode theNode((CHTMLToken*)aToken); - PRInt32 theCount=0; - PRInt32 result=mParser->CollectSkippedContent(theNode,theCount); + nsCParserNode attrNode((CHTMLToken*)aToken); + PRInt32 attrCount=aToken->GetAttributeCount(); + + if (kNotFound == pos) { + // We're in the HEAD + result=OpenHead(theNode); + if(kNoError==result) { + mParser->CollectSkippedContent(attrNode,attrCount); + if(kNoError==result) { + result=AddLeaf(attrNode); + if(kNoError==result) + result=CloseHead(theNode); + } + } + } + else { + // We're in the BODY + mParser->CollectSkippedContent(attrNode,attrCount); + if(kNoError==result) { + result=AddLeaf(attrNode); + } + } return result; } @@ -753,8 +770,8 @@ void CNavDTD::DeleteTokenHandlers(void) { * @param aTagType type of tag to be handled * @return valid tag handler (if found) or null */ -CTokenHandler* CNavDTD::GetTokenHandler(eHTMLTokenTypes aType) const { - CTokenHandler* result=0; +CITokenHandler* CNavDTD::GetTokenHandler(eHTMLTokenTypes aType) const { + CITokenHandler* result=0; if((aType>0) && (aTypeGetTokenType(); if(type= 0, kInvalidTagStackPos); PRInt32 result=kNoError; - eHTMLTags topTag=(eHTMLTags)CNavDTD::GetTopNode(); + eHTMLTags topTag=GetTopNode(); if(eHTMLTag_html!=topTag) { @@ -2126,7 +2132,7 @@ PRInt32 CNavDTD::CloseContainersTo(eHTMLTags aTag,PRBool aUpdateStyles){ return CloseContainersTo(pos,aTag,aUpdateStyles); } - eHTMLTags theTopTag=(eHTMLTags)GetTopNode(); + eHTMLTags theTopTag=GetTopNode(); if(IsCompatibleStyleTag(aTag,theTopTag)) { //if you're here, it's because we're trying to close one style tag, //but a different one is actually open. Because this is NAV4x @@ -2263,13 +2269,13 @@ PRInt32 CNavDTD::CreateContextStackFor(eHTMLTags aChildTag){ */ PRInt32 CNavDTD::ReduceContextStackFor(eHTMLTags aChildTag){ PRInt32 result=kNoError; - eHTMLTags topTag=(eHTMLTags)GetTopNode(); + eHTMLTags topTag=GetTopNode(); while( (topTag!=kNotFound) && (PR_FALSE==CanContain(topTag,aChildTag)) && (PR_FALSE==CanContainIndirect(topTag,aChildTag))) { CloseTopmostContainer(); - topTag=(eHTMLTags)GetTopNode(); + topTag=GetTopNode(); } return result; } @@ -2297,6 +2303,7 @@ PRInt32 CNavDTD::UpdateStyleStackForOpenTag(eHTMLTags aTag,eHTMLTags anActualTag case eHTMLTag_font: case eHTMLTag_italic: case eHTMLTag_kbd: + case eHTMLTag_s: case eHTMLTag_small: case eHTMLTag_spell: case eHTMLTag_strike: @@ -2346,6 +2353,7 @@ PRInt32 CNavDTD::UpdateStyleStackForCloseTag(eHTMLTags aTag,eHTMLTags anActualTa case eHTMLTag_kbd: case eHTMLTag_small: case eHTMLTag_spell: + case eHTMLTag_s: case eHTMLTag_strike: case eHTMLTag_strong: case eHTMLTag_sub: diff --git a/mozilla/htmlparser/src/CNavDTD.h b/mozilla/htmlparser/src/CNavDTD.h index ff6087b862a..9dc22e80a76 100644 --- a/mozilla/htmlparser/src/CNavDTD.h +++ b/mozilla/htmlparser/src/CNavDTD.h @@ -28,22 +28,22 @@ #define NS_NAVHTMLDTD__ #include "nsIDTD.h" +#include "nsISupports.h" #include "nsHTMLTokens.h" #include "nshtmlpars.h" -#include "nsParserNode.h" -#include "nsTokenHandler.h" #include "nsVoidArray.h" #include "nsDeque.h" - #define NS_INAVHTML_DTD_IID \ {0x5c5cce40, 0xcfd6, 0x11d1, \ {0xaa, 0xda, 0x00, 0x80, 0x5f, 0x8a, 0x3e, 0x14}} -class nsParser; class nsIHTMLContentSink; class nsIDTDDebug; +class nsIParserNode; +class CITokenHandler; +class nsParser; class CNavDTD : public nsIDTD { @@ -70,13 +70,21 @@ class CNavDTD : public nsIDTD { */ virtual ~CNavDTD(); + /** + * + * @update gess7/1/98 + * @param + * @return + */ + virtual PRBool IsCapableOf(eProcessType aProcessType, nsString& aString, PRInt32 aVersion); + /** * * @update jevering6/23/98 * @param * @return */ - virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug); + virtual void SetDTDDebug(nsIDTDDebug * aDTDDebug); /** * @@ -292,7 +300,7 @@ class CNavDTD : public nsIDTD { * @param aNode is a node be updated with info from given token * @return TRUE if the token was handled. */ - PRInt32 HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode); + PRInt32 HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsIParserNode& aNode); /** * This method gets called when an end token has been consumed and needs @@ -359,7 +367,7 @@ class CNavDTD : public nsIDTD { -private: +protected: /** * Causes token handlers to be registered for this parser. @@ -373,13 +381,13 @@ private: * DEPRECATED * @update gess5/11/98 */ - CTokenHandler* GetTokenHandler(eHTMLTokenTypes aType) const; + CITokenHandler* GetTokenHandler(eHTMLTokenTypes aType) const; /** * DEPRECATED * @update gess5/11/98 */ - CTokenHandler* AddTokenHandler(CTokenHandler* aHandler); + CITokenHandler* AddTokenHandler(CITokenHandler* aHandler); /** * DEPRECATED @@ -679,7 +687,7 @@ protected: nsParser* mParser; nsIHTMLContentSink* mSink; - CTokenHandler* mTokenHandlers[eToken_last]; + CITokenHandler* mTokenHandlers[eToken_last]; nsVoidArray mLeafBits; nsVoidArray mContextStack; @@ -691,9 +699,10 @@ protected: PRBool mHasOpenMap; nsDeque mTokenDeque; char* mFilename; - nsIDTDDebug* mDTDDebug; + nsIDTDDebug* mDTDDebug; }; +extern NS_HTMLPARS nsresult NS_NewNavHTMLDTD(nsIDTD** aInstancePtrResult); #endif diff --git a/mozilla/htmlparser/src/COtherDTD.cpp b/mozilla/htmlparser/src/COtherDTD.cpp index d11b157ad7a..e6e26b9e9fa 100644 --- a/mozilla/htmlparser/src/COtherDTD.cpp +++ b/mozilla/htmlparser/src/COtherDTD.cpp @@ -27,11 +27,11 @@ * TRANSIENT STYLE-HANDLING NOTES: * @update gess 6/15/98 * - * ...add comments here about transient style stack. + * See notes about transient style handling + * in the nsNavDTD.h file. * */ -#include "nsIDTDDebug.h" #include "COtherDTD.h" #include "nsHTMLTokens.h" #include "nsCRT.h" @@ -56,39 +56,17 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIDTDIID, NS_IDTD_IID); static NS_DEFINE_IID(kClassIID, NS_IOtherHTML_DTD_IID); +static NS_DEFINE_IID(kBaseClassIID, NS_INAVHTML_DTD_IID); static const char* kNullURL = "Error: Null URL given"; static const char* kNullFilename= "Error: Null filename given"; static const char* kNullTokenizer = "Error: Unable to construct tokenizer"; static const char* kNullToken = "Error: Null token given"; static const char* kInvalidTagStackPos = "Error: invalid tag stack position"; +static const char* kHTMLTextContentType = "text/html"; static nsAutoString gEmpty; -static char formElementTags[]= { - eHTMLTag_button, eHTMLTag_fieldset, eHTMLTag_input, - eHTMLTag_isindex, eHTMLTag_label, eHTMLTag_legend, - eHTMLTag_select, eHTMLTag_textarea,0}; - -static char gHeadingTags[]={ - eHTMLTag_h1, eHTMLTag_h2, eHTMLTag_h3, - eHTMLTag_h4, eHTMLTag_h5, eHTMLTag_h6, - 0}; - -static char gStyleTags[]={ - eHTMLTag_a, eHTMLTag_bold, eHTMLTag_big, - eHTMLTag_blink, eHTMLTag_cite, eHTMLTag_em, - eHTMLTag_font, eHTMLTag_italic, eHTMLTag_kbd, - eHTMLTag_small, eHTMLTag_spell, eHTMLTag_strike, - eHTMLTag_strong, eHTMLTag_sub, eHTMLTag_sup, - eHTMLTag_tt, eHTMLTag_u, eHTMLTag_var, - 0}; - -static char gWhitespaceTags[]={ - eHTMLTag_newline, eHTMLTag_whitespace, - 0}; - - /** * This method gets called as part of our COM-like interfaces. @@ -109,6 +87,9 @@ nsresult COtherDTD::QueryInterface(const nsIID& aIID, void** aInstancePtr) if(aIID.Equals(kISupportsIID)) { //do IUnknown... *aInstancePtr = (nsIDTD*)(this); } + else if(aIID.Equals(kBaseClassIID)) { //do nav dtd base class... + *aInstancePtr = (CNavDTD*)(this); + } else if(aIID.Equals(kIDTDIID)) { //do IParser base class... *aInstancePtr = (nsIDTD*)(this); } @@ -146,103 +127,14 @@ NS_HTMLPARS nsresult NS_NewOtherHTMLDTD(nsIDTD** aInstancePtrResult) NS_IMPL_ADDREF(COtherDTD) NS_IMPL_RELEASE(COtherDTD) - - /** - * - * - * @update gess 6/9/98 - * @param - * @return - */ -PRInt32 OtherDispatchTokenHandler(CToken* aToken,nsIDTD* aDTD) { - PRInt32 result=0; - CHTMLToken* theToken= (CHTMLToken*)(aToken); - eHTMLTokenTypes theType= (eHTMLTokenTypes)theToken->GetTokenType(); - COtherDTD* theDTD=(COtherDTD*)aDTD; - - if(aDTD) { - switch(theType) { - case eToken_start: - result=theDTD->HandleStartToken(aToken); break; - case eToken_end: - result=theDTD->HandleEndToken(aToken); break; - case eToken_comment: - result=theDTD->HandleCommentToken(aToken); break; - case eToken_entity: - result=theDTD->HandleEntityToken(aToken); break; - case eToken_whitespace: - result=theDTD->HandleStartToken(aToken); break; - case eToken_newline: - result=theDTD->HandleStartToken(aToken); break; - case eToken_text: - result=theDTD->HandleStartToken(aToken); break; - case eToken_attribute: - result=theDTD->HandleAttributeToken(aToken); break; - case eToken_style: - result=theDTD->HandleStyleToken(aToken); break; - case eToken_skippedcontent: - result=theDTD->HandleSkippedContentToken(aToken); break; - default: - result=0; - }//switch - }//if - return result; -} - -/** - * init the set of default token handlers... - * - * @update gess 3/25/98 - * @param - * @return - */ -void COtherDTD::InitializeDefaultTokenHandlers() { - AddTokenHandler(new CTokenHandler(OtherDispatchTokenHandler,eToken_start)); - - AddTokenHandler(new CTokenHandler(OtherDispatchTokenHandler,eToken_end)); - AddTokenHandler(new CTokenHandler(OtherDispatchTokenHandler,eToken_comment)); - AddTokenHandler(new CTokenHandler(OtherDispatchTokenHandler,eToken_entity)); - - AddTokenHandler(new CTokenHandler(OtherDispatchTokenHandler,eToken_whitespace)); - AddTokenHandler(new CTokenHandler(OtherDispatchTokenHandler,eToken_newline)); - AddTokenHandler(new CTokenHandler(OtherDispatchTokenHandler,eToken_text)); - - AddTokenHandler(new CTokenHandler(OtherDispatchTokenHandler,eToken_attribute)); -// AddTokenHandler(new CTokenHandler(OtherDispatchTokenHandler,eToken_script)); - AddTokenHandler(new CTokenHandler(OtherDispatchTokenHandler,eToken_style)); - AddTokenHandler(new CTokenHandler(OtherDispatchTokenHandler,eToken_skippedcontent)); -} - - -class COtherTokenDeallocator: public nsDequeFunctor{ -public: - virtual void operator()(void* anObject) { - CToken* aToken = (CToken*)anObject; - delete aToken; - } -}; - -static COtherTokenDeallocator gTokenKiller; - -/** - * Default constructor + * Default constructor; parent does all the real work. * * @update gess 4/9/98 * @param * @return */ -COtherDTD::COtherDTD() : nsIDTD(), mTokenDeque(gTokenKiller) { - NS_INIT_REFCNT(); - mParser=0; - mFilename=0; - mDTDDebug=0; - nsCRT::zero(mTokenHandlers,sizeof(mTokenHandlers)); - mContextStackPos=0; - mStyleStackPos=0; - mHasOpenForm=PR_FALSE; - mHasOpenMap=PR_FALSE; - InitializeDefaultTokenHandlers(); +COtherDTD::COtherDTD() : CNavDTD() { } /** @@ -253,28 +145,19 @@ COtherDTD::COtherDTD() : nsIDTD(), mTokenDeque(gTokenKiller) { * @return */ COtherDTD::~COtherDTD(){ - DeleteTokenHandlers(); - if (mFilename) - PL_strfree(mFilename); - if (mDTDDebug) - NS_RELEASE(mDTDDebug); -// NS_RELEASE(mSink); + //parent does all the real work of destruction. } /** - * - * @update jevering6/23/98 + * This method gets called by the parser to determine if this DTD can handle + * the requested process for the requested content type. + * + * @update gess6/24/98 * @param - * @return + * @return TRUE if the DTD can handle the process for this type; FALSE otherwise. */ - -void COtherDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug) -{ - if (mDTDDebug) - NS_RELEASE(mDTDDebug); - mDTDDebug = aDTDDebug; - if (mDTDDebug) - NS_ADDREF(mDTDDebug); +PRBool COtherDTD::IsCapableOf(eProcessType aProcessType, nsString& aContentType,PRInt32 aVersion){ + return CNavDTD::IsCapableOf(aProcessType,aContentType,aVersion); } /** @@ -283,21 +166,8 @@ void COtherDTD::SetDTDDebug(nsIDTDDebug * aDTDDebug) * @param * @return */ -PRInt32 COtherDTD::WillBuildModel(const char* aFilename){ - PRInt32 result=0; - - if (mFilename) { - PL_strfree(mFilename); - mFilename=0; - } - if(aFilename) { - mFilename = PL_strdup(aFilename); - } - - if(mSink) - mSink->WillBuildModel(); - - return result; +PRInt32 COtherDTD::WillBuildModel(const char* aFilename) { + return CNavDTD::WillBuildModel(aFilename); } /** @@ -307,16 +177,7 @@ PRInt32 COtherDTD::WillBuildModel(const char* aFilename){ * @return */ PRInt32 COtherDTD::DidBuildModel(PRInt32 anErrorCode){ - PRInt32 result=0; - - if((kNoError==anErrorCode) && (mContextStackPos>0)) { - CloseContainersTo(0,eHTMLTag_unknown,PR_FALSE); - } - if(mSink) { - mSink->DidBuildModel(0); - } - - return result; + return CNavDTD::DidBuildModel(anErrorCode); } /** @@ -331,21 +192,7 @@ PRInt32 COtherDTD::DidBuildModel(PRInt32 anErrorCode){ * @return */ PRInt32 COtherDTD::HandleToken(CToken* aToken){ - PRInt32 result=0; - - if(aToken) { - CHTMLToken* theToken= (CHTMLToken*)(aToken); - eHTMLTokenTypes theType=eHTMLTokenTypes(theToken->GetTokenType()); - CTokenHandler* aHandler=GetTokenHandler(theType); - - if(aHandler) { - result=(*aHandler)(theToken,this); - if (mDTDDebug) - mDTDDebug->Verify(this, mParser, mContextStackPos, mContextStack, mFilename); - } - - }//if - return result; + return CNavDTD::HandleToken(aToken); } @@ -364,40 +211,8 @@ PRInt32 COtherDTD::HandleToken(CToken* aToken){ * @param aNode -- CParserNode representing this start token * @return PR_TRUE if all went well; PR_FALSE if error occured */ -PRInt32 COtherDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode) { - NS_PRECONDITION(0!=aToken,kNullToken); - - eHTMLTags parentTag=(eHTMLTags)GetTopNode(); - PRInt32 result=kNoError; - PRBool contains=CanContain(parentTag,aChildTag); - - if(PR_FALSE==contains){ - result=CreateContextStackFor(aChildTag); - if(kNoError!=result) { - //if you're here, then the new topmost container can't contain aToken. - //You must determine what container hierarchy you need to hold aToken, - //and create that on the parsestack. - result=ReduceContextStackFor(aChildTag); - if(PR_FALSE==CanContain(GetTopNode(),aChildTag)) { - //we unwound too far; now we have to recreate a valid context stack. - result=CreateContextStackFor(aChildTag); - } - } - } - - if(IsContainer(aChildTag)){ - if(PR_TRUE==(PRBool)mLeafBits[mContextStackPos-1]) { - CloseTransientStyles(aChildTag); - } - result=OpenContainer(aNode,PR_TRUE); - } - else { - if(PR_FALSE==(PRBool)mLeafBits[mContextStackPos-1]) { - OpenTransientStyles(aChildTag); - } - result=AddLeaf(aNode); - } - return result; +PRInt32 COtherDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsIParserNode& aNode) { + return CNavDTD::HandleDefaultStartToken(aToken,aChildTag,aNode); } /** @@ -415,105 +230,7 @@ PRInt32 COtherDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,ns * @return PR_TRUE if all went well; PR_FALSE if error occured */ PRInt32 COtherDTD::HandleStartToken(CToken* aToken) { - NS_PRECONDITION(0!=aToken,kNullToken); - - CStartToken* st= (CStartToken*)(aToken); - eHTMLTags tokenTagType=(eHTMLTags)st->GetTypeID(); - - //Begin by gathering up attributes... - nsCParserNode attrNode((CHTMLToken*)aToken); - PRInt16 attrCount=aToken->GetAttributeCount(); - PRInt32 theCount; - PRInt32 result=(0==attrCount) ? kNoError : mParser->CollectAttributes(attrNode,attrCount); - - if(kNoError==result) { - //now check to see if this token should be omitted... - if(PR_FALSE==CanOmit(GetTopNode(),tokenTagType)) { - - switch(tokenTagType) { - - case eHTMLTag_html: - result=OpenHTML(attrNode); break; - - case eHTMLTag_title: - { - nsCParserNode theNode(st); - result=OpenHead(theNode); //open the head... - if(kNoError==result) { - result=mParser->CollectSkippedContent(attrNode,theCount); - mSink->SetTitle(attrNode.GetSkippedContent()); - result=CloseHead(theNode); //close the head... - } - } - break; - - case eHTMLTag_textarea: - { - mParser->CollectSkippedContent(attrNode,theCount); - result=AddLeaf(attrNode); - } - break; - - case eHTMLTag_form: - result = OpenForm(attrNode); - break; - - case eHTMLTag_meta: - case eHTMLTag_link: - { - nsCParserNode theNode((CHTMLToken*)aToken); - result=OpenHead(theNode); - if(kNoError==result) - result=AddLeaf(theNode); - if(kNoError==result) - result=CloseHead(theNode); - } - break; - - case eHTMLTag_style: - { - nsCParserNode theNode((CHTMLToken*)aToken); - result=OpenHead(theNode); - if(kNoError==result) { - mParser->CollectSkippedContent(attrNode,theCount); - if(kNoError==result) { - result=AddLeaf(attrNode); - if(kNoError==result) - result=CloseHead(theNode); - } - } - } - break; - - case eHTMLTag_script: - result=HandleScriptToken(st); break; - - - case eHTMLTag_head: - break; //ignore head tags... - - case eHTMLTag_base: - result=OpenHead(attrNode); - if(kNoError==result) { - result=AddLeaf(attrNode); - if(kNoError==result) - result=CloseHead(attrNode); - } - break; - - case eHTMLTag_nobr: - result=PR_TRUE; - - case eHTMLTag_map: - result=PR_TRUE; - - default: - result=HandleDefaultStartToken(aToken,tokenTagType,attrNode); - break; - } //switch - } //if - } //if - return result; + return CNavDTD::HandleStartToken(aToken); } @@ -531,65 +248,7 @@ PRInt32 COtherDTD::HandleStartToken(CToken* aToken) { * @return PR_TRUE if all went well; PR_FALSE if error occured */ PRInt32 COtherDTD::HandleEndToken(CToken* aToken) { - NS_PRECONDITION(0!=aToken,kNullToken); - - PRInt32 result=kNoError; - CEndToken* et = (CEndToken*)(aToken); - eHTMLTags tokenTagType=(eHTMLTags)et->GetTypeID(); - - // Here's the hacky part: - // Because we're trying to be backward compatible with Nav4/5, - // we have to handle explicit styles the way it does. That means - // that we keep an internal style stack.When an EndToken occurs, - // we should see if it is an explicit style tag. If so, we can - // close AND explicit style tag (goofy, huh?) - -/* - if(0!=strchr(gStyleTags,tokenTagType)){ - eHTMLTags topTag=(eHTMLTags)GetTopNode(); - if(0!=strchr(gStyleTags,topTag)){ - tokenTagType=topTag; - } - } -*/ - - //now check to see if this token should be omitted... - if(PR_TRUE==CanOmitEndTag(GetTopNode(),tokenTagType)) { - UpdateStyleStackForCloseTag(tokenTagType,tokenTagType); - return result; - } - - nsCParserNode theNode((CHTMLToken*)aToken); - switch(tokenTagType) { - - case eHTMLTag_style: - case eHTMLTag_link: - case eHTMLTag_meta: - case eHTMLTag_textarea: - case eHTMLTag_title: - case eHTMLTag_head: - case eHTMLTag_script: - break; - - case eHTMLTag_map: - result=CloseContainer(theNode,tokenTagType,PR_TRUE); - break; - - case eHTMLTag_form: - { - nsCParserNode aNode((CHTMLToken*)aToken); - result=CloseForm(aNode); - } - break; - - default: - if(IsContainer(tokenTagType)){ - result=CloseContainersTo(tokenTagType,PR_TRUE); - } - // - break; - } - return result; + return CNavDTD::HandleEndToken(aToken); } /** @@ -601,17 +260,7 @@ PRInt32 COtherDTD::HandleEndToken(CToken* aToken) { * @return PR_TRUE if all went well; PR_FALSE if error occured */ PRInt32 COtherDTD::HandleEntityToken(CToken* aToken) { - NS_PRECONDITION(0!=aToken,kNullToken); - - CEntityToken* et = (CEntityToken*)(aToken); - PRInt32 result=kNoError; - eHTMLTags tokenTagType=(eHTMLTags)et->GetTypeID(); - - if(PR_FALSE==CanOmit(GetTopNode(),tokenTagType)) { - nsCParserNode aNode((CHTMLToken*)aToken); - result=AddLeaf(aNode); - } - return result; + return CNavDTD::HandleEntityToken(aToken); } /** @@ -625,8 +274,7 @@ PRInt32 COtherDTD::HandleEntityToken(CToken* aToken) { * @return PR_TRUE if all went well; PR_FALSE if error occured */ PRInt32 COtherDTD::HandleCommentToken(CToken* aToken) { - NS_PRECONDITION(0!=aToken,kNullToken); - return kNoError; + return CNavDTD::HandleCommentToken(aToken); } /** @@ -640,15 +288,7 @@ PRInt32 COtherDTD::HandleCommentToken(CToken* aToken) { * @return PR_TRUE if all went well; PR_FALSE if error occured */ PRInt32 COtherDTD::HandleSkippedContentToken(CToken* aToken) { - NS_PRECONDITION(0!=aToken,kNullToken); - - PRInt32 result=kNoError; - - if(HasOpenContainer(eHTMLTag_body)) { - nsCParserNode aNode((CHTMLToken*)aToken); - result=AddLeaf(aNode); - } - return result; + return CNavDTD::HandleSkippedContentToken(aToken); } /** @@ -662,12 +302,7 @@ PRInt32 COtherDTD::HandleSkippedContentToken(CToken* aToken) { * @return PR_TRUE if all went well; PR_FALSE if error occured */ PRInt32 COtherDTD::HandleAttributeToken(CToken* aToken) { - NS_PRECONDITION(0!=aToken,kNullToken); - NS_ERROR("attribute encountered -- this shouldn't happen!"); - - CAttributeToken* at = (CAttributeToken*)(aToken); - PRInt32 result=kNoError; - return result; + return CNavDTD::HandleAttributeToken(aToken); } /** @@ -679,13 +314,7 @@ PRInt32 COtherDTD::HandleAttributeToken(CToken* aToken) { * @return PR_TRUE if all went well; PR_FALSE if error occured */ PRInt32 COtherDTD::HandleScriptToken(CToken* aToken) { - NS_PRECONDITION(0!=aToken,kNullToken); - - nsCParserNode theNode((CHTMLToken*)aToken); - PRInt32 theCount=0; - PRInt32 result=mParser->CollectSkippedContent(theNode,theCount); - - return result; + return CNavDTD::HandleScriptToken(aToken); } /** @@ -697,98 +326,9 @@ PRInt32 COtherDTD::HandleScriptToken(CToken* aToken) { * @return PR_TRUE if all went well; PR_FALSE if error occured */ PRInt32 COtherDTD::HandleStyleToken(CToken* aToken){ - NS_PRECONDITION(0!=aToken,kNullToken); - - CStyleToken* st = (CStyleToken*)(aToken); - PRInt32 result=kNoError; - return result; + return CNavDTD::HandleStyleToken(aToken); } - -/** - * Finds a tag handler for the given tag type, given in string. - * - * @update gess 4/2/98 - * @param aString contains name of tag to be handled - * @return valid tag handler (if found) or null - */ -void COtherDTD::DeleteTokenHandlers(void) { - int i=0; - for(i=eToken_unknown;i0) && (aTypeGetTokenType(); - if(type=0;i--){ - if((eHTMLTags)(int)mContextStack[i]==aTag) - return i; - } - return kNotFound; +PRInt32 COtherDTD::DidCloseContainer(eHTMLTags aTag,PRBool anExplicitClosure){ + return CNavDTD::DidOpenContainer(aTag,anExplicitClosure); } /********************************************* @@ -1667,34 +490,7 @@ PRInt32 COtherDTD::GetTopmostIndexOf(eHTMLTags aTag) const { * @return 0 (for now) */ PRInt32 COtherDTD::OpenTransientStyles(eHTMLTags aTag){ - PRInt32 result=0; - - if(0==strchr(gWhitespaceTags,aTag)){ - PRInt32 pos=0; - for(pos=0;pos0) && (mLeafBits[mContextStackPos-1])) { - if(0==strchr(gWhitespaceTags,aTag)){ - - result=CloseContainersTo((eHTMLTags)(int)mStyleStack[0],PR_FALSE); - mLeafBits.ReplaceElementAt((void*)PR_FALSE,mContextStackPos-1); - - }//if - }//if - return result; + return CNavDTD::CloseTransientStyles(aTag); } /** @@ -1733,11 +519,7 @@ PRInt32 COtherDTD::CloseTransientStyles(eHTMLTags aTag){ * @return TRUE if ok, FALSE if error */ PRInt32 COtherDTD::OpenHTML(const nsIParserNode& aNode){ - NS_PRECONDITION(mContextStackPos >= 0, kInvalidTagStackPos); - - PRInt32 result=mSink->OpenHTML(aNode); - mContextStack.ReplaceElementAt((void*)aNode.GetNodeType(),mContextStackPos++); - return result; + return CNavDTD::OpenHTML(aNode); } /** @@ -1750,10 +532,7 @@ PRInt32 COtherDTD::OpenHTML(const nsIParserNode& aNode){ * @return TRUE if ok, FALSE if error */ PRInt32 COtherDTD::CloseHTML(const nsIParserNode& aNode){ - NS_PRECONDITION(mContextStackPos > 0, kInvalidTagStackPos); - PRInt32 result=mSink->CloseHTML(aNode); - mContextStack.ReplaceElementAt((void*)eHTMLTag_unknown,--mContextStackPos); - return result; + return CNavDTD::CloseHTML(aNode); } @@ -1766,9 +545,7 @@ PRInt32 COtherDTD::CloseHTML(const nsIParserNode& aNode){ * @return TRUE if ok, FALSE if error */ PRInt32 COtherDTD::OpenHead(const nsIParserNode& aNode){ - mContextStack.ReplaceElementAt((void*)eHTMLTag_head,++mContextStackPos); - PRInt32 result=mSink->OpenHead(aNode); - return result; + return CNavDTD::OpenHead(aNode); } /** @@ -1780,9 +557,7 @@ PRInt32 COtherDTD::OpenHead(const nsIParserNode& aNode){ * @return TRUE if ok, FALSE if error */ PRInt32 COtherDTD::CloseHead(const nsIParserNode& aNode){ - PRInt32 result=mSink->CloseHead(aNode); - mContextStack.ReplaceElementAt((void*)eHTMLTag_unknown,--mContextStackPos); - return result; + return CNavDTD::CloseHead(aNode); } /** @@ -1794,41 +569,7 @@ PRInt32 COtherDTD::CloseHead(const nsIParserNode& aNode){ * @return TRUE if ok, FALSE if error */ PRInt32 COtherDTD::OpenBody(const nsIParserNode& aNode){ - NS_PRECONDITION(mContextStackPos >= 0, kInvalidTagStackPos); - - PRInt32 result=kNoError; - eHTMLTags topTag=(eHTMLTags)COtherDTD::GetTopNode(); - - if(eHTMLTag_html!=topTag) { - - //ok, there are two cases: - // 1. Nobody opened the html container - // 2. Someone left the head (or other) open - PRInt32 pos=GetTopmostIndexOf(eHTMLTag_html); - if(kNotFound!=pos) { - //if you're here, it means html is open, - //but some other tag(s) are in the way. - //So close other tag(s). - result=CloseContainersTo(pos+1,eHTMLTag_body,PR_TRUE); - } else { - //if you're here, it means that there is - //no HTML tag in document. Let's open it. - - result=CloseContainersTo(0,eHTMLTag_html,PR_TRUE); //close current stack containers. - - CHTMLToken token(gEmpty); - nsCParserNode htmlNode(&token); - - token.SetTypeID(eHTMLTag_html); //open the html container... - result=OpenHTML(htmlNode); - } - } - - if(kNoError==result) { - result=mSink->OpenBody(aNode); - mContextStack.ReplaceElementAt((void*)aNode.GetNodeType(),mContextStackPos++); - } - return result; + return CNavDTD::OpenBody(aNode); } /** @@ -1840,10 +581,7 @@ PRInt32 COtherDTD::OpenBody(const nsIParserNode& aNode){ * @return TRUE if ok, FALSE if error */ PRInt32 COtherDTD::CloseBody(const nsIParserNode& aNode){ - NS_PRECONDITION(mContextStackPos >= 0, kInvalidTagStackPos); - PRInt32 result=mSink->CloseBody(aNode); - mContextStack.ReplaceElementAt((void*)eHTMLTag_unknown,--mContextStackPos); - return result; + return CNavDTD::CloseBody(aNode); } /** @@ -1855,12 +593,7 @@ PRInt32 COtherDTD::CloseBody(const nsIParserNode& aNode){ * @return TRUE if ok, FALSE if error */ PRInt32 COtherDTD::OpenForm(const nsIParserNode& aNode){ - if(mHasOpenForm) - CloseForm(aNode); - PRInt32 result=mSink->OpenForm(aNode); - if(kNoError==result) - mHasOpenForm=PR_TRUE; - return result; + return CNavDTD::OpenForm(aNode); } /** @@ -1872,12 +605,7 @@ PRInt32 COtherDTD::OpenForm(const nsIParserNode& aNode){ * @return TRUE if ok, FALSE if error */ PRInt32 COtherDTD::CloseForm(const nsIParserNode& aNode){ - PRInt32 result=kNoError; - if(mHasOpenForm) { - mHasOpenForm=PR_FALSE; - result=mSink->CloseForm(aNode); - } - return result; + return CNavDTD::CloseForm(aNode); } /** @@ -1889,16 +617,7 @@ PRInt32 COtherDTD::CloseForm(const nsIParserNode& aNode){ * @return TRUE if ok, FALSE if error */ PRInt32 COtherDTD::OpenMap(const nsIParserNode& aNode){ - if(mHasOpenMap) - CloseMap(aNode); - - //NOTE: We need to change to method so that it opens a MAP, - // instead of a FORM. This was copy/paste coding at its best. - - PRInt32 result=mSink->OpenForm(aNode); - if(kNoError==result) - mHasOpenMap=PR_TRUE; - return result; + return CNavDTD::OpenMap(aNode); } /** @@ -1910,16 +629,7 @@ PRInt32 COtherDTD::OpenMap(const nsIParserNode& aNode){ * @return TRUE if ok, FALSE if error */ PRInt32 COtherDTD::CloseMap(const nsIParserNode& aNode){ - PRInt32 result=kNoError; - if(mHasOpenMap) { - mHasOpenMap=PR_FALSE; - - //NOTE: We need to change to method so that it closes a MAP, - // instead of a FORM. This was copy/paste coding at its best. - - result=mSink->CloseForm(aNode); - } - return result; + return CNavDTD::CloseMap(aNode); } /** @@ -1931,10 +641,7 @@ PRInt32 COtherDTD::CloseMap(const nsIParserNode& aNode){ * @return TRUE if ok, FALSE if error */ PRInt32 COtherDTD::OpenFrameset(const nsIParserNode& aNode){ - NS_PRECONDITION(mContextStackPos >= 0, kInvalidTagStackPos); - PRInt32 result=mSink->OpenFrameset(aNode); - mContextStack.ReplaceElementAt((void*)aNode.GetNodeType(),mContextStackPos++); - return result; + return CNavDTD::OpenFrameset(aNode); } /** @@ -1946,13 +653,9 @@ PRInt32 COtherDTD::OpenFrameset(const nsIParserNode& aNode){ * @return TRUE if ok, FALSE if error */ PRInt32 COtherDTD::CloseFrameset(const nsIParserNode& aNode){ - NS_PRECONDITION(mContextStackPos > 0, kInvalidTagStackPos); - PRInt32 result=mSink->CloseFrameset(aNode); - mContextStack.ReplaceElementAt((void*)eHTMLTag_unknown,--mContextStackPos); - return result; + return CNavDTD::CloseFrameset(aNode); } - /** * This method does two things: 1st, help construct * our own internal model of the content-stack; and @@ -1962,41 +665,7 @@ PRInt32 COtherDTD::CloseFrameset(const nsIParserNode& aNode){ * @return TRUE if ok, FALSE if error */ PRInt32 COtherDTD::OpenContainer(const nsIParserNode& aNode,PRBool aUpdateStyleStack){ - NS_PRECONDITION(mContextStackPos > 0, kInvalidTagStackPos); - - PRInt32 result=kNoError; - eHTMLTags nodeType=(eHTMLTags)aNode.GetNodeType(); - -// CloseTransientStyles(nodeType); - - switch(nodeType) { - - case eHTMLTag_html: - result=OpenHTML(aNode); break; - - case eHTMLTag_body: - result=OpenBody(aNode); break; - - case eHTMLTag_style: - case eHTMLTag_textarea: - case eHTMLTag_head: - case eHTMLTag_title: - break; - - case eHTMLTag_form: - result=OpenForm(aNode); break; - - default: - result=mSink->OpenContainer(aNode); - mContextStack.ReplaceElementAt((void*)nodeType,mContextStackPos++); - break; - } - - if((kNoError==result) && (PR_TRUE==aUpdateStyleStack)){ - UpdateStyleStackForOpenTag(nodeType,nodeType); - } - - return result; + return CNavDTD::OpenContainer(aNode,aUpdateStyleStack); } /** @@ -2008,44 +677,7 @@ PRInt32 COtherDTD::OpenContainer(const nsIParserNode& aNode,PRBool aUpdateStyleS * @return TRUE if ok, FALSE if error */ PRInt32 COtherDTD::CloseContainer(const nsIParserNode& aNode,eHTMLTags aTag,PRBool aUpdateStyles){ - NS_PRECONDITION(mContextStackPos > 0, kInvalidTagStackPos); - PRInt32 result=kNoError; //was false - eHTMLTags nodeType=(eHTMLTags)aNode.GetNodeType(); - - //XXX Hack! We know this is wrong, but it works - //for the general case until we get it right. - switch(nodeType) { - - case eHTMLTag_html: - result=CloseHTML(aNode); break; - - case eHTMLTag_style: - case eHTMLTag_textarea: - break; - - case eHTMLTag_head: - //result=CloseHead(aNode); - break; - - case eHTMLTag_body: - result=CloseBody(aNode); break; - - case eHTMLTag_form: - result=CloseForm(aNode); break; - - case eHTMLTag_title: - default: - result=mSink->CloseContainer(aNode); - mContextStack.ReplaceElementAt((void*)eHTMLTag_unknown,--mContextStackPos); - break; - } - - mLeafBits.ReplaceElementAt((void*)PR_FALSE, mContextStackPos); - if((kNoError==result) && (PR_TRUE==aUpdateStyles)){ - UpdateStyleStackForCloseTag(nodeType,aTag); - } - - return result; + return CNavDTD::CloseContainer(aNode,aTag,aUpdateStyles); } /** @@ -2057,20 +689,7 @@ PRInt32 COtherDTD::CloseContainer(const nsIParserNode& aNode,eHTMLTags aTag,PRBo * @return TRUE if ok, FALSE if error */ PRInt32 COtherDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag,PRBool aUpdateStyles){ - NS_PRECONDITION(mContextStackPos > 0, kInvalidTagStackPos); - PRInt32 result=kNoError; - - CEndToken aToken(gEmpty); - nsCParserNode theNode(&aToken); - - if((anIndex=0)) { - while(mContextStackPos>anIndex) { - eHTMLTags theTag=(eHTMLTags)(int)mContextStack[mContextStackPos-1]; - aToken.SetTypeID(theTag); - result=CloseContainer(theNode,aTag,aUpdateStyles); - } - } - return result; + return CNavDTD::CloseContainersTo(anIndex,aTag,aUpdateStyles); } /** @@ -2082,36 +701,7 @@ PRInt32 COtherDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag,PRBool aUpda * @return TRUE if ok, FALSE if error */ PRInt32 COtherDTD::CloseContainersTo(eHTMLTags aTag,PRBool aUpdateStyles){ - NS_PRECONDITION(mContextStackPos > 0, kInvalidTagStackPos); - - PRInt32 pos=GetTopmostIndexOf(aTag); - - if(kNotFound!=pos) { - //the tag is indeed open, so close it. - return CloseContainersTo(pos,aTag,aUpdateStyles); - } - - eHTMLTags theTopTag=(eHTMLTags)GetTopNode(); - if(IsCompatibleOtherStyleTag(aTag,theTopTag)) { - //if you're here, it's because we're trying to close one style tag, - //but a different one is actually open. Because this is NAV4x - //compatibililty mode, we must close the one that's really open. - aTag=theTopTag; - pos=GetTopmostIndexOf(aTag); - if(kNotFound!=pos) { - //the tag is indeed open, so close it. - return CloseContainersTo(pos,aTag,aUpdateStyles); - } - } - - PRInt32 result=kNoError; - eHTMLTags theParentTag=GetDefaultParentTagFor(aTag); - pos=GetTopmostIndexOf(theParentTag); - if(kNotFound!=pos) { - //the parent container is open, so close it instead - result=CloseContainersTo(pos+1,aTag,aUpdateStyles); - } - return result; + return CNavDTD::CloseContainersTo(aTag,aUpdateStyles); } /** @@ -2123,13 +713,7 @@ PRInt32 COtherDTD::CloseContainersTo(eHTMLTags aTag,PRBool aUpdateStyles){ * @return TRUE if ok, FALSE if error */ PRInt32 COtherDTD::CloseTopmostContainer(){ - NS_PRECONDITION(mContextStackPos > 0, kInvalidTagStackPos); - - CEndToken aToken(gEmpty); - eHTMLTags theTag=(eHTMLTags)(int)mContextStack[mContextStackPos-1]; - aToken.SetTypeID(theTag); - nsCParserNode theNode(&aToken); - return CloseContainer(theNode,theTag,PR_TRUE); + return CNavDTD::CloseTopmostContainer(); } /** @@ -2141,8 +725,7 @@ PRInt32 COtherDTD::CloseTopmostContainer(){ * @return TRUE if ok, FALSE if error */ PRInt32 COtherDTD::AddLeaf(const nsIParserNode& aNode){ - PRInt32 result=mSink->AddLeaf(aNode); - return result; + return CNavDTD::AddLeaf(aNode); } /** @@ -2157,61 +740,7 @@ PRInt32 COtherDTD::AddLeaf(const nsIParserNode& aNode){ * @return true if we succeeded, otherwise false */ PRInt32 COtherDTD::CreateContextStackFor(eHTMLTags aChildTag){ - nsAutoString theVector; - - PRInt32 result=kNoError; - PRInt32 pos=0; - PRInt32 cnt=0; - eHTMLTags theTop=GetTopNode(); - - if(PR_TRUE==ForwardPropagate(theVector,theTop,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]==(void*)theVector[cnt]) - result=kNoError; - else result=kContextMismatch; - } - else { - PRBool tempResult; - if(eHTMLTag_unknown!=theTop) { - tempResult=BackwardPropagate(theVector,theTop,aChildTag); - if(eHTMLTag_html!=theTop) - BackwardPropagate(theVector,eHTMLTag_html,theTop); - } - else tempResult=BackwardPropagate(theVector,eHTMLTag_html,aChildTag); - - if(PR_TRUE==tempResult) { - - //propagation worked, so pop unwanted containers, push new ones, then exit... - pos=0; - cnt=theVector.Length(); - result=kNoError; - while(pos0) { - switch (aTag) { - - case eHTMLTag_a: - case eHTMLTag_bold: - case eHTMLTag_big: - case eHTMLTag_blink: - case eHTMLTag_cite: - case eHTMLTag_em: - case eHTMLTag_font: - case eHTMLTag_italic: - case eHTMLTag_kbd: - case eHTMLTag_small: - case eHTMLTag_spell: - case eHTMLTag_strike: - case eHTMLTag_strong: - case eHTMLTag_sub: - case eHTMLTag_sup: - case eHTMLTag_tt: - case eHTMLTag_u: - case eHTMLTag_var: - if(aTag==anActualTag) - mStyleStack.ReplaceElementAt((void*)eHTMLTag_unknown,--mStyleStackPos); - break; - - case eHTMLTag_h1: case eHTMLTag_h2: - case eHTMLTag_h3: case eHTMLTag_h4: - case eHTMLTag_h5: case eHTMLTag_h6: - break; - - default: - break; - }//switch - }//if - return result; + return CNavDTD::UpdateStyleStackForCloseTag(aTag,anActualTag); } //update... /******************************************************************* @@ -2352,43 +802,7 @@ PRInt32 COtherDTD::UpdateStyleStackForCloseTag(eHTMLTags aTag,eHTMLTags anActual * @return error code (may return kInterrupted). */ PRInt32 COtherDTD::ConsumeTag(PRUnichar aChar,CScanner& aScanner,CToken*& aToken) { - - nsAutoString empty(""); - PRInt32 result=aScanner.GetChar(aChar); - - if(kNoError==result) { - - switch(aChar) { - case kForwardSlash: - PRUnichar ch; - result=aScanner.Peek(ch); - if(kNoError==result) { - if(nsString::IsAlpha(ch)) - aToken=new CEndToken(empty); - else aToken=new CCommentToken(empty); //Special case: is treated as a comment - }//if - break; - case kExclamation: - aToken=new CCommentToken(empty); - break; - default: - if(nsString::IsAlpha(aChar)) - return ConsumeStartTag(aChar,aScanner,aToken); - else if(kEOF!=aChar) { - nsAutoString temp("<"); - return ConsumeText(temp,aScanner,aToken); - } - } //switch - - if((0!=aToken) && (kNoError==result)) { - result= aToken->Consume(aChar,aScanner); //tell new token to finish consuming text... - if(result) { - delete aToken; - aToken=0; - } - } //if - } //if - return result; + return CNavDTD::ConsumeTag(aChar,aScanner,aToken); } /** @@ -2401,33 +815,7 @@ PRInt32 COtherDTD::ConsumeTag(PRUnichar aChar,CScanner& aScanner,CToken*& aToken * @return */ PRInt32 COtherDTD::ConsumeAttributes(PRUnichar aChar,CScanner& aScanner,CStartToken* aToken) { - PRBool done=PR_FALSE; - PRInt32 result=kNoError; - nsAutoString as(""); - PRInt16 theAttrCount=0; - - while((!done) && (result==kNoError)) { - CToken* theToken= new CAttributeToken(as); - if(theToken){ - result=theToken->Consume(aChar,aScanner); //tell new token to finish consuming text... - if(kNoError==result){ - theAttrCount++; - mTokenDeque.Push(theToken); - }//if - else delete theToken; //we can't keep it... - }//if - - if(kNoError==result){ - result=aScanner.Peek(aChar); - if(aChar==kGreaterThan) { //you just ate the '>' - aScanner.GetChar(aChar); //skip the '>' - done=PR_TRUE; - }//if - }//if - }//while - - aToken->SetAttributeCount(theAttrCount); - return result; + return CNavDTD::ConsumeAttributes(aChar,aScanner,aToken); } /** @@ -2440,15 +828,7 @@ PRInt32 COtherDTD::ConsumeAttributes(PRUnichar aChar,CScanner& aScanner,CStartTo * @return new token or null */ PRInt32 COtherDTD::ConsumeContentToEndTag(const nsString& aString,PRUnichar aChar,CScanner& aScanner,CToken*& aToken){ - - //In the case that we just read the given tag, we should go and - //consume all the input until we find a matching end tag. - - nsAutoString endTag(""); - aToken=new CSkippedContentToken(endTag); - return aToken->Consume(aChar,aScanner); //tell new token to finish consuming text... + return CNavDTD::ConsumeContentToEndTag(aString,aChar,aScanner,aToken); } /** @@ -2462,62 +842,7 @@ PRInt32 COtherDTD::ConsumeContentToEndTag(const nsString& aString,PRUnichar aCha * @return new token or null */ PRInt32 COtherDTD::ConsumeStartTag(PRUnichar aChar,CScanner& aScanner,CToken*& aToken) { - PRInt32 theDequeSize=mTokenDeque.GetSize(); - PRInt32 result=kNoError; - - aToken=new CStartToken(nsAutoString("")); - - if(aToken) { - result= aToken->Consume(aChar,aScanner); //tell new token to finish consuming text... - if(kNoError==result) { - if(((CStartToken*)aToken)->IsAttributed()) { - result=ConsumeAttributes(aChar,aScanner,(CStartToken*)aToken); - } - //now that that's over with, we have one more problem to solve. - //In the case that we just read a