From 8cc14193f7976bf4f1f5d5781b858b5a519f9c81 Mon Sep 17 00:00:00 2001 From: "rickg%netscape.com" Date: Sun, 16 May 1999 05:27:23 +0000 Subject: [PATCH] final features for parsing engine (WIP); lots of bug fixes git-svn-id: svn://10.0.0.236/trunk@31835 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/htmlparser/src/CNavDTD.cpp | 956 +++++++++--------- mozilla/htmlparser/src/CNavDTD.h | 31 +- mozilla/htmlparser/src/COtherDTD.cpp | 27 - mozilla/htmlparser/src/COtherDTD.h | 20 - mozilla/htmlparser/src/nsDTDUtils.cpp | 79 +- mozilla/htmlparser/src/nsDTDUtils.h | 7 +- mozilla/htmlparser/src/nsElementTable.cpp | 825 +++++++++------ mozilla/htmlparser/src/nsElementTable.h | 61 +- mozilla/htmlparser/src/nsHTMLTokenizer.cpp | 84 +- mozilla/htmlparser/src/nsHTMLTokenizer.h | 3 +- mozilla/htmlparser/src/nsHTMLTokens.cpp | 160 ++- mozilla/htmlparser/src/nsHTMLTokens.h | 12 +- mozilla/htmlparser/src/nsIParser.h | 1 + mozilla/htmlparser/src/nsParser.cpp | 67 +- mozilla/htmlparser/src/nsParser.h | 7 +- mozilla/htmlparser/src/nsParserNode.cpp | 40 +- mozilla/htmlparser/src/nsParserNode.h | 30 +- mozilla/htmlparser/src/nsToken.cpp | 10 + mozilla/htmlparser/src/nsToken.h | 8 + mozilla/htmlparser/src/nsViewSourceHTML.cpp | 25 +- mozilla/htmlparser/src/nsWellFormedDTD.cpp | 2 - mozilla/htmlparser/src/nsXIFDTD.cpp | 6 +- mozilla/parser/htmlparser/src/CNavDTD.cpp | 956 +++++++++--------- mozilla/parser/htmlparser/src/CNavDTD.h | 31 +- mozilla/parser/htmlparser/src/COtherDTD.cpp | 27 - mozilla/parser/htmlparser/src/COtherDTD.h | 20 - mozilla/parser/htmlparser/src/nsDTDUtils.cpp | 79 +- mozilla/parser/htmlparser/src/nsDTDUtils.h | 7 +- .../parser/htmlparser/src/nsElementTable.cpp | 825 +++++++++------ .../parser/htmlparser/src/nsElementTable.h | 61 +- .../parser/htmlparser/src/nsHTMLTokenizer.cpp | 84 +- .../parser/htmlparser/src/nsHTMLTokenizer.h | 3 +- .../parser/htmlparser/src/nsHTMLTokens.cpp | 160 ++- mozilla/parser/htmlparser/src/nsHTMLTokens.h | 12 +- mozilla/parser/htmlparser/src/nsIParser.h | 1 + mozilla/parser/htmlparser/src/nsParser.cpp | 67 +- mozilla/parser/htmlparser/src/nsParser.h | 7 +- .../parser/htmlparser/src/nsParserNode.cpp | 40 +- mozilla/parser/htmlparser/src/nsParserNode.h | 30 +- mozilla/parser/htmlparser/src/nsToken.cpp | 10 + mozilla/parser/htmlparser/src/nsToken.h | 8 + .../htmlparser/src/nsViewSourceHTML.cpp | 25 +- .../parser/htmlparser/src/nsWellFormedDTD.cpp | 2 - mozilla/parser/htmlparser/src/nsXIFDTD.cpp | 6 +- 44 files changed, 2860 insertions(+), 2062 deletions(-) diff --git a/mozilla/htmlparser/src/CNavDTD.cpp b/mozilla/htmlparser/src/CNavDTD.cpp index 51423c34963..e197401d45e 100644 --- a/mozilla/htmlparser/src/CNavDTD.cpp +++ b/mozilla/htmlparser/src/CNavDTD.cpp @@ -44,6 +44,7 @@ #endif #include "prmem.h" +#undef ENABLE_RESIDUALSTYLE #define RICKG_DEBUG 0 #ifdef RICKG_DEBUG #include @@ -162,7 +163,6 @@ public: //CTagHandlerRegister gTagHandlerRegister; - /************************************************************************ And now for the main class -- CNavDTD... ************************************************************************/ @@ -257,8 +257,6 @@ PRInt32 NavDispatchTokenHandler(CToken* aToken,nsIDTD* aDTD) { result=theDTD->HandleAttributeToken(aToken); break; case eToken_style: result=theDTD->HandleStyleToken(aToken); break; - case eToken_skippedcontent: - result=theDTD->HandleSkippedContentToken(aToken); break; case eToken_instruction: result=theDTD->HandleProcessingInstructionToken(aToken); break; default: @@ -337,7 +335,7 @@ void CNavDTD::DeleteTokenHandlers(void) { * @param * @return */ -CNavDTD::CNavDTD() : nsIDTD(), mMisplacedContent(0) { +CNavDTD::CNavDTD() : nsIDTD(), mMisplacedContent(0), mSkippedContent(0) { NS_INIT_REFCNT(); mSink = 0; mParser=0; @@ -358,6 +356,11 @@ CNavDTD::CNavDTD() : nsIDTD(), mMisplacedContent(0) { mExpectedCRC32=0; mSaveBadTokens = PR_FALSE; // DebugDumpContainmentRules2(*this,"c:/temp/DTDRules.new","New CNavDTD Containment Rules"); +#ifdef RICKG_DEBUG + nsHTMLElement::DebugDumpContainment("c:/temp/rules.new","ElementTable Rules"); + nsHTMLElement::DebugDumpMembership("c:/temp/table.out"); + nsHTMLElement::DebugDumpContainType("c:/temp/ctnrules.out"); +#endif } @@ -477,7 +480,7 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,PRBool aNotifySink,nsString #endif result = mSink->WillBuildModel(); - + mSkipTarget=eHTMLTag_unknown; mComputedCRC32=0; mExpectedCRC32=0; } @@ -498,6 +501,7 @@ CTokenRecycler* gRecycler=0; nsresult CNavDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsITokenObserver* anObserver,nsIContentSink* aSink) { nsresult result=NS_OK; + NS_ADDREF(aSink); if(aTokenizer) { nsITokenizer* oldTokenizer=mTokenizer; mTokenizer=aTokenizer; @@ -514,6 +518,7 @@ nsresult CNavDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsIToke mTokenizer=oldTokenizer; } else result=NS_ERROR_HTMLPARSER_BADTOKENIZER; + NS_IF_RELEASE(aSink); return result; } @@ -581,7 +586,6 @@ nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParse return result; } - /** * This big dispatch method is used to route token handler calls to the right place. * What's wrong with it? This table, and the dispatch methods themselves need to be @@ -593,50 +597,93 @@ nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParse * @return */ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){ - nsresult result=NS_OK; + nsresult result=NS_OK; if(aToken) { CHTMLToken* theToken= (CHTMLToken*)(aToken); eHTMLTokenTypes theType=eHTMLTokenTypes(theToken->GetTokenType()); eHTMLTags theTag=(eHTMLTags)theToken->GetTypeID(); + PRBool execSkipContent=PR_FALSE; - static eHTMLTags passThru[]= {eHTMLTag_html,eHTMLTag_comment,eHTMLTag_newline,eHTMLTag_whitespace,eHTMLTag_script}; - if(!FindTagInSet(theTag,passThru,sizeof(passThru)/sizeof(eHTMLTag_unknown))){ - if(!gHTMLElements[eHTMLTag_html].SectionContains(theTag,PR_FALSE)) { - if(!mHadBodyOrFrameset){ - if(mHasOpenHead) { - //just fall through and handle current token - if(!gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag)){ - mMisplacedContent.Push(aToken); - return result; + /* --------------------------------------------------------------------------------- + To understand this little piece of code, you need to look below too. + In essence, this code caches "skipped content" until we find a given skiptarget. + Once we find the skiptarget, we take all skipped content up to that point and + coallate it. Then we push those tokens back onto the tokenizer deque. + --------------------------------------------------------------------------------- + */ + if(mSkipTarget){ //handle a preexisting target... + if((theTag==mSkipTarget) && (eToken_end==theType)){ + mSkipTarget=eHTMLTag_unknown; //stop skipping. + //mTokenizer->PushTokenFront(aToken); //push the end token... + execSkipContent=PR_TRUE; + gRecycler->RecycleToken(aToken); + theToken=(CHTMLToken*)mSkippedContent.PopFront(); + // result=HandleStartToken(theToken); + } + else { + mSkippedContent.Push(theToken); + return result; + } + } + + /* --------------------------------------------------------------------------------- + This section of code is used to "move" misplaced content from one location in + our document model to another. (Consider what would happen if we found a

tag + and text in the head.) To move content, we throw it onto the misplacedcontent + deque until we can deal with it. + --------------------------------------------------------------------------------- + */ + if(!execSkipContent) { + static eHTMLTags passThru[]= {eHTMLTag_html,eHTMLTag_comment,eHTMLTag_newline,eHTMLTag_whitespace,eHTMLTag_script}; + if(!FindTagInSet(theTag,passThru,sizeof(passThru)/sizeof(eHTMLTag_unknown))){ + if(!gHTMLElements[eHTMLTag_html].SectionContains(theTag,PR_FALSE)) { + if(!mHadBodyOrFrameset){ + if(mHasOpenHead) { + //just fall through and handle current token + if(!gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag)){ + mMisplacedContent.Push(aToken); + return result; + } } - } - else { - if(gHTMLElements[eHTMLTag_body].SectionContains(theTag,PR_TRUE)){ - mTokenizer->PushTokenFront(aToken); //put this token back... - mTokenizer->PrependTokens(mMisplacedContent); //push misplaced content - theToken=(CHTMLToken*)gRecycler->CreateTokenOfType(eToken_start,eHTMLTag_body); - //now open a body... + else { + if(gHTMLElements[eHTMLTag_body].SectionContains(theTag,PR_TRUE)){ + mTokenizer->PushTokenFront(aToken); //put this token back... + mTokenizer->PrependTokens(mMisplacedContent); //push misplaced content + theToken=(CHTMLToken*)gRecycler->CreateTokenOfType(eToken_start,eHTMLTag_body); + //now open a body... + } } - } - } + } + } } } if(theToken){ - CITokenHandler* theHandler=GetTokenHandler(theType); - if(theHandler) { - mParser=(nsParser*)aParser; - result=(*theHandler)(theToken,this); - if(NS_SUCCEEDED(result) || (NS_ERROR_HTMLPARSER_BLOCK==result)) { - gRecycler->RecycleToken(theToken); - } - else if(NS_ERROR_HTMLPARSER_MISPLACED!=result) - mTokenizer->PushTokenFront(theToken); - else result=NS_OK; - if (mDTDDebug) { - //mDTDDebug->Verify(this, mParser, mBodyContext->GetCount(), mBodyContext->mStack, mFilename); - } + //Before dealing with the token normally, we need to deal with skip targets + if((!execSkipContent) && + (theType!=eToken_end) && + (eHTMLTag_unknown==mSkipTarget) && + (gHTMLElements[theTag].mSkipTarget)){ //create a new target + mSkipTarget=gHTMLElements[theTag].mSkipTarget; + mSkippedContent.Push(theToken); + } + else { + + CITokenHandler* theHandler=GetTokenHandler(theType); + if(theHandler) { + mParser=(nsParser*)aParser; + result=(*theHandler)(theToken,this); + if(NS_SUCCEEDED(result) || (NS_ERROR_HTMLPARSER_BLOCK==result)) { + gRecycler->RecycleToken(theToken); + } + else if(NS_ERROR_HTMLPARSER_MISPLACED!=result) + mTokenizer->PushTokenFront(theToken); + else result=NS_OK; + if (mDTDDebug) { + //mDTDDebug->Verify(this, mParser, mBodyContext->GetCount(), mBodyContext->mStack, mFilename); + } + } //if } } @@ -678,51 +725,38 @@ nsresult CNavDTD::ReleaseTokenPump(nsITagHandler* aHandler){ nsresult CNavDTD::DidHandleStartTag(nsCParserNode& aNode,eHTMLTags aChildTag){ nsresult result=NS_OK; - CToken* theNextToken=mTokenizer->PeekToken(); - if(theNextToken){ - switch(aChildTag){ - case eHTMLTag_body: - case eHTMLTag_frameset: - mHadBodyOrFrameset=PR_TRUE; - break; + switch(aChildTag){ + case eHTMLTag_body: + case eHTMLTag_frameset: + mHadBodyOrFrameset=PR_TRUE; + break; - - case eHTMLTag_pre: - case eHTMLTag_listing: - { - if(theNextToken) { - eHTMLTokenTypes theType=eHTMLTokenTypes(theNextToken->GetTokenType()); - if(eToken_newline==theType){ - - switch(aChildTag){ - case eHTMLTag_pre: - case eHTMLTag_listing: - //we skip the first newline token inside PRE and LISTING - mTokenizer->PopToken(); - break; - default: - break; - }//switch - - }//if + case eHTMLTag_pre: + case eHTMLTag_listing: + { + CToken* theNextToken=mTokenizer->PeekToken(); + if(theNextToken) { + eHTMLTokenTypes theType=eHTMLTokenTypes(theNextToken->GetTokenType()); + if(eToken_newline==theType){ + mTokenizer->PopToken(); //skip 1st newline inside PRE and LISTING }//if - } - break; + }//if + } + break; - case eHTMLTag_plaintext: - case eHTMLTag_xmp: - //grab the skipped content and dump it out as text... - { - const nsString& theText=aNode.GetSkippedContent(); - if(0=0;i--){ if(aTagStack[i]==aTag) return i; @@ -745,6 +779,41 @@ PRInt32 GetTopmostIndexOf(eHTMLTags aTag,nsEntryStack& aTagStack) { return kNotFound; } +/** + * This method is called to determine whether or not a START tag + * can be autoclosed. This means that based on the current + * context, the stack should be closed to the nearest matching + * tag. + * + * @param aTag -- tag enum of child to be tested + * @return index of tag to be closed + */ +static PRInt32 FindAutoCloseTargetForStartTag2(eHTMLTags aChild,nsEntryStack& aTagStack,CNavDTD& aDTD) { + PRInt32 max=aTagStack.GetCount(); + + if(nsHTMLElement::IsContainer(aChild)){ + PRInt32 index=max; + CTagList* theRootTags=gHTMLElements[aChild].GetRootTags(); + + while(--index>=0){ + eHTMLTags thePrevTag=aTagStack.TagAt(index); + + if((theRootTags) && (theRootTags->Contains(thePrevTag))) { + return index+1; + } + + if(aDTD.CanOmit(thePrevTag,aChild)){ + return index+1; + } + + if(aDTD.CanContain(thePrevTag,aChild)){ + return index+1; + } + } + } + return max; //which means don't close anything... +} + /** * This method is called to determine whether or not a START tag @@ -757,19 +826,17 @@ PRInt32 GetTopmostIndexOf(eHTMLTags aTag,nsEntryStack& aTagStack) { */ static eHTMLTags FindAutoCloseTargetForStartTag(eHTMLTags aCurrentTag,nsEntryStack& aTagStack) { - int theTopIndex = aTagStack.GetSize(); + int theTopIndex = aTagStack.GetCount(); eHTMLTags thePrevTag=aTagStack.Last(); if(nsHTMLElement::IsContainer(aCurrentTag)){ if(thePrevTag==aCurrentTag) { return (gHTMLElements[aCurrentTag].CanContainSelf()) ? eHTMLTag_unknown: aCurrentTag; } - if(nsHTMLElement::IsBlockCloser(aCurrentTag)) { - - PRInt32 theRootIndex=kNotFound; - CTagList* theRootTags=gHTMLElements[aCurrentTag].GetRootTags(); + CTagList* theRootTags=gHTMLElements[aCurrentTag].GetRootTags(); + PRInt32 theRootIndex=(theRootTags) ? theRootTags->GetTopmostIndexOf(aTagStack) : kNotFound; + if(nsHTMLElement::IsBlockCloser(aCurrentTag)) { if(theRootTags) { - theRootIndex=theRootTags->GetTopmostIndexOf(aTagStack); CTagList* theStartTags=gHTMLElements[aCurrentTag].GetAutoCloseStartTags(); PRInt32 thePeerIndex=kNotFound; if(theStartTags){ @@ -798,15 +865,14 @@ eHTMLTags FindAutoCloseTargetForStartTag(eHTMLTags aCurrentTag,nsEntryStack& aTa } //if } //if }//if - else if(kNotFound

<- - while((theRootIndex<--theTopIndex) && (!gHTMLElements[aTagStack[theTopIndex]].CanContain(aCurrentTag))) { - } - return aTagStack[theTopIndex+1]; - //return aTagStack.mTags[theRootIndex+1]; + } //if isblockcloser + if(kNotFound

<-

+ while((theRootIndex<--theTopIndex) && (!gHTMLElements[aTagStack[theTopIndex]].CanContain(aCurrentTag))) { } - - } //if + return aTagStack[theTopIndex+1]; + //return aTagStack.mTags[theRootIndex+1]; + } //else } //if return eHTMLTag_unknown; } @@ -856,25 +922,30 @@ PRBool CanBeContained(eHTMLTags aParentTag,eHTMLTags aChildTag,nsEntryStack& aTa //Note: This method is going away. First we need to get the elementtable to do closures right, and // therefore we must get residual style handling to work. +/* // I've removed this on general principle. + // If style tags want to contain each other, the state should be in the element table. + if(nsHTMLElement::IsStyleTag(aParentTag)) if(nsHTMLElement::IsStyleTag(aChildTag)) return PR_TRUE; +*/ - CTagList* theRootTags=gHTMLElements[aChildTag].GetRootTags(); - if(theRootTags) { - PRInt32 theRootIndex=theRootTags->GetTopmostIndexOf(aTagStack); - PRInt32 theChildIndex=GetIndexOfChildOrSynonym(aTagStack,aChildTag); - PRInt32 theBaseIndex=(theRootIndexGetTopmostIndexOf(aTagStack); + PRInt32 theChildIndex=GetIndexOfChildOrSynonym(aTagStack,aChildTag); - if((theRootIndex==theChildIndex) && (gHTMLElements[aChildTag].CanContainSelf())) - result=PR_TRUE; - else result=PRBool(theRootIndex>theChildIndex); + if((theRootIndex==theChildIndex) && (gHTMLElements[aChildTag].CanContainSelf())) + result=PR_TRUE; + else result=PRBool(theRootIndex>theChildIndex); + } } + return result; } - /** * This method gets called when a start token has been * encountered in the parse process. If the current container @@ -892,6 +963,77 @@ PRBool CanBeContained(eHTMLTags aParentTag,eHTMLTags aChildTag,nsEntryStack& aTa nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsIParserNode& aNode) { NS_PRECONDITION(0!=aToken,kNullToken); + nsresult result=NS_OK; + + PRBool theCanContainResult=PR_FALSE; + PRBool theChildAgrees=PR_TRUE; + + do { + + eHTMLTags theParentTag=mBodyContext->Last(); + if(CanOmit(theParentTag,aChildTag)){ + //call handleOmittedTag()... + return result; + } + + theCanContainResult=CanContain(theParentTag,aChildTag); + theChildAgrees=PR_TRUE; + if(theCanContainResult) { + + eHTMLTags theAncestor=gHTMLElements[aChildTag].mExcludingAncestor; + if(eHTMLTag_unknown!=theAncestor){ + theChildAgrees=!HasOpenContainer(theAncestor); + } + + if(theChildAgrees){ + theAncestor=gHTMLElements[aChildTag].mRequiredAncestor; + if(eHTMLTag_unknown!=theAncestor){ + theChildAgrees=HasOpenContainer(theAncestor); + } + } + } + + if(!(theCanContainResult && theChildAgrees)) { + if (!CanPropagate(theParentTag,aChildTag)) { + if(nsHTMLElement::IsContainer(aChildTag)){ + CloseTopmostContainer(); //drastic measures, to be sure! + }//if + else break; + }//if + else CreateContextStackFor(aChildTag); + }//if + } while(!(theCanContainResult && theChildAgrees)); + + + if(nsHTMLElement::IsContainer(aChildTag)){ + result=OpenContainer(aNode,PR_TRUE); + } + else { //we're writing a leaf... + result=AddLeaf(aNode); + } + + return result; +} + +#if 0 +/** + * This method gets called when a start token has been + * encountered in the parse process. If the current container + * can contain this tag, then add it. Otherwise, you have + * two choices: 1) create an implicit container for this tag + * to be stored in + * 2) close the top container, and add this to + * whatever container ends up on top. + * + * @update gess 3/25/98 + * @param aToken -- next (start) token to be handled + * @param aNode -- CParserNode representing this start token + * @return PR_TRUE if all went well; PR_FALSE if error occured + */ + +nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsIParserNode& aNode) { + NS_PRECONDITION(0!=aToken,kNullToken); + nsresult result=NS_OK; //Sick as it sounds, I have to make sure the body has been @@ -899,21 +1041,8 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI PRBool rickgSkip=PR_FALSE; if(!rickgSkip) { -/* - TRYING TO MAKE THIS CODE GO AWAY!... - static eHTMLTags gBodyBlockers[]={eHTMLTag_body,eHTMLTag_frameset,eHTMLTag_map}; - PRInt32 theBodyBlocker=GetTopmostIndexOf(gBodyBlockers,sizeof(gBodyBlockers)/sizeof(eHTMLTag_unknown)); - if((kNotFound==theBodyBlocker) && (!mHasOpenHead)){ - if(CanPropagate(eHTMLTag_body,aChildTag)) { - mHasOpenBody=PR_TRUE; - result=CreateContextStackFor(aChildTag); - //CStartToken theToken(eHTMLTag_body); //open the body container... - //result=HandleStartToken(&theToken); - } - }//if -*/ - /*********************************************************************** + /*********************************************************************** Subtlety alert: The REAL story on when tags are opened is somewhat confusing, but it's @@ -948,7 +1077,12 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI PRBool theChildAgrees=(theCanContainResult) ? CanBeContained(theParentTag,aChildTag,mBodyContext->mStack) : PR_FALSE; if(!(theCanContainResult && theChildAgrees)) { + PRInt32 theIndex=FindAutoCloseTargetForStartTag2(aChildTag,mBodyContext->mStack,*this); + eHTMLTags theTarg2=mBodyContext->TagAt(theIndex); eHTMLTags theTarget=FindAutoCloseTargetForStartTag(aChildTag,mBodyContext->mStack); + + NS_ASSERTION(theTarg2==theTarget,"Error: target mismatch"); + if(eHTMLTag_unknown!=theTarget){ result=CloseContainersTo(theTarget,PR_TRUE); theParentTag=mBodyContext->Last(); @@ -986,13 +1120,12 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI result=OpenContainer(aNode,PR_TRUE); } else { //we're writing a leaf... - OpenTransientStyles(aChildTag); result=AddLeaf(aNode); } return result; } - +#endif #ifdef RICKG_DEBUG void WriteTokenToLog(CToken* aToken) { @@ -1034,15 +1167,15 @@ public: eHTMLTags mTag; }; -/** - * This gets called before we've handled a given start tag. - * It's a generic hook to let us do pre processing. - * @param aToken contains the tag in question - * @param aChildTag is the tag itself. - * @param aNode is the node (tag) with associated attributes. - * @return TRUE if tag processing should continue; FALSE if the tag has been handled. - */ -nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsCParserNode& aNode){ +/** + * This gets called before we've handled a given start tag. + * It's a generic hook to let us do pre processing. + * @param aToken contains the tag in question + * @param aChildTag is the tag itself. + * @param aNode is the node (tag) with associated attributes. + * @return TRUE if tag processing should continue; FALSE if the tag has been handled. + */ +nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsCParserNode& aNode){ nsresult result=NS_OK; PRInt32 theAttrCount = aNode.GetAttributeCount(); @@ -1082,78 +1215,80 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsCParserNode } } - //********************************************************** - //XXX Hack until I get the node observer API in place... - if(eHTMLTag_meta==aTag) { - PRInt32 theCount=aNode.GetAttributeCount(); - if(1 - const nsString& theKey=aNode.GetKeyAt(0); - if(theKey.EqualsIgnoreCase("HTTP-EQUIV")) { - const nsString& theKey2=aNode.GetKeyAt(1); - if(theKey2.EqualsIgnoreCase("CONTENT")) { - nsScanner* theScanner=mParser->GetScanner(); - if(theScanner) { - const nsString& theValue=aNode.GetValueAt(1); - PRInt32 charsetValueStart = theValue.RFind("charset=", PR_TRUE ) ; - if(kNotFound != charsetValueStart) { + //********************************************************** + //XXX Hack until I get the node observer API in place... + + if(eHTMLTag_meta==aTag) { + PRInt32 theCount=aNode.GetAttributeCount(); + if(1 + const nsString& theKey=aNode.GetKeyAt(0); + if(theKey.EqualsIgnoreCase("HTTP-EQUIV")) { + const nsString& theKey2=aNode.GetKeyAt(1); + if(theKey2.EqualsIgnoreCase("CONTENT")) { + nsScanner* theScanner=mParser->GetScanner(); + if(theScanner) { + const nsString& theValue=aNode.GetValueAt(1); + PRInt32 charsetValueStart = theValue.RFind("charset=", PR_TRUE ) ; + if(kNotFound != charsetValueStart) { charsetValueStart += 8; // 8 = "charset=".length - PRInt32 charsetValueEnd = theValue.FindCharInSet("\'\";", charsetValueStart ); + PRInt32 charsetValueEnd = theValue.FindCharInSet("\'\";", charsetValueStart ); if(kNotFound == charsetValueEnd ) - charsetValueEnd = theValue.Length(); - nsAutoString theCharset; - theValue.Mid(theCharset, charsetValueStart, charsetValueEnd - charsetValueStart); - theScanner->SetDocumentCharset(theCharset, kCharsetFromMetaTag); - // XXX this should be delete after META charset really work - nsParser::gHackMetaCharset = theCharset; - } //if - } //if - } - } //if + charsetValueEnd = theValue.Length(); + nsAutoString theCharset; + theValue.Mid(theCharset, charsetValueStart, charsetValueEnd - charsetValueStart); + theScanner->SetDocumentCharset(theCharset, kCharsetFromMetaTag); + // XXX this should be delete after META charset really work + nsParser::gHackMetaCharset = theCharset; + } //if + } //if + } + } //if - else if(theKey.EqualsIgnoreCase("NAME")) { - const nsString& theValue1=aNode.GetValueAt(0); - if(theValue1.EqualsIgnoreCase("\"CRC\"")) { - const nsString& theKey2=aNode.GetKeyAt(1); - if(theKey2.EqualsIgnoreCase("CONTENT")) { - const nsString& theValue2=aNode.GetValueAt(1); - PRInt32 err=0; - mExpectedCRC32=theValue2.ToInteger(&err); - } //if - } //if - } //else + else if(theKey.EqualsIgnoreCase("NAME")) { + const nsString& theValue1=aNode.GetValueAt(0); + if(theValue1.EqualsIgnoreCase("\"CRC\"")) { + const nsString& theKey2=aNode.GetKeyAt(1); + if(theKey2.EqualsIgnoreCase("CONTENT")) { + const nsString& theValue2=aNode.GetValueAt(1); + PRInt32 err=0; + mExpectedCRC32=theValue2.ToInteger(&err); + } //if + } //if + } //else - } //if - }//if + } //if + }//if - //XXX Hack until I get the node observer API in place... - //********************************************************** + //XXX Hack until I get the node observer API in place... + //********************************************************** - if(NS_OK==result) { - result=gHTMLElements[aTag].HasSpecialProperty(kDiscardTag) ? 1 : NS_OK; - } + if(NS_OK==result) { + result=gHTMLElements[aTag].HasSpecialProperty(kDiscardTag) ? 1 : NS_OK; + } - PRBool isHeadChild=gHTMLElements[eHTMLTag_head].IsChildOfHead(aTag); + + PRBool isHeadChild=gHTMLElements[eHTMLTag_head].IsChildOfHead(aTag); //this code is here to make sure the head is closed before we deal - //with any tags that don't belong in the head. - if(NS_OK==result) { - if(mHasOpenHead){ - static eHTMLTags skip2[]={eHTMLTag_newline,eHTMLTag_whitespace}; - if(!FindTagInSet(aTag,skip2,sizeof(skip2)/sizeof(eHTMLTag_unknown))){ - if(!isHeadChild){ - CEndToken theToken(eHTMLTag_head); - nsCParserNode theNode(&theToken,mLineNumber); - result=CloseHead(theNode); - } - } - } - } + //with any tags that don't belong in the head. + if(NS_OK==result) { + if(mHasOpenHead){ + static eHTMLTags skip2[]={eHTMLTag_newline,eHTMLTag_whitespace}; + if(!FindTagInSet(aTag,skip2,sizeof(skip2)/sizeof(eHTMLTag_unknown))){ + if(!isHeadChild){ + CEndToken theToken(eHTMLTag_head); + nsCParserNode theNode(&theToken,mLineNumber); + result=CloseHead(theNode); + } + } + } + } - return result; -} + return result; +} /** * This method gets called when a start token has been encountered that the parent @@ -1240,7 +1375,7 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) { eHTMLTags theChildTag=(eHTMLTags)aToken->GetTypeID(); nsCParserNode attrNode((CHTMLToken*)aToken,mLineNumber,GetTokenRecycler()); PRInt16 attrCount=aToken->GetAttributeCount(); - nsresult result=(0==attrCount) ? NS_OK : CollectAttributes(attrNode,attrCount); + nsresult result=(0==attrCount) ? NS_OK : CollectAttributes(attrNode,theChildTag,attrCount); eHTMLTags theParent=mBodyContext->Last(); if(NS_OK==result) { @@ -1248,8 +1383,12 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) { if(nsHTMLElement::IsSectionTag(theChildTag)){ switch(theChildTag){ - case eHTMLTag_head: case eHTMLTag_body: + if(HasOpenContainer(theChildTag)){ + return NS_OK; //OpenContainer(attrNode,PR_FALSE); + } + break; + case eHTMLTag_head: if(mHadBodyOrFrameset) { result=HandleOmittedTag(aToken,theChildTag,theParent,attrNode); if(result == NS_OK) @@ -1318,9 +1457,13 @@ PRBool HasCloseablePeerAboveRoot(CTagList& aRootTagList,nsEntryStack& aTagStack, theChildIndex=theCloseTags->GetTopmostIndexOf(aTagStack); } else { - theChildIndex=aTagStack.GetTopmostIndexOf(aTag); + if((anEndTag) || (!gHTMLElements[aTag].CanContainSelf())) + theChildIndex=aTagStack.GetTopmostIndexOf(aTag); } - return PRBool(theRootIndex... + // + return PRBool(theRootIndex<=theChildIndex); } @@ -1335,7 +1478,7 @@ PRBool HasCloseablePeerAboveRoot(CTagList& aRootTagList,nsEntryStack& aTagStack, */ static eHTMLTags FindAutoCloseTargetForEndTag(eHTMLTags aCurrentTag,nsEntryStack& aTagStack) { - int theTopIndex=aTagStack.GetSize(); + int theTopIndex=aTagStack.GetCount(); eHTMLTags thePrevTag=aTagStack.Last(); if(nsHTMLElement::IsContainer(aCurrentTag)){ @@ -1385,7 +1528,12 @@ eHTMLTags FindAutoCloseTargetForEndTag(eHTMLTags aCurrentTag,nsEntryStack& aTagS return aCurrentTag; else return eHTMLTag_unknown; } - } //if + } //if blockcloser + else{ + //Ok, a much more sensible approach for non-block closers; use the tag group to determine closure: + //For example: %phrasal closes %phrasal, %fontstyle and %special + return gHTMLElements[aCurrentTag].GetCloseTargetForEndTag(aTagStack,theChildIndex); + } }//if } //if return eHTMLTag_unknown; @@ -1438,12 +1586,12 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) { result=HandleStartToken(theToken); } break; - + default: { //now check to see if this token should be omitted, or //if it's gated from closing by the presence of another tag. - if(PR_TRUE==CanOmitEndTag(mBodyContext->Last(),theChildTag)) { + if((gHTMLElements[theChildTag].CanOmitEndTag()) || (kNotFound==GetIndexOfChildOrSynonym(mBodyContext->mStack,theChildTag))) { UpdateStyleStackForCloseTag(theChildTag,theChildTag); } else { @@ -1452,7 +1600,7 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) { result = HandleSavedTokensAbove(theTarget); } if(eHTMLTag_unknown!=theTarget) { - result=CloseContainersTo(theTarget,PR_TRUE); + result=CloseContainersTo(theTarget,PR_FALSE); } } } @@ -1476,14 +1624,13 @@ nsresult CNavDTD::HandleSavedTokensAbove(eHTMLTags aTag) { NS_PRECONDITION(mBodyContext != nsnull && mBodyContext->GetCount() > 0,"invalid context"); - CToken* theToken; - eHTMLTags theTag; - PRInt32 attrCount; - nsresult result = NS_OK; - PRInt32 theTopIndex = GetTopmostIndexOf(aTag); - PRInt32 theTagCount = mBodyContext->GetCount(); + CToken* theToken; + eHTMLTags theTag; + PRInt32 attrCount; + nsresult result = NS_OK; + PRInt32 theTopIndex = GetTopmostIndexOf(aTag); + PRInt32 theTagCount = mBodyContext->GetCount(); - if(theTopIndex == kNotFound) return result; @@ -1491,10 +1638,11 @@ nsresult CNavDTD::HandleSavedTokensAbove(eHTMLTags aTag) PRInt32 theBadTokenCount = mBodyContext->TokenCountAt(theBadContentIndex); if(theBadTokenCount > 0) { - nsDTDContext temp; // Pause the main context and switch to the new context. mSink->BeginContext(theBadContentIndex); - + + nsDTDContext temp; + // The body context should contain contents only upto the marked position. for(PRInt32 i=0; i<(theTagCount - theTopIndex); i++) temp.Push(mBodyContext->Pop()); @@ -1520,8 +1668,7 @@ nsresult CNavDTD::HandleSavedTokensAbove(eHTMLTags aTag) theBadTokenCount--; } if(theTopIndex != mBodyContext->GetCount()) { - eHTMLTags theTarget = mBodyContext->TagAt(theTopIndex); - CloseContainersTo(theTopIndex,theTarget,PR_TRUE); + CloseContainersTo(theTopIndex,mBodyContext->TagAt(theTopIndex),PR_TRUE); } // Bad-contents were successfully processed. Now, itz time to get @@ -1599,27 +1746,6 @@ nsresult CNavDTD::HandleCommentToken(CToken* aToken) { return result; } -/** - * This method gets called when a skippedcontent token has - * been encountered in the parse process. After verifying - * that the topmost container can contain text, we call - * AddLeaf to store this token in the top container. - * - * @update gess 3/25/98 - * @param aToken -- next (start) token to be handled - * @return PR_TRUE if all went well; PR_FALSE if error occured - */ -nsresult CNavDTD::HandleSkippedContentToken(CToken* aToken) { - NS_PRECONDITION(0!=aToken,kNullToken); - - nsresult result=NS_OK; - - if(HasOpenContainer(eHTMLTag_body)) { - nsCParserNode aNode((CHTMLToken*)aToken,mLineNumber); - result=AddLeaf(aNode); - } - return result; -} /** * This method gets called when an attribute token has been @@ -1700,13 +1826,18 @@ nsresult CNavDTD::HandleProcessingInstructionToken(CToken* aToken){ * @param aCount is the # of attributes you're expecting * @return error code (should be 0) */ -nsresult CNavDTD::CollectAttributes(nsCParserNode& aNode,PRInt32 aCount){ +nsresult CNavDTD::CollectAttributes(nsCParserNode& aNode,eHTMLTags aTag,PRInt32 aCount){ int attr=0; nsresult result=NS_OK; - if(aCount<=mTokenizer->GetCount()) { + int theAvailTokenCount=mTokenizer->GetCount() + mSkippedContent.GetSize(); + if(aCount<=theAvailTokenCount) { + CToken* theToken=0; + eHTMLTags theSkipTarget=gHTMLElements[aTag].mSkipTarget; for(attr=0;attrPopToken(); + if((eHTMLTag_unknown!=theSkipTarget) && mSkippedContent.GetSize()) + theToken=(CToken*)mSkippedContent.PopFront(); + else theToken=mTokenizer->PopToken(); if(theToken) { #ifdef RICKG_DEBUG @@ -1733,27 +1864,21 @@ nsresult CNavDTD::CollectAttributes(nsCParserNode& aNode,PRInt32 aCount){ * @return Error condition. */ nsresult CNavDTD::CollectSkippedContent(nsCParserNode& aNode,PRInt32& aCount) { - nsresult result=NS_OK; - eHTMLTokenTypes theType=eToken_unknown; - aCount=0; - CToken* theToken=mTokenizer->PopToken(); - if(theToken) { - theType=eHTMLTokenTypes(theToken->GetTokenType()); - if(eToken_skippedcontent==theType) { + CTokenRecycler* theRecycler=(CTokenRecycler*)mTokenizer->GetTokenRecycler(); - #ifdef RICKG_DEBUG - WriteTokenToLog(theToken); - #endif - - aNode.SetSkippedContent(theToken); - aCount++; - } + int aIndex=0; + int aMax=mSkippedContent.GetSize(); + nsAutoString theTempStr; + nsAutoString theStr; + for(aIndex=0;aIndexGetSource(theTempStr); + theStr+=theTempStr; + theRecycler->RecycleToken(theNextToken); } - else { - result=kEOF; - } - return result; + aNode.SetSkippedContent(theStr); + return NS_OK; } @@ -1782,64 +1907,8 @@ CITokenHandler* CNavDTD::GetTokenHandler(eHTMLTokenTypes aType) const { * @return */ void CNavDTD::EmitMisplacedContent(nsITokenizer* aTokenizer){ -/* - if(aTokenizer){ - if(!mHadBodyOrFrameset){ - int index=0; - int max=mMisplacedContent.GetSize(); - PRBool isBodyContent=PR_TRUE; - for(index=0;indexGetTypeID(); - if(gHTMLElements[theTag].IsWhitespaceTag(theTag)){ - //ignore it... - } - if(gHTMLElements[eHTMLTag_body].SectionContains(theTag,PR_TRUE)){ - break; //stop, since you now know for sure to open the body... - } - else { - static eHTMLTags frameTags[]={eHTMLTag_frame,eHTMLTag_noframes,eHTMLTag_frameset}; - if(FindTagInSet(theTag,frameTags,sizeof(frameTags)/sizeof(eHTMLTag_unknown))) { - isBodyContent=PR_FALSE; - break; - } - } - } - } //for - if(isBodyContent){ - CTokenRecycler* theRecycler=(CTokenRecycler*)aTokenizer->GetTokenRecycler(); - CToken* theBodyToken=theRecycler->CreateTokenOfType(eToken_start,eHTMLTag_body); - mMisplacedContent.PushFront(theBodyToken); - //mMisplacedContent.PushFront(theBodyToken); - } - } - } -*/ - aTokenizer->PrependTokens(mMisplacedContent); } -/** - * This method is called to determine whether or not a tag - * can contain an explict style tag (font, italic, bold, etc.) - * Most can -- but some, like option, cannot. Therefore we - * don't bother to open transient styles within these elements. - * - * @update gess 4/8/98 - * @param aParent -- tag enum of parent container - * @param aChild -- tag enum of child container - * @return PR_TRUE if parent can contain child - */ -PRBool CNavDTD::CanContainStyles(eHTMLTags aParent) const { - PRBool result=PR_TRUE; - switch(aParent) { - case eHTMLTag_option: - result=PR_FALSE; break; - default: - break; - } - return result; -} /*********************************************************************************** The preceeding tables determine the set of elements each tag can contain... @@ -1879,22 +1948,29 @@ PRBool CNavDTD::CanPropagate(eHTMLTags aParentTag,eHTMLTags aChildTag) const { PRBool result=PR_FALSE; PRBool parentCanContain=CanContain(aParentTag,aChildTag); - if(nsHTMLElement::IsContainer(aChildTag)){ - if(nsHTMLElement::IsBlockParent(aParentTag) || (gHTMLElements[aParentTag].GetSpecialChildren())) { - while(eHTMLTag_unknown!=aChildTag) { - if(parentCanContain){ - result=PR_TRUE; - break; - }//if - CTagList* theTagList=gHTMLElements[aChildTag].GetRootTags(); - aChildTag=theTagList->mTags[0]; - parentCanContain=CanContain(aParentTag,aChildTag); - }//while - }//if - }//if - else if(nsHTMLElement::IsTextTag(aChildTag)){ - result=PR_TRUE; + if(aParentTag==aChildTag) { + return result; } + + int thePropLevel=0; + if(nsHTMLElement::IsContainer(aChildTag)){ + if(!gHTMLElements[aChildTag].HasSpecialProperty(kNoPropagate)){ + if(nsHTMLElement::IsBlockParent(aParentTag) || (gHTMLElements[aParentTag].GetSpecialChildren())) { + while(eHTMLTag_unknown!=aChildTag) { + if(parentCanContain){ + result=PR_TRUE; + break; + }//if + CTagList* theTagList=gHTMLElements[aChildTag].GetRootTags(); + aChildTag=theTagList->GetTagAt(0); + parentCanContain=CanContain(aParentTag,aChildTag); + ++thePropLevel; + }//while + }//if + }//if + if(thePropLevel>gHTMLElements[aParentTag].mPropagateRange) + result=PR_FALSE; + }//if else result=parentCanContain; return result; } @@ -1921,18 +1997,22 @@ PRBool CNavDTD::CanOmit(eHTMLTags aParent,eHTMLTags aChild) const { } if(gHTMLElements[aParent].HasSpecialProperty(kOmitWS)) { - if(nsHTMLElement::IsTextTag(aChild)) { + if(nsHTMLElement::IsWhitespaceTag(aChild)) { return PR_TRUE; } } + if(gHTMLElements[aParent].CanExclude(aChild)){ + return PR_TRUE; + } + //Now the obvious test: if the parent can contain the child, don't omit. - if(gHTMLElements[aParent].CanContain(aChild)){ + if((gHTMLElements[aParent].CanContain(aChild)) || (aChild==aParent)){ return PR_FALSE; } - if(nsHTMLElement::IsBlockElement(aParent)) { - if(nsHTMLElement::IsInlineElement(aChild)) { //feel free to drop inlines that a block doesn't contain. + if(nsHTMLElement::IsBlockEntity(aParent)) { + if(nsHTMLElement::IsInlineEntity(aChild)) { //feel free to drop inlines that a block doesn't contain. return PR_TRUE; } } @@ -1946,27 +2026,6 @@ PRBool CNavDTD::CanOmit(eHTMLTags aParent,eHTMLTags aChild) const { } -/** - * This method gets called to determine whether a given - * ENDtag can be omitted. Admittedly,this is a gross simplification. - * - * @update gess 3/25/98 - * @param aTag -- tag to test for containership - * @return PR_TRUE if given tag can contain other tags - */ -PRBool CNavDTD::CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild) const { - PRBool result=PR_FALSE; - - if(gHTMLElements[aChild].CanOmitEndTag(aParent)) { - return PR_TRUE; - } - - PRInt32 theChildIndex=GetIndexOfChildOrSynonym(mBodyContext->mStack,aChild); - result=PRBool(kNotFound==theChildIndex); - - return result; -} - /** * This method gets called to determine whether a given * tag is itself a container @@ -2043,7 +2102,7 @@ PRBool CNavDTD::BackwardPropagate(nsEntryStack& aStack,eHTMLTags aParentTag,eHTM do { CTagList* theRootTags=gHTMLElements[theParentTag].GetRootTags(); - theParentTag=theRootTags->mTags[0]; + theParentTag=theRootTags->GetTagAt(0); if(theParentTag!=eHTMLTag_unknown) { aStack.Push(theParentTag); } @@ -2173,43 +2232,39 @@ PRInt32 CNavDTD::GetTopmostIndexOf(eHTMLTags aTag) const { * @param tag of the container just opened * @return 0 (for now) */ -nsresult CNavDTD::OpenTransientStyles(eHTMLTags aTag){ +nsresult CNavDTD::OpenTransientStyles(eHTMLTags aChildTag){ nsresult result=NS_OK; - if(!FindTagInSet(aTag,gWhitespaceTags,sizeof(gWhitespaceTags)/sizeof(aTag))){ - //the following code builds the set of style tags to be opened... + //later, change this so that transients only open in containers that get leaked in to. -/* - eHTMLTags theStyles[50]; - int theCount=0; +#ifdef ENABLE_RESIDUALSTYLE + eHTMLTags theParentTag=mBodyContext->Last(); + if(!gHTMLElements[theParentTag].HasSpecialProperty(kNoStyleLeaksIn)) { + if(!FindTagInSet(aChildTag,gWhitespaceTags,sizeof(gWhitespaceTags)/sizeof(aChildTag))){ + //the following code builds the set of style tags to be opened... + PRUint32 theCount=mBodyContext->GetCount(); + PRUint32 theIndex=0; + for(theIndex=0;theIndexGetStylesAt(theIndex); + if(theStack){ + PRUint32 scount=theStack->GetCount(); + PRUint32 sindex=0; + for(sindex=0;sindexTagAt(sindex); - int theStackPos=0; - for(theStackPos=0;theStackPosGetCount();theStackPos++){ - nsEntryStack* theStyleStack=mBodyContext->mStyles[theStackPos]; - if(theStyleStack) { - int theTagPos=0; - int count = theStyleStack->mTags->GetSize(); - for(theTagPos=0;theTagPosTagAt(theTagPos),theStyles,theCount))) { - theStyles[theCount++]=theStyleStack->TagAt(theTagPos); + if(theTag==eHTMLTag_font) //XXX HACK DEBUG! + theTag=eHTMLTag_b; + + CStartToken theToken(theTag); + nsCParserNode theNode(&theToken,mLineNumber); + theToken.SetTypeID(theTag); + result=OpenContainer(theNode,PR_FALSE); } } } } - theStyles[theCount]=eHTMLTag_unknown; - - //now iterate style set, and open the containers... - for(theStackPos=0;theStackPosmOpenStyles=theCount; - -*/ - } +#endif return result; } @@ -2225,13 +2280,13 @@ nsresult CNavDTD::OpenTransientStyles(eHTMLTags aTag){ * @param tag of the container just opened * @return 0 (for now) */ -nsresult CNavDTD::CloseTransientStyles(eHTMLTags aTag){ +nsresult CNavDTD::CloseTransientStyles(eHTMLTags aChildTag){ nsresult result=NS_OK; int theTagPos=0; - //now iterate style set, and close the containers... -/* + +#ifdef ENABLE_RESIDUALSTYLE nsDeque* theStyleDeque=mBodyContext->GetStyles(); for(theTagPos=mBodyContext->mOpenStyles;theTagPos>0;theTagPos--){ eHTMLTags theTag=GetTopNode(); @@ -2240,7 +2295,7 @@ nsresult CNavDTD::CloseTransientStyles(eHTMLTags aTag){ token.SetTypeID(theTag); result=CloseContainer(theNode,theTag,PR_FALSE); } -*/ +#endif return result; } @@ -2323,44 +2378,30 @@ nsresult CNavDTD::OpenBody(const nsIParserNode& aNode){ NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos); nsresult result=NS_OK; - eHTMLTags topTag=mBodyContext->Last(); - 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. + PRInt32 theHTMLPos=GetTopmostIndexOf(eHTMLTag_html); + if(kNotFound==theHTMLPos){ //someone forgot to open HTML. Let's do it for them. + nsAutoString theEmpty; + CHTMLToken token(theEmpty,eHTMLTag_html); + nsCParserNode htmlNode(&token,mLineNumber); + result=OpenHTML(htmlNode); //open the html container... + theHTMLPos=GetTopmostIndexOf(eHTMLTag_html); + } - result=CloseContainersTo(0,eHTMLTag_html,PR_TRUE); //close current stack containers. - nsAutoString theEmpty; - CHTMLToken token(theEmpty,eHTMLTag_html); - nsCParserNode htmlNode(&token,mLineNumber); - result=OpenHTML(htmlNode); //open the html container... - } + PRBool theBodyIsOpen=HasOpenContainer(eHTMLTag_body); + if(!theBodyIsOpen){ + //body is not already open, but head may be so close it + result=CloseContainersTo(theHTMLPos+1,eHTMLTag_body,PR_TRUE); //close current stack containers. } if(NS_OK==result) { result=(mSink) ? mSink->OpenBody(aNode) : NS_OK; - mBodyContext->Push((eHTMLTags)aNode.GetNodeType()); - - /*now THIS is a hack to support plaintext documents in this DTD... - if((NS_OK==result) && mIsPlaintext) { - CStartToken theToken(eHTMLTag_pre); //open the body container... - result=HandleStartToken(&theToken); + if(!theBodyIsOpen) { + mBodyContext->Push((eHTMLTags)aNode.GetNodeType()); + mTokenizer->PrependTokens(mMisplacedContent); } - */ } - mTokenizer->PrependTokens(mMisplacedContent); return result; } @@ -2464,6 +2505,7 @@ nsresult CNavDTD::OpenFrameset(const nsIParserNode& aNode){ NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos); nsresult result=(mSink) ? mSink->OpenFrameset(aNode) : NS_OK; mBodyContext->Push((eHTMLTags)aNode.GetNodeType()); + mHadBodyOrFrameset=PR_TRUE; return result; } @@ -2490,10 +2532,11 @@ nsresult CNavDTD::CloseFrameset(const nsIParserNode& aNode){ * 2nd, pass this message on to the sink. * @update gess4/6/98 * @param aNode -- next node to be added to model + * @param aClosedByStartTag -- ONLY TRUE if the container is being closed by opening of another container. * @return TRUE if ok, FALSE if error */ nsresult -CNavDTD::OpenContainer(const nsIParserNode& aNode,PRBool aUpdateStyleStack){ +CNavDTD::OpenContainer(const nsIParserNode& aNode,PRBool aClosedByStartTag){ NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos); nsresult result=NS_OK; @@ -2563,9 +2606,11 @@ CNavDTD::OpenContainer(const nsIParserNode& aNode,PRBool aUpdateStyleStack){ break; } - if((NS_OK==result) && (PR_TRUE==aUpdateStyleStack)){ + /* + if((NS_OK==result) && (PR_TRUE==aClosedByStartTag)){ UpdateStyleStackForOpenTag(nodeType,nodeType); } + */ return result; } @@ -2576,18 +2621,22 @@ CNavDTD::OpenContainer(const nsIParserNode& aNode,PRBool aUpdateStyleStack){ * 2nd, pass this message on to the sink. * @update gess4/6/98 * @param aNode -- next node to be removed from our model + * @param aTag -- id of tag to be closed + * @param aClosedByStartTag -- ONLY TRUE if the container is being closed by opening of another container. * @return TRUE if ok, FALSE if error */ nsresult -CNavDTD::CloseContainer(const nsIParserNode& aNode,eHTMLTags aTag, - PRBool aUpdateStyles){ +CNavDTD::CloseContainer(const nsIParserNode& aNode,eHTMLTags aTag,PRBool aClosedByStartTag){ nsresult result=NS_OK; eHTMLTags nodeType=(eHTMLTags)aNode.GetNodeType(); - + #define K_CLOSEOP 200 CRCStruct theStruct(nodeType,K_CLOSEOP); mComputedCRC32=AccumulateCRC(mComputedCRC32,(char*)&theStruct,sizeof(theStruct)); + if(!aClosedByStartTag) + UpdateStyleStackForCloseTag(nodeType,aTag); + switch(nodeType) { case eHTMLTag_html: @@ -2621,9 +2670,8 @@ CNavDTD::CloseContainer(const nsIParserNode& aNode,eHTMLTags aTag, break; } - if((NS_OK==result) && (PR_TRUE==aUpdateStyles)){ - UpdateStyleStackForCloseTag(nodeType,aTag); - } + if(aClosedByStartTag) + UpdateStyleStackForOpenTag(nodeType,aTag); return result; } @@ -2633,10 +2681,12 @@ CNavDTD::CloseContainer(const nsIParserNode& aNode,eHTMLTags aTag, * our own internal model of the content-stack; and * 2nd, pass this message on to the sink. * @update gess4/6/98 - * @param + * @param anIndex + * @param aTag + * @param aClosedByStartTag -- if TRUE, then we're closing something because a start tag caused it * @return TRUE if ok, FALSE if error */ -nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag, PRBool aUpdateStyles){ +nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag, PRBool aClosedByStartTag){ NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos); nsresult result=NS_OK; @@ -2648,7 +2698,7 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag, PRBool aUpda while(mBodyContext->GetCount()>anIndex) { eHTMLTags theTag=mBodyContext->Last(); theToken.SetTypeID(theTag); - result=CloseContainer(theNode,aTag,aUpdateStyles); + result=CloseContainer(theNode,aTag,aClosedByStartTag); } } return result; @@ -2659,17 +2709,18 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag, PRBool aUpda * our own internal model of the content-stack; and * 2nd, pass this message on to the sink. * @update gess4/6/98 - * @param + * @param aTag -- + * @param aClosedByStartTag -- ONLY TRUE if the container is being closed by opening of another container. * @return TRUE if ok, FALSE if error */ -nsresult CNavDTD::CloseContainersTo(eHTMLTags aTag,PRBool aUpdateStyles){ +nsresult CNavDTD::CloseContainersTo(eHTMLTags aTag,PRBool aClosedByStartTag){ NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos); PRInt32 pos=GetTopmostIndexOf(aTag); if(kNotFound!=pos) { //the tag is indeed open, so close it. - return CloseContainersTo(pos,aTag,aUpdateStyles); + return CloseContainersTo(pos,aTag,aClosedByStartTag); } eHTMLTags theTopTag=mBodyContext->Last(); @@ -2687,27 +2738,27 @@ nsresult CNavDTD::CloseContainersTo(eHTMLTags aTag,PRBool aUpdateStyles){ pos=GetTopmostIndexOf(aTag); if(kNotFound!=pos) { //the tag is indeed open, so close it. - return CloseContainersTo(pos,aTag,aUpdateStyles); + return CloseContainersTo(pos,aTag,aClosedByStartTag); } } nsresult result=NS_OK; - CTagList* theTagList=gHTMLElements[aTag].GetRootTags(); - eHTMLTags theParentTag=theTagList->mTags[0]; + CTagList* theRootTags=gHTMLElements[aTag].GetRootTags(); + eHTMLTags theParentTag=theRootTags->GetTagAt(0); pos=GetTopmostIndexOf(theParentTag); if(kNotFound!=pos) { //the parent container is open, so close it instead - result=CloseContainersTo(pos+1,aTag,aUpdateStyles); + result=CloseContainersTo(pos+1,aTag,aClosedByStartTag); } return result; } /** * This method causes the topmost container on the stack - * to be closed. - * @update gess4/6/98 - * @see CloseContainer() - * @param + * to be closed. The closure is ALWAYS due to a new start + * tag be opened which forces the topmost tag closed. + * + * @update gess 4/26/99 * @return TRUE if ok, FALSE if error */ nsresult CNavDTD::CloseTopmostContainer(){ @@ -2715,7 +2766,8 @@ nsresult CNavDTD::CloseTopmostContainer(){ nsAutoString theEmpty; CEndToken theToken(theEmpty); - eHTMLTags theTag=mBodyContext->Last(); + eHTMLTags theTag=mBodyContext->Last(); + theToken.SetTypeID(theTag); nsCParserNode theNode(&theToken,mLineNumber); return CloseContainer(theNode,theTag,PR_TRUE); @@ -2730,7 +2782,13 @@ nsresult CNavDTD::CloseTopmostContainer(){ * @return error code; 0 means OK */ nsresult CNavDTD::AddLeaf(const nsIParserNode& aNode){ - nsresult result=(mSink) ? mSink->AddLeaf(aNode) : NS_OK; + nsresult result=NS_OK; + + if(mSink){ + eHTMLTags theTag=(eHTMLTags)aNode.GetNodeType(); + OpenTransientStyles(theTag); + result=mSink->AddLeaf(aNode); + } return result; } @@ -2742,7 +2800,7 @@ nsresult CNavDTD::AddLeaf(const nsIParserNode& aNode){ * @param aNode -- next node to be added to model * @return error code; 0 means OK */ -nsresult CNavDTD::AddHeadLeaf(const nsIParserNode& aNode){ +nsresult CNavDTD::AddHeadLeaf(nsIParserNode& aNode){ nsresult result=NS_OK; static eHTMLTags gNoXTags[]={eHTMLTag_noframes,eHTMLTag_nolayer,eHTMLTag_noscript}; @@ -2758,8 +2816,9 @@ nsresult CNavDTD::AddHeadLeaf(const nsIParserNode& aNode){ if(mSink) { result=OpenHead(aNode); if(NS_OK==result) { - if(eHTMLTag_title==theTag) + if(eHTMLTag_title==theTag) { mSink->SetTitle(aNode.GetSkippedContent()); + } else result=AddLeaf(aNode); // XXX If the return value tells us to block, go // ahead and close the tag out anyway, since its @@ -2843,7 +2902,7 @@ nsresult CNavDTD::CreateContextStackFor(eHTMLTags aChildTag){ //you have that aren't in the stack... nsAutoString theEmpty; CStartToken theToken(theEmpty); - PRInt32 count = kPropagationStack.GetSize(); + PRInt32 count = kPropagationStack.GetCount(); if(PR_TRUE==bResult){ while(count>0) { eHTMLTags theTag=kPropagationStack.Pop(); @@ -2893,12 +2952,13 @@ nsresult CNavDTD::ReduceContextStackFor(eHTMLTags aChildTag){ nsresult CNavDTD::UpdateStyleStackForOpenTag(eHTMLTags aTag,eHTMLTags anActualTag){ nsresult result=0; - if(nsHTMLElement::IsStyleTag(aTag)) { - nsEntryStack* theStyleStack=mBodyContext->GetStyles(); - if(theStyleStack){ - theStyleStack->Push(aTag); +#ifdef ENABLE_RESIDUALSTYLE + if(anActualTag!=eHTMLTag_font){ + if(nsHTMLElement::IsStyleTag(aTag)) { + mBodyContext->PushStyle(aTag); } } +#endif return result; } //update.. @@ -2914,15 +2974,10 @@ nsresult CNavDTD::UpdateStyleStackForOpenTag(eHTMLTags aTag,eHTMLTags anActualTa nsresult CNavDTD::UpdateStyleStackForCloseTag(eHTMLTags aTag,eHTMLTags anActualTag){ nsresult result=0; - - nsEntryStack* theStyles=mBodyContext->GetStyles(); - if(theStyles){ - if(nsHTMLElement::IsStyleTag(aTag)) { - if(aTag==anActualTag) { - theStyles->Pop(); - } - }//if - }//if + +#ifdef ENABLE_RESIDUALSTYLE + eHTMLTags theTag=mBodyContext->PopStyle(); +#endif return result; } @@ -2983,6 +3038,3 @@ nsresult CNavDTD::DoFragment(PRBool aFlag) return NS_OK; } - - - diff --git a/mozilla/htmlparser/src/CNavDTD.h b/mozilla/htmlparser/src/CNavDTD.h index 07084cdc321..f438aad7d96 100644 --- a/mozilla/htmlparser/src/CNavDTD.h +++ b/mozilla/htmlparser/src/CNavDTD.h @@ -296,17 +296,6 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD { */ virtual PRBool CanOmit(eHTMLTags aParent,eHTMLTags aChild)const; - /** - * This is called to determine if the given parent can omit the - * given child (end tag). - * - * @update gess 3/25/98 - * @param aParent -- tag type of parent - * @param aChild -- tag type of child - * @return PR_TRUE if given tag can contain omit child (end tag) - */ - virtual PRBool CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild)const; - /** * This method gets called to determine whether a given * tag is itself a container @@ -405,7 +394,6 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD { nsresult HandleEndToken(CToken* aToken); nsresult HandleEntityToken(CToken* aToken); nsresult HandleCommentToken(CToken* aToken); - nsresult HandleSkippedContentToken(CToken* aToken); nsresult HandleAttributeToken(CToken* aToken); nsresult HandleScriptToken(nsCParserNode& aNode); nsresult HandleStyleToken(CToken* aToken); @@ -431,7 +419,7 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD { nsresult OpenForm(const nsIParserNode& aNode); nsresult OpenMap(const nsIParserNode& aNode); nsresult OpenFrameset(const nsIParserNode& aNode); - nsresult OpenContainer(const nsIParserNode& aNode,PRBool aUpdateStyleStack); + nsresult OpenContainer(const nsIParserNode& aNode,PRBool aClosedByStartTag); /** * The next set of methods close the given HTML element. @@ -446,7 +434,7 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD { nsresult CloseForm(const nsIParserNode& aNode); nsresult CloseMap(const nsIParserNode& aNode); nsresult CloseFrameset(const nsIParserNode& aNode); - nsresult CloseContainer(const nsIParserNode& aNode,eHTMLTags anActualTag,PRBool aUpdateStyles); + nsresult CloseContainer(const nsIParserNode& aNode,eHTMLTags anActualTag,PRBool aClosedByStartTag); /** * The special purpose methods automatically close @@ -455,8 +443,8 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD { * @return error code - 0 if all went well. */ nsresult CloseTopmostContainer(); - nsresult CloseContainersTo(eHTMLTags aTag,PRBool aUpdateStyles); - nsresult CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag,PRBool aUpdateStyles); + nsresult CloseContainersTo(eHTMLTags aTag,PRBool aClosedByStartTag); + nsresult CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag,PRBool aClosedByStartTag); /** * Causes leaf to be added to sink at current vector pos. @@ -465,7 +453,7 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD { * @return error code - 0 if all went well. */ nsresult AddLeaf(const nsIParserNode& aNode); - nsresult AddHeadLeaf(const nsIParserNode& aNode); + nsresult AddHeadLeaf(nsIParserNode& aNode); /** * Causes auto-closures of context vector stack in order to find a @@ -495,17 +483,16 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD { * @param aTag -- represents the transient style tag to be handled. * @return error code -- usually 0 */ - nsresult OpenTransientStyles(eHTMLTags aTag); - nsresult CloseTransientStyles(eHTMLTags aTag); + nsresult OpenTransientStyles(eHTMLTags aChildTag); + nsresult CloseTransientStyles(eHTMLTags aChildTag); nsresult UpdateStyleStackForOpenTag(eHTMLTags aTag,eHTMLTags aActualTag); nsresult UpdateStyleStackForCloseTag(eHTMLTags aTag,eHTMLTags aActualTag); - PRBool CanContainStyles(eHTMLTags aTag) const; nsresult DoFragment(PRBool aFlag); protected: - nsresult CollectAttributes(nsCParserNode& aNode,PRInt32 aCount); + nsresult CollectAttributes(nsCParserNode& aNode,eHTMLTags aTag,PRInt32 aCount); nsresult CollectSkippedContent(nsCParserNode& aNode,PRInt32& aCount); nsresult WillHandleStartTag(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode); nsresult DidHandleStartTag(nsCParserNode& aNode,eHTMLTags aChildTag); @@ -531,8 +518,10 @@ protected: nsParser* mParser; nsITokenizer* mTokenizer; nsDeque mMisplacedContent; + nsDeque mSkippedContent; PRBool mHasOpenScript; PRBool mSaveBadTokens; + eHTMLTags mSkipTarget; PRUint32 mComputedCRC32; PRUint32 mExpectedCRC32; diff --git a/mozilla/htmlparser/src/COtherDTD.cpp b/mozilla/htmlparser/src/COtherDTD.cpp index 60d0cdf73a8..c71d8255066 100644 --- a/mozilla/htmlparser/src/COtherDTD.cpp +++ b/mozilla/htmlparser/src/COtherDTD.cpp @@ -254,20 +254,6 @@ nsresult COtherDTD::HandleCommentToken(CToken* aToken) { return CNavDTD::HandleCommentToken(aToken); } -/** - * This method gets called when a skippedcontent token has - * been encountered in the parse process. After verifying - * that the topmost container can contain text, we call - * AddLeaf to store this token in the top container. - * - * @update gess 3/25/98 - * @param aToken -- next (start) token to be handled - * @return PR_TRUE if all went well; PR_FALSE if error occured - */ -nsresult COtherDTD::HandleSkippedContentToken(CToken* aToken) { - return CNavDTD::HandleSkippedContentToken(aToken); -} - /** * This method gets called when an attribute token has been * encountered in the parse process. This is an error, since @@ -334,19 +320,6 @@ PRBool COtherDTD::CanOmit(eHTMLTags aParent,eHTMLTags aChild) const { } -/** - * This method gets called to determine whether a given - * ENDtag can be omitted. Admittedly,this is a gross simplification. - * - * @update gess 3/25/98 - * @param aTag -- tag to test for containership - * @return PR_TRUE if given tag can contain other tags - */ -PRBool COtherDTD::CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild) const { - return CNavDTD::CanOmitEndTag(aParent,aChild); -} - - /********************************************* Here comes code that handles the interface to our content sink. diff --git a/mozilla/htmlparser/src/COtherDTD.h b/mozilla/htmlparser/src/COtherDTD.h index 8cc1f83f45b..6e63a61fa59 100644 --- a/mozilla/htmlparser/src/COtherDTD.h +++ b/mozilla/htmlparser/src/COtherDTD.h @@ -121,17 +121,6 @@ class COtherDTD : public CNavDTD { */ virtual PRBool CanOmit(eHTMLTags aParent,eHTMLTags aChild)const; - /** - * This method gets called to determine whether a given - * tag can contain newlines. Most do not. - * - * @update gess 3/25/98 - * @param aParent -- tag type of parent - * @param aChild -- tag type of child - * @return PR_TRUE if given tag can contain other tags - */ - virtual PRBool CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild)const; - /** * This method gets called when a start token has been consumed and needs * to be handled (possibly added to content model via sink). @@ -181,15 +170,6 @@ class COtherDTD : public CNavDTD { */ nsresult HandleCommentToken(CToken* aToken); - /** - * This method gets called when a skipped-content token has been consumed and needs - * to be handled (possibly added to content model via sink). - * @update gess5/11/98 - * @param aToken is the skipped-content token to be handled - * @return TRUE if the token was handled. - */ - nsresult HandleSkippedContentToken(CToken* aToken); - /** * This method gets called when an attribute token has been consumed and needs * to be handled (possibly added to content model via sink). diff --git a/mozilla/htmlparser/src/nsDTDUtils.cpp b/mozilla/htmlparser/src/nsDTDUtils.cpp index 770d125e848..a7d0a155afc 100644 --- a/mozilla/htmlparser/src/nsDTDUtils.cpp +++ b/mozilla/htmlparser/src/nsDTDUtils.cpp @@ -19,9 +19,9 @@ #include "nsDTDUtils.h" #include "CNavDTD.h" + #include "nsIObserverService.h" #include "nsIServiceManager.h" -#include "nsIElementObserver.h" static NS_DEFINE_IID(kIObserverServiceIID, NS_IOBSERVERSERVICE_IID); static NS_DEFINE_IID(kObserverServiceCID, NS_OBSERVERSERVICE_CID); @@ -51,6 +51,8 @@ nsEntryStack::nsEntryStack() { nsEntryStack::~nsEntryStack() { if(mEntries) delete [] mEntries; + mCount=mCapacity=0; + mEntries=0; } /** @@ -182,7 +184,6 @@ PRInt32 nsEntryStack::GetTopmostIndexOf(eHTMLTags aTag) const { /** * * @update gess9/10/98 - * @update gess 4/26/99 */ nsDTDContext::nsDTDContext() : mStack(), mSkipped(0), mStyles(0) { #ifdef NS_DEBUG @@ -194,7 +195,6 @@ nsDTDContext::nsDTDContext() : mStack(), mSkipped(0), mStyles(0) { /** * * @update gess9/10/98 - * @update gess 4/26/99 */ nsDTDContext::~nsDTDContext() { } @@ -202,16 +202,14 @@ nsDTDContext::~nsDTDContext() { /** * * @update gess7/9/98, harishd 04/04/99 - * @update gess 4/26/99 */ PRInt32 nsDTDContext::GetCount(void) { - return mStack.GetSize(); + return mStack.GetCount(); } /** * * @update gess7/9/98, harishd 04/04/99 - * @update gess 4/26/99 */ void nsDTDContext::Push(eHTMLTags aTag) { #ifdef NS_DEBUG @@ -224,7 +222,6 @@ void nsDTDContext::Push(eHTMLTags aTag) { /** * @update gess7/9/98, harishd 04/04/99 - * @update gess 4/26/99 */ eHTMLTags nsDTDContext::Pop() { #ifdef NS_DEBUG @@ -232,6 +229,14 @@ eHTMLTags nsDTDContext::Pop() { mTags[mStack.mCount-1]=eHTMLTag_unknown; #endif + nsEntryStack* theStyles=0; + nsTagEntry& theEntry=mStack.EntryAt(mStack.mCount-1); + PRInt32 theIndex=theEntry.mStyleIndex; + if(-1Push(aTag); + } +} + +/** + * + * @update gess 04/28/99 + */ +eHTMLTags nsDTDContext::PopStyle(void){ + eHTMLTags result=eHTMLTag_unknown; + nsTagEntry& theEntry=mStack.EntryAt(mStack.mCount-1); + //ok, now go get the right tokenbank deque... + nsEntryStack* theStack=0; + if(-1Pop(); + } + return result; +} + + /** * * @update harishd 04/04/99 @@ -296,7 +337,7 @@ nsEntryStack* nsDTDContext::GetStyles(void) const { */ void nsDTDContext::SaveToken(CToken* aToken, PRInt32 aID) { - NS_PRECONDITION(aID <= mStack.GetSize() && aID > -1,"Out of bounds"); + NS_PRECONDITION(aID <= mStack.GetCount() && aID > -1,"Out of bounds"); if(aToken) { nsTagEntry& theEntry=mStack.EntryAt(aID); @@ -321,9 +362,9 @@ void nsDTDContext::SaveToken(CToken* aToken, PRInt32 aID) */ CToken* nsDTDContext::RestoreTokenFrom(PRInt32 aID) { - NS_PRECONDITION(aID <= mStack.GetSize() && aID > -1,"Out of bounds"); + NS_PRECONDITION(aID <= mStack.GetCount() && aID > -1,"Out of bounds"); CToken* result=0; - if(0 #include "nsITokenizer.h" #include "nsString.h" +#include "nsIElementObserver.h" /*************************************************************** Before digging into the NavDTD, we'll define a helper @@ -79,7 +80,7 @@ public: eHTMLTags operator[](PRUint32 anIndex) const; eHTMLTags Last() const; void Empty(void); - PRInt32 GetSize(void) const {return mCount;} + PRInt32 GetCount(void) const {return mCount;} nsTagEntry* mEntries; PRUint32 mCount; @@ -106,7 +107,9 @@ public: eHTMLTags Last() const; void Empty(void); PRInt32 GetCount(void); - nsEntryStack* GetStyles(void) const; + nsEntryStack* GetStylesAt(PRUint32 anIndex) const; + void PushStyle(eHTMLTags aTag); + eHTMLTags PopStyle(void); void SaveToken(CToken* aToken, PRInt32 aID); CToken* RestoreTokenFrom(PRInt32 aID); diff --git a/mozilla/htmlparser/src/nsElementTable.cpp b/mozilla/htmlparser/src/nsElementTable.cpp index 446a405ef4c..e655862aa7f 100644 --- a/mozilla/htmlparser/src/nsElementTable.cpp +++ b/mozilla/htmlparser/src/nsElementTable.cpp @@ -48,7 +48,7 @@ PRBool CTagList::Contains(eHTMLTags aTag){ * @return */ PRInt32 CTagList::GetTopmostIndexOf(nsEntryStack& aTagStack){ - int max = aTagStack.GetSize(); + int max = aTagStack.GetCount(); int index; for(index=max-1;index>=0;index--){ if(Contains(aTagStack[index])) { @@ -65,7 +65,7 @@ PRInt32 CTagList::GetTopmostIndexOf(nsEntryStack& aTagStack){ * @return */ PRInt32 CTagList::GetBottommostIndexOf(nsEntryStack& aTagStack,PRInt32 aStartOffset){ - int max = aTagStack.GetSize(); + int max = aTagStack.GetCount(); int index; for(index=aStartOffset;index*/ 0,&gContainsParam,eHTMLTag_unknown}, + /*parent,incl,exclgroups*/ kSpecial, (kSelf|SPECIALTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, + /*special parents,kids,skip*/ 0,&gContainsParam,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_area, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gAreaParent,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, kInline, kSelf, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, kInlineEntity, kSelf, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ &gAreaParent,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_b, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kFlow|kSelf), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFontStyle, (FSTYPE|kSelf), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_base, @@ -283,63 +307,63 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gInHead, &gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ 0, kNoPropRange, /*special parents,kids,skip*/ &gInHead,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_basefont, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kSpecial, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, SPECIALTYPE, kNone, + /*special props, prop-range*/ 0, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_bdo, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kSpecial, (kSelf|kInline), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, (kSelf|SPECIALTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_bgsound, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kExtensions, kNone, kNone, + /*special props, prop-range*/ 0,kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_big, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kFlow|kSelf), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFontStyle, (FSTYPE|kSelf), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_blink, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kFlow|kSelf), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFontStyle, (kFlowEntity|kSelf), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_blockquote, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_body, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_frameset, /*rootnodes,endrootnodes*/ &gInHTML, &gInHTML, /*autoclose starttags and endtags*/ &gBodyAutoClose,0,0, - /*parent,incl,exclgroups*/ kHTMLContent,(kFlow|kSelf), kNone, - /*special properties*/ kOmitEndTag|kLegalOpen, + /*parent,incl,exclgroups*/ kHTMLContent,(kFlowEntity|kSelf), kNone, + /*special props, prop-range*/ kOmitEndTag|kLegalOpen, kBodyPropRange, /*special parents,kids,skip*/ &gInNoframes,&gBodyKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_br, @@ -347,103 +371,103 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kSpecial, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ 0, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_button, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFormControl, kFlow, kFormControl, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFormControl, kFlowEntity, kFormControl, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gButtonKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_caption, - /*requiredAncestor*/ eHTMLTag_table,eHTMLTag_unknown, - /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, + /*req-parent excl-parent*/ eHTMLTag_table,eHTMLTag_unknown, + /*rootnodes,endrootnodes*/ &gInTable,&gInTable, /*autoclose starttags and endtags*/ &gCaptionAutoClose,0,0, - /*parent,incl,exclgroups*/ kNone, kInline, kSelf, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, kInlineEntity, kSelf, + /*special props, prop-range*/ kNoPropagate,kDefaultPropRange, /*special parents,kids,skip*/ &gInTable,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_center, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, (kInline|kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kBlock, (kInlineEntity|kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_cite, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kPhrase, (kInline|kSelf), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPhrase, (kFlowEntity|kSelf), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_code, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPhrase, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_col, - /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, + /*req-parent excl-parent*/ eHTMLTag_table,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gColParents,&gColParents, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ kOmitWS, + /*special props, prop-range*/ kNoPropagate|kOmitWS,kDefaultPropRange, /*special parents,kids,skip*/ &gColParents,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_colgroup, - /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, - /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, + /*req-parent excl-parent*/ eHTMLTag_table,eHTMLTag_unknown, + /*rootnodes,endrootnodes*/ &gInTable,&gInTable, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ kOmitWS, + /*special props, prop-range*/ kOmitWS|kNoPropagate,kDefaultPropRange, /*special parents,kids,skip*/ &gInTable,&gColgroupKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_dd, - /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, + /*req-parent excl-parent*/ eHTMLTag_dl,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gInDL, &gInDL, /*autoclose starttags and endtags*/ &gDTCloseTags,0,0, - /*parent,incl,exclgroups*/ kNone, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, kFlowEntity, kNone, + /*special props, prop-range*/ kNoPropagate,kDefaultPropRange, /*special parents,kids,skip*/ &gInDL,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_del, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFlowEntity, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ &gInBody,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_dfn, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPhrase, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_dir, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kList, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gULKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_div, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gDivAutoClose,0,0, - /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_dl, @@ -451,63 +475,63 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kBlock, (kSpecial|kFontStyle), kNone, - /*special properties*/ kOmitWS, + /*special props, prop-range*/ kOmitWS, kNoPropRange, /*special parents,kids,skip*/ 0,&gDLKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_dt, - /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, + /*req-parent excl-parent*/ eHTMLTag_dl,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gInDL,&gInDL, /*autoclose starttags and endtags*/ &gDTCloseTags,0,0, - /*parent,incl,exclgroups*/ kNone, kInline, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, kInlineEntity, kNone, + /*special props, prop-range*/ kNoPropagate,kDefaultPropRange, /*special parents, kids
*/ &gInDL,&gDTKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_em, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPhrase, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_embed, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kBlockEntity, kNone, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gContainsParam,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_endnote, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFlowEntity, kFlowEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_fieldset, /*requiredAncestor*/ eHTMLTag_form,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ kOmitWS, + /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ kNoPropagate|kOmitWS,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gFieldsetKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_font, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kSpecial, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, (kSelf|SPECIALTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gFontKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_form, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kBlock, kFlowEntity, kNone, + /*special props, prop-range*/ kNoStyleLeaksIn, kNoPropRange, /*special parents,kids,skip*/ 0,&gFormKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_frame, @@ -515,15 +539,15 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gInFrameset,&gInFrameset, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ kNoPropagate|kNoStyleLeaksIn, kNoPropRange, /*special parents,kids,skip*/ &gInFrameset,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_frameset, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_body, /*rootnodes,endrootnodes*/ &gFramesetParents,&gInHTML, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kNone, kSelf, kNone, - /*special properties*/ kOmitWS, + /*parent,incl,exclgroups*/ kHTMLContent, kSelf, kNone, + /*special props, prop-range*/ kOmitWS|kNoPropagate|kNoStyleLeaksIn, kNoPropRange, /*special parents,kids,skip*/ &gInHTML,&gFramesetKids,eHTMLTag_unknown}, @@ -531,56 +555,56 @@ nsHTMLElement gHTMLElements[] = { /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kHeading, kFlowEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_h2, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kHeading, kFlowEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_h3, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kHeading, kFlowEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_h4, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kHeading, kFlowEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_h5, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kHeading, kFlowEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_h6, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kHeading, kFlowEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_head, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gInHTML, &gInHTML, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kNone, (kHeadContent|kHeadMisc), kNone, - /*special properties*/ kOmitWS, + /*parent,incl,exclgroups*/ kHTMLContent, (kHeadContent|kHeadMisc), kNone, + /*special props, prop-range*/ kOmitWS|kNoStyleLeaksIn, kDefaultPropRange, /*special parents,kids,skip*/ &gInHTML,&gHeadKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_hr, @@ -588,55 +612,55 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gHRAutoClose,0,0, /*parent,incl,exclgroups*/ kBlock, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_html, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_html, /*rootnodes,endrootnodes*/ &gHTMLRootTags, &gHTMLRootTags, - /*autoclose starttags and endtags*/ &gAutoClose,0,0, + /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kHTMLContent, kNone, - /*special properties*/ kOmitEndTag|kOmitWS, + /*special props, prop-range*/ kOmitEndTag|kOmitWS|kNoStyleLeaksIn, kDefaultPropRange, /*special parents,kids,skip*/ 0,&gHtmlKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_i, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFontStyle, (kSelf|FSTYPE), kNone, + /*special props, prop-range*/ 0, kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_iframe, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kSpecial, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, (kSelf|SPECIALTYPE), kNone, + /*special props, prop-range*/ kNoStyleLeaksIn, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_ilayer, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kBlock, kFlowEntity, kNone, + /*special props, prop-range*/ kNoStyleLeaksIn, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_image, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, kNone, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_img, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, kNone, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_input, @@ -644,31 +668,31 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kFormControl, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_ins, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, (kSelf|kNone), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFlowEntity, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_isindex, - /*requiredAncestor*/ eHTMLTag_form,eHTMLTag_unknown, + /*requiredAncestor*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ (kBlock|kHeadContent), kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ (kBlock|kHeadContent), kFlowEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ &gInBody,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_kbd, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kPhrase, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPhrase, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_keygen, @@ -676,39 +700,39 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_label, - /*requiredAncestor*/ eHTMLTag_form,eHTMLTag_unknown, + /*req-parent excl-parent*/ eHTMLTag_form,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFormControl, kInline, kSelf, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFormControl, kInlineEntity, kSelf, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_layer, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, kFlow, kSelf, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kBlock, kFlowEntity, kSelf, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_legend, /*requiredAncestor*/ eHTMLTag_form,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gInFieldset,&gInFieldset, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kNone, kInline, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, kInlineEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ &gInFieldset,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_li, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gLIRootTags,&gLIRootTags, /*autoclose starttags and endtags*/ &gLIAutoClose,0,0, - /*parent,incl,exclgroups*/ kList, kFlow, kSelf, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFlowEntity, kFlowEntity, kSelf, + /*special props, prop-range*/ kNoPropagate, kDefaultPropRange, /*special parents,kids,skip*/ 0,&gLIKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_link, @@ -716,31 +740,31 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gInHead,&gInHead, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kHeadMisc, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ &gInHead,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_listing, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPreformatted, kNone, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_map, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kSpecial, kBlock, kNone, - /*special properties*/ kOmitWS, + /*parent,incl,exclgroups*/ kSpecial, SPECIALTYPE, kNone, + /*special props, prop-range*/ kOmitWS, kDefaultPropRange, /*special parents,kids,skip*/ 0,&gMapKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_menu, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kList, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kList, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gULKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_meta, @@ -748,23 +772,23 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gInHead, &gInHead, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kHeadMisc, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ kNoStyleLeaksIn, kDefaultPropRange, /*special parents,kids,skip*/ &gInHead,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_multicol, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kExtensions, kNone, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_nobr, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, (kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kExtensions, (kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_noembed, @@ -772,15 +796,15 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ kDiscardTag, + /*special props, prop-range*/ kDiscardTag, kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_noembed}, { /*tag*/ eHTMLTag_noframes, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gNoframeRoot,&gNoframeRoot, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ kDiscardTag, + /*parent,incl,exclgroups*/ kBlock, kFlowEntity, kNone, + /*special props, prop-range*/ kDiscardTag, kNoPropRange, /*special parents,kids,skip*/ &gNoframeRoot,&gNoframesKids,eHTMLTag_noframes}, { /*tag*/ eHTMLTag_nolayer, @@ -788,31 +812,31 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ kDiscardTag, + /*special props, prop-range*/ kDiscardTag, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_nolayer}, { /*tag*/ eHTMLTag_noscript, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ kDiscardTag, + /*parent,incl,exclgroups*/ kBlock, kFlowEntity, kNone, + /*special props, prop-range*/ kDiscardTag, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_noscript}, { /*tag*/ eHTMLTag_object, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ (kHeadMisc|kSpecial), (kFlow|kSelf), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ (kHeadMisc|kSpecial), (SPECIALTYPE|kSelf), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gContainsParam,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_ol, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gOLRootTags,&gOLRootTags, /*autoclose starttags and endtags*/ &gOLAutoClose, &gULCloseTags, 0, - /*parent,incl,exclgroups*/ kBlock, (kFlow|kSelf), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kList, (kFlowEntity|kSelf), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gULKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_optgroup, @@ -820,79 +844,79 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gOptgroupParents,&gOptgroupParents, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ &gOptgroupParents,&gContainsOpts,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_option, /*requiredAncestor*/ eHTMLTag_form,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gOptgroupParents,&gOptgroupParents, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kNone, kPCDATA, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, kPCDATA, kFlowEntity, + /*special props, prop-range*/ kNoStyleLeaksIn, kDefaultPropRange, /*special parents,kids,skip*/ &gOptgroupParents,&gContainsText,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_p, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, - /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, + /*rootnodes,endrootnodes*/ &gInBody,&gInBody, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, kInline, kNone, //this used to contain FLOW. But it's really an inline container. - /*special properties*/ 0, //otherwise it tries to contain things like H1..H6 + /*parent,incl,exclgroups*/ kBlock, kInlineEntity, kNone, //this used to contain FLOW. But it's really an inline container. + /*special props, prop-range*/ 0,kDefaultPropRange, //otherwise it tries to contain things like H1..H6 /*special parents,kids,skip*/ 0,&gInP,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_param, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gParamParents, &gParamParents, /*autoclose starttags and endtags*/ &gPAutoClose,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, kNone, kNone, + /*special props, prop-range*/ 0, kNoPropRange, /*special parents,kids,skip*/ &gParamParents,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_parsererror, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gDivAutoClose,0,0, - /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_plaintext, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kExtensions, kFlowEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_html}, { /*tag*/ eHTMLTag_pre, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kPreformatted, kInline, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPreformatted, kFlowEntity, kNone, //I'm allowing WAY too much in here. Spec says inline. + /*special props, prop-range*/ kNoStyleLeaksIn, kDefaultPropRange, /*special parents,kids,skip*/ 0,&gPreKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_q, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kSpecial, (kSelf|kInline), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, (kSelf|SPECIALTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, - + { /*tag*/ eHTMLTag_s, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFontStyle, (kSelf|FSTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_samp, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPhrase, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_script, @@ -900,15 +924,15 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ (kSpecial|kHeadMisc), kPCDATA, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ kNoStyleLeaksIn, kNoPropRange, /*special parents,kids,skip*/ 0,&gContainsText,eHTMLTag_script}, { /*tag*/ eHTMLTag_select, /*requiredAncestor*/ eHTMLTag_form, eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gInForm,&gInForm, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFormControl, kNone, kNone, - /*special properties*/ kOmitWS, + /*parent,incl,exclgroups*/ kFormControl, kNone, kFlowEntity, + /*special props, prop-range*/ kOmitWS|kNoStyleLeaksIn, kDefaultPropRange, /*special parents,kids,skip*/ &gInForm,&gContainsOpts,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_server, @@ -916,15 +940,15 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ kNoStyleLeaksIn, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_small, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFontStyle, (kSelf|FSTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_sound, @@ -932,47 +956,47 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_sourcetext, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gDivAutoClose,0,0, - /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_spacer, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kExtensions, kNone, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_span, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kSpecial, (kSelf|kInline), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, (kSelf|SPECIALTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_strike, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFontStyle, (kSelf|FSTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_strong, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ (kPhrase|kFontStyle), (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPhrase, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gContainsText,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_style, @@ -980,55 +1004,55 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gInHead, &gInHead, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kHeadMisc, kPCDATA, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ kNoStyleLeaksIn, kNoPropRange, /*special parents,kids,skip*/ &gInHead,0,eHTMLTag_style}, { /*tag*/ eHTMLTag_sub, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, (kSelf|SPECIALTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_sup, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, (kSelf|SPECIALTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_table, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gInBody, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, kNone, kSelf, - /*special properties*/ (kOmitWS|kBadContentWatch), + /*parent,incl,exclgroups*/ kBlock, kNone, (kSelf|kInlineEntity), + /*special props, prop-range*/ (kOmitWS|kBadContentWatch|kNoStyleLeaksIn), 2, /*special parents,kids,skip*/ 0,&gTableKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_tbody, /*requiredAncestor*/ eHTMLTag_table, eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gInTable, &gInTable, /*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0, - /*parent,incl,exclgroups*/ kNone, kNone, kSelf, - /*special properties*/ (kOmitWS|kBadContentWatch), + /*parent,incl,exclgroups*/ kNone, kNone, (kSelf|kInlineEntity), + /*special props, prop-range*/ (kNoPropagate|kOmitWS|kBadContentWatch|kNoStyleLeaksIn), kDefaultPropRange, /*special parents,kids,skip*/ &gInTable,&gTBodyKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_td, /*requiredAncestor*/ eHTMLTag_table, eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gTDRootTags,&gTDRootTags, /*autoclose starttags and endtags*/ &gTDCloseTags,&gTDCloseTags,0, - /*parent,incl,exclgroups*/ kNone, kFlow, kSelf, - /*special properties*/ 0, - /*special parents,kids,skip*/ &gTDRootTags,0,eHTMLTag_unknown}, + /*parent,incl,exclgroups*/ kNone, kFlowEntity, kSelf, + /*special props, prop-range*/ kNoStyleLeaksIn, kDefaultPropRange, + /*special parents,kids,skip*/ &gTDRootTags,&gBodyKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_textarea, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gInForm, &gInForm, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kFormControl, kPCDATA, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ &gInForm,&gContainsText,eHTMLTag_textarea}, { /*tag*/ eHTMLTag_tfoot, @@ -1036,15 +1060,15 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gInTable, &gInTable, /*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kSelf, - /*special properties*/ (kOmitWS|kBadContentWatch), + /*special props, prop-range*/ (kNoPropagate|kOmitWS|kBadContentWatch|kNoStyleLeaksIn), kNoPropRange, /*special parents,kids,skip*/ &gInTable,&gTableElemKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_th, /*requiredAncestor*/ eHTMLTag_table, eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gTDRootTags,&gTDRootTags, /*autoclose starttags and endtags*/ &gTDCloseTags,&gTDCloseTags,0, - /*parent,incl,exclgroups*/ kNone, kFlow, kSelf, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, kFlowEntity, kSelf, + /*special props, prop-range*/ kNoStyleLeaksIn, kDefaultPropRange, /*special parents,kids,skip*/ &gTDRootTags,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_thead, @@ -1052,111 +1076,111 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gInTable,&gInTable, /*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kSelf, - /*special properties*/ (kOmitWS|kBadContentWatch), + /*special props, prop-range*/ (kNoPropagate|kOmitWS|kBadContentWatch|kNoStyleLeaksIn), kNoPropRange, /*special parents,kids,skip*/ &gInTable,&gTableElemKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_title, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gInHead,&gInHead, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kNone, (kHeadMisc|kPCDATA), kNone, - /*special properties*/ kOmitWS, + /*parent,incl,exclgroups*/ kHeadMisc,kPCDATA, kNone, + /*special props, prop-range*/ kOmitWS|kNoStyleLeaksIn, kNoPropRange, /*special parents,kids,skip*/ &gInHead,&gContainsText,eHTMLTag_title}, { /*tag*/ eHTMLTag_tr, /*requiredAncestor*/ eHTMLTag_table, eHTMLTag_unknown, - /*rootnodes,endrootnodes*/ &gTRParents,&gTRParents, + /*rootnodes,endrootnodes*/ &gTRParents,&gTREndParents, /*autoclose starttags and endtags*/ &gTRCloseTags,0,0, - /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ (kOmitWS|kBadContentWatch), + /*parent,incl,exclgroups*/ kNone, kNone, kInlineEntity, + /*special props, prop-range*/ (kOmitWS|kBadContentWatch|kNoStyleLeaksIn), kNoPropRange, /*special parents,kids,skip*/ &gTRParents,&gTRKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_tt, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFontStyle, (kSelf|FSTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_u, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFontStyle, (kSelf|FSTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_ul, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gOLRootTags,&gOLRootTags, /*autoclose starttags and endtags*/ &gOLAutoClose,&gULCloseTags,0, - /*parent,incl,exclgroups*/ kBlock, (kFlow|kSelf), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kList, (kFlowEntity|kSelf), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gULKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_var, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPhrase, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_wbr, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kExtensions, kNone, kNone, + /*special props, prop-range*/ 0,kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_xmp, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, - /*special parents,kids,skip*/ 0,0,eHTMLTag_xmp}, + /*parent,incl,exclgroups*/ kPreformatted, kNone, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, + /*special parents,kids,skip*/ 0,0,eHTMLTag_xmp}, { /*tag*/ eHTMLTag_text, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, - /*rootnodes,endrootnodes*/ &gTextRootTags,&gTextRootTags, + /*rootnodes,endrootnodes*/ &gInBody,&gInBody, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFlowEntity, kNone, kNone, + /*special props, prop-range*/ 0,kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_whitespace, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, - /*rootnodes,endrootnodes*/ &gTextRootTags,&gTextRootTags, + /*rootnodes,endrootnodes*/ &gInBody,&gInBody, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFlowEntity, kNone, kNone, + /*special props, prop-range*/ 0,kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_newline, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, - /*rootnodes,endrootnodes*/ &gTextRootTags,&gTextRootTags, + /*rootnodes,endrootnodes*/ &gInBody,&gInBody, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFlowEntity, kNone, kNone, + /*special props, prop-range*/ 0, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_comment, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ kOmitEndTag, + /*parent,incl,exclgroups*/ kFlowEntity, kNone, kNone, + /*special props, prop-range*/ kOmitEndTag,kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_entity, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, - /*rootnodes,endrootnodes*/ &gTextRootTags,&gTextRootTags, + /*rootnodes,endrootnodes*/ &gInBody,&gInBody, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFlowEntity, kNone, kNone, + /*special props, prop-range*/ 0, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_userdefined, @@ -1164,7 +1188,7 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ kOmitEndTag, + /*special props, prop-range*/ kOmitEndTag, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, }; @@ -1203,14 +1227,16 @@ PRBool nsHTMLElement::IsContainer(eHTMLTags aChild) { if(!result){ static eHTMLTags gNonContainers[]={ eHTMLTag_unknown, - eHTMLTag_area, eHTMLTag_base, eHTMLTag_basefont, - eHTMLTag_br, eHTMLTag_col, eHTMLTag_embed, - eHTMLTag_frame, eHTMLTag_hr, eHTMLTag_whitespace, - eHTMLTag_input, eHTMLTag_link, eHTMLTag_isindex, - eHTMLTag_meta, eHTMLTag_param, eHTMLTag_plaintext, - eHTMLTag_style, eHTMLTag_spacer, eHTMLTag_wbr, - eHTMLTag_newline, eHTMLTag_text, eHTMLTag_img, - eHTMLTag_unknown, eHTMLTag_xmp}; + eHTMLTag_area, eHTMLTag_base, eHTMLTag_basefont, + eHTMLTag_br, eHTMLTag_col, eHTMLTag_embed, + eHTMLTag_frame, eHTMLTag_hr, + eHTMLTag_img, eHTMLTag_image, eHTMLTag_input, + eHTMLTag_link, eHTMLTag_isindex, eHTMLTag_meta, + eHTMLTag_newline, eHTMLTag_param, eHTMLTag_plaintext, + eHTMLTag_style, eHTMLTag_spacer, eHTMLTag_text, + eHTMLTag_unknown, eHTMLTag_wbr, eHTMLTag_whitespace, + eHTMLTag_xmp}; + result=!FindTagInSet(aChild,gNonContainers,sizeof(gNonContainers)/sizeof(eHTMLTag_unknown)); } @@ -1226,22 +1252,7 @@ PRBool nsHTMLElement::IsContainer(eHTMLTags aChild) { */ inline PRBool TestBits(int aBitset,int aTest) { PRInt32 result=aBitset & aTest; - return PRBool(result==aTest); -} - -/** - * - * @update gess 01/04/99 - * @param - * @return - */ -PRBool nsHTMLElement::IsContainerType(eHTMLTags aTag,int aType) { - PRBool result=PR_FALSE; - - if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_userdefined)){ - result=TestBits(gHTMLElements[aTag].mInclusionBits,aType); - } - return result; + return (aTest) ? PRBool(result==aTest) : PR_FALSE; //was aTest } @@ -1251,11 +1262,11 @@ PRBool nsHTMLElement::IsContainerType(eHTMLTags aTag,int aType) { * @param * @return */ -PRBool nsHTMLElement::IsBlockElement(eHTMLTags aTag){ +PRBool nsHTMLElement::IsBlockEntity(eHTMLTags aTag){ PRBool result=PR_FALSE; if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_userdefined)){ - result=TestBits(gHTMLElements[aTag].mParentBits,kBlock); + result=TestBits(gHTMLElements[aTag].mParentBits,kBlockEntity); } return result; } @@ -1272,11 +1283,12 @@ PRBool nsHTMLElement::IsBlockCloser(eHTMLTags aTag){ if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_userdefined)){ // result=IsFlowElement(aTag); - result=gHTMLElements[aTag].IsMemberOf(kFlow); + result=gHTMLElements[aTag].IsMemberOf(kBlockEntity); //was kFlowEntity... if(!result) { - static eHTMLTags gClosers[]={ eHTMLTag_table,eHTMLTag_caption,eHTMLTag_dd,eHTMLTag_dt, - eHTMLTag_td,eHTMLTag_tfoot,eHTMLTag_th,eHTMLTag_thead,eHTMLTag_tr}; + static eHTMLTags gClosers[]={ eHTMLTag_table,eHTMLTag_tbody,eHTMLTag_caption,eHTMLTag_dd,eHTMLTag_dt, + eHTMLTag_td,eHTMLTag_tfoot,eHTMLTag_th,eHTMLTag_thead,eHTMLTag_tr, + eHTMLTag_optgroup}; result=FindTagInSet(aTag,gClosers,sizeof(gClosers)/sizeof(eHTMLTag_body)); } } @@ -1290,10 +1302,10 @@ PRBool nsHTMLElement::IsBlockCloser(eHTMLTags aTag){ * @param * @return */ -PRBool nsHTMLElement::IsInlineElement(eHTMLTags aTag){ +PRBool nsHTMLElement::IsInlineEntity(eHTMLTags aTag){ PRBool result=PR_FALSE; if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_userdefined)){ - result=TestBits(gHTMLElements[aTag].mParentBits,kInline); + result=TestBits(gHTMLElements[aTag].mParentBits,kInlineEntity); } return result; } @@ -1304,11 +1316,11 @@ PRBool nsHTMLElement::IsInlineElement(eHTMLTags aTag){ * @param * @return */ -PRBool nsHTMLElement::IsFlowElement(eHTMLTags aTag){ +PRBool nsHTMLElement::IsFlowEntity(eHTMLTags aTag){ PRBool result=PR_FALSE; if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_userdefined)){ - result=TestBits(gHTMLElements[aTag].mParentBits,kFlow); + result=TestBits(gHTMLElements[aTag].mParentBits,kFlowEntity); } return result; } @@ -1322,7 +1334,7 @@ PRBool nsHTMLElement::IsFlowElement(eHTMLTags aTag){ PRBool nsHTMLElement::IsBlockParent(eHTMLTags aTag){ PRBool result=PR_FALSE; if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_userdefined)){ - result=TestBits(gHTMLElements[aTag].mInclusionBits,kBlock); + result=TestBits(gHTMLElements[aTag].mInclusionBits,kBlockEntity); } return result; } @@ -1337,7 +1349,7 @@ PRBool nsHTMLElement::IsBlockParent(eHTMLTags aTag){ PRBool nsHTMLElement::IsInlineParent(eHTMLTags aTag){ PRBool result=PR_FALSE; if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_userdefined)){ - result=TestBits(gHTMLElements[aTag].mInclusionBits,kInline); + result=TestBits(gHTMLElements[aTag].mInclusionBits,kInlineEntity); } return result; } @@ -1352,7 +1364,7 @@ PRBool nsHTMLElement::IsInlineParent(eHTMLTags aTag){ PRBool nsHTMLElement::IsFlowParent(eHTMLTags aTag){ PRBool result=PR_FALSE; if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_userdefined)){ - result=TestBits(gHTMLElements[aTag].mInclusionBits,kFlow); + result=TestBits(gHTMLElements[aTag].mInclusionBits,kFlowEntity); } return result; } @@ -1399,8 +1411,34 @@ PRBool nsHTMLElement::CanContain(eHTMLTags aParent,eHTMLTags aChild){ * @param * @return */ -PRBool nsHTMLElement::CanOmitEndTag(eHTMLTags aParent) const{ - PRBool result=TestBits(mSpecialProperties,kOmitEndTag); +PRBool nsHTMLElement::CanExclude(eHTMLTags aChild) const{ + PRBool result=PR_FALSE; + + //Note that special kids takes precedence over exclusions... + if(mSpecialKids) { + if(mSpecialKids->Contains(aChild)) { + return PR_FALSE; + } + } + + if(eHTMLTag_unknown!=mExclusionBits){ + if(gHTMLElements[aChild].IsMemberOf(mExclusionBits)) { + result=PR_TRUE; + } + } + return result; +} + +/** + * + * @update gess 01/04/99 + * @param + * @return + */ +PRBool nsHTMLElement::CanOmitEndTag(void) const{ + PRBool result=!IsContainer(mTagID); + if(!result) + result=TestBits(mSpecialProperties,kOmitEndTag); return result; } @@ -1476,7 +1514,8 @@ PRBool nsHTMLElement::IsHeadingTag(eHTMLTags aChild) { * @return */ PRBool nsHTMLElement::CanContainType(PRInt32 aType) const{ - PRBool result=(aType && TestBits(mInclusionBits,aType)); + PRInt32 answer=mInclusionBits & aType; + PRBool result=PRBool(0!=answer); return result; } @@ -1515,11 +1554,79 @@ PRBool nsHTMLElement::IsTextTag(eHTMLTags aChild) { return result; } -PRBool nsHTMLElement::CanContainSelf() const { +/** + * + * @update gess12/13/98 + * @param + * @return + */ +PRBool nsHTMLElement::CanContainSelf(void) const { PRBool result=PRBool(TestBits(mInclusionBits,kSelf)!=0); return result; } +/** + * + * @update gess12/13/98 + * @param + * @return + */ +eHTMLTags nsHTMLElement::GetCloseTargetForEndTag(nsEntryStack& aTagStack,PRInt32 anIndex) const{ + eHTMLTags result=eHTMLTag_unknown; + + int theCount=aTagStack.GetCount(); + int theIndex=theCount; + if(IsMemberOf(kPhrase)){ + while((--theIndex>=anIndex) && (eHTMLTag_unknown==result)){ + eHTMLTags theTag=aTagStack.TagAt(theIndex); + if(theTag!=mTagID) { + //phrasal elements can close other phrasals, along with fontstyle and special tags... + if(!gHTMLElements[theTag].IsMemberOf(kSpecial|kFontStyle|kPhrase)) { + break; //it's not something I can close + } + } + else { + result=theTag; //stop because you just found yourself on the stack + break; + } + } + } + else if(IsMemberOf(kSpecial)){ + while((--theIndex>=anIndex) && (eHTMLTag_unknown==result)){ + eHTMLTags theTag=aTagStack.TagAt(theIndex); + if(theTag!=mTagID) { + //phrasal elements can close other phrasals, along with fontstyle and special tags... + if(gHTMLElements[theTag].IsMemberOf(kSpecial) || + gHTMLElements[theTag].IsMemberOf(kFontStyle)){ + } + else { + break; //it's not something I can close + } + } + else { + result=theTag; //stop because you just found yourself on the stack + break; + } + } + } + else if(IsMemberOf(kFormControl|kExtensions)){ + while((--theIndex>=anIndex) && (eHTMLTag_unknown==result)){ + eHTMLTags theTag=aTagStack.TagAt(theIndex); + if(theTag!=mTagID) { + if(!CanContain(theTag)) { + break; //it's not something I can close + } + } + else { + result=theTag; //stop because you just found yourself on the stack + break; + } + } + } + return result; +} + + /** * See whether this tag can DIRECTLY contain the given child. * @update gess12/13/98 @@ -1541,13 +1648,13 @@ PRBool nsHTMLElement::CanContain(eHTMLTags aChild) const{ } - if(nsHTMLElement::IsInlineElement(aChild)){ + if(nsHTMLElement::IsInlineEntity(aChild)){ if(nsHTMLElement::IsInlineParent(mTagID)){ return PR_TRUE; } } - if(nsHTMLElement::IsFlowElement(aChild)) { + if(nsHTMLElement::IsFlowEntity(aChild)) { if(nsHTMLElement::IsFlowParent(mTagID)){ return PR_TRUE; } @@ -1559,7 +1666,7 @@ PRBool nsHTMLElement::CanContain(eHTMLTags aChild) const{ } } - if(nsHTMLElement::IsBlockElement(aChild)){ + if(nsHTMLElement::IsBlockEntity(aChild)){ if(nsHTMLElement::IsBlockParent(mTagID) || IsStyleTag(mTagID)){ return PR_TRUE; } @@ -1595,3 +1702,151 @@ PRBool nsHTMLElement::HasSpecialProperty(PRInt32 aProperty) const{ return result; } +void nsHTMLElement::DebugDumpContainment(const char* aFilename,const char* aTitle){ + + PRBool t=CanContain(eHTMLTag_address,eHTMLTag_object); + + const char* prefix=" "; + fstream out(aFilename,ios::out); + out << "==================================================" << endl; + out << aTitle << endl; + out << "=================================================="; + int i,j=0; + int written; + int linenum=5; + for(i=1;i" << endl; + out << prefix; + linenum+=3; + written=0; + char startChar=0; + if(IsContainer((eHTMLTags)i)) { + for(j=1;j"); - - CTokenRecycler* theRecycler=(CTokenRecycler*)GetTokenRecycler(); - aToken=theRecycler->CreateTokenOfType(eToken_skippedcontent,aChildTag,endTag); - return aToken->Consume(aChar,aScanner); //tell new token to finish consuming text... -} - -/** - * + * 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. * @update gess12/28/98 * @param * @return */ -nsresult nsHTMLTokenizer::HandleSkippedContent(nsScanner& aScanner,CToken*& aToken) { +nsresult nsHTMLTokenizer::ConsumeScriptContent(nsScanner& aScanner,CToken*& aToken) { nsresult result=NS_OK; - eHTMLTags theTag=(eHTMLTags)aToken->GetTypeID(); - if(eHTMLTag_unknown!=gHTMLElements[theTag].mSkipTarget) { - - //Do special case handling for "); + CTokenRecycler* theRecycler=(CTokenRecycler*)GetTokenRecycler(); + CToken* textToken=theRecycler->CreateTokenOfType(eToken_text,theTag,endTag); + result=((CTextToken*)textToken)->ConsumeUntil(0,aScanner,endTag); //tell new token to finish consuming text... + AddToken(textToken,result,mTokenDeque,theRecycler); + CToken* endToken=theRecycler->CreateTokenOfType(eToken_end,theTag); + AddToken(endToken,result,mTokenDeque,theRecycler); } //EEEEECCCCKKKK!!! diff --git a/mozilla/htmlparser/src/nsHTMLTokenizer.h b/mozilla/htmlparser/src/nsHTMLTokenizer.h index 65a3e96f1a9..3c8a4a12468 100644 --- a/mozilla/htmlparser/src/nsHTMLTokenizer.h +++ b/mozilla/htmlparser/src/nsHTMLTokenizer.h @@ -69,7 +69,7 @@ public: protected: - virtual nsresult HandleSkippedContent(nsScanner& aScanner,CToken*& aToken); + virtual nsresult ConsumeScriptContent(nsScanner& aScanner,CToken*& aToken); virtual nsresult ConsumeTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); virtual nsresult ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); virtual nsresult ConsumeEndTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); @@ -79,7 +79,6 @@ protected: virtual nsresult ConsumeComment(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); virtual nsresult ConsumeNewline(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); virtual nsresult ConsumeText(const nsString& aString,CToken*& aToken,nsScanner& aScanner); - virtual nsresult ConsumeContentToEndTag(PRUnichar aChar,eHTMLTags aChildTag,nsScanner& aScanner,CToken*& aToken); virtual nsresult ConsumeProcessingInstruction(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); static void AddToken(CToken*& aToken,nsresult aResult,nsDeque& aDeque,CTokenRecycler* aRecycler); diff --git a/mozilla/htmlparser/src/nsHTMLTokens.cpp b/mozilla/htmlparser/src/nsHTMLTokens.cpp index d06836445aa..5d11f8a8ff3 100644 --- a/mozilla/htmlparser/src/nsHTMLTokens.cpp +++ b/mozilla/htmlparser/src/nsHTMLTokens.cpp @@ -29,7 +29,6 @@ #include "nsHTMLTags.h" #include "nsHTMLEntities.h" #include "nsCRT.h" -#include "nsStr.h" //#define GESS_MACHINE #ifdef GESS_MACHINE @@ -79,7 +78,6 @@ void CHTMLToken::SetStringValue(const char* name){ } } - /* * constructor from tag id * @@ -272,6 +270,19 @@ void CStartToken::DebugDumpSource(ostream& out) { out << ">"; } +/* + * + * + * @update gess 3/25/98 + * @param anOutputString will recieve the result + * @return nada + */ +void CStartToken::GetSource(nsString& anOutputString){ + anOutputString="<"; + anOutputString+=mTextValue; + if(!mAttributed) + anOutputString+=">"; +} /* * constructor from tag id @@ -303,7 +314,6 @@ CEndToken::CEndToken(const nsString& aName) : CHTMLToken(aName) { * @return error result */ nsresult CEndToken::Consume(PRUnichar aChar, nsScanner& aScanner) { - //if you're here, we've already Consumed the '. @@ -388,6 +398,19 @@ void CEndToken::DebugDumpSource(ostream& out) { out << ""; } +/* + * + * + * @update gess 3/25/98 + * @param anOutputString will recieve the result + * @return nada + */ +void CEndToken::GetSource(nsString& anOutputString){ + anOutputString=""; +} + /* * default constructor * @@ -474,6 +497,70 @@ nsresult CTextToken::Consume(PRUnichar aChar, nsScanner& aScanner) { return result; } +/* + * Consume as much clear text from scanner as possible. + * + * @update gess 3/25/98 + * @param aChar -- last char consumed from stream + * @param aScanner -- controller of underlying input source + * @return error result + */ +nsresult CTextToken::ConsumeUntil(PRUnichar aChar,nsScanner& aScanner,nsString& aTerminalString){ + PRBool done=PR_FALSE; + nsresult result=NS_OK; + nsString temp; + PRUnichar theChar; + + //We're going to try a new algorithm here. Rather than scan for the matching + //end tag like we used to do, we're now going to scan for whitespace and comments. + //If we find either, just eat them. If we find text or a tag, then go to the + //target endtag, or the start of another comment. + + static nsAutoString theWhitespace2("\b\t "); + + while((!done) && (NS_OK==result)) { + result=aScanner.GetChar(aChar); + if((NS_OK==result) && (kLessThan==aChar)) { + //we're reading a tag or a comment... + result=aScanner.GetChar(theChar); + if((NS_OK==result) && (kExclamation==theChar)) { + //read a comment... + static CCommentToken theComment; + result=theComment.Consume(aChar,aScanner); + if(NS_OK==result) { + //result=aScanner.SkipWhitespace(); + //temp.Append(""); + } + } else { + //read a tag... + temp+=aChar; + temp+=theChar; + result=aScanner.ReadUntil(temp,kGreaterThan,PR_TRUE); + } + } + else if(0<=theWhitespace2.BinarySearch(aChar)) { + static CWhitespaceToken theWS; + result=theWS.Consume(aChar,aScanner); + if(NS_OK==result) { + temp.Append(theWS.GetStringValueXXX()); + } + } + else { + temp+=aChar; + result=aScanner.ReadUntil(temp,kLessThan,PR_FALSE); + } + nsAutoString theRight; + temp.Right(theRight,aTerminalString.Length()); + done=PRBool(0==theRight.Compare(aTerminalString,PR_TRUE)); + } //while + int len=temp.Length(); + temp.Truncate(len-aTerminalString.Length()); + mTextValue=temp; + return result; +} + /* * default constructor * @@ -759,14 +846,16 @@ nsresult CCommentToken::Consume(PRUnichar aChar, nsScanner& aScanner) { PRBool theStrictForm=PR_FALSE; nsresult result=(theStrictForm) ? ConsumeStrictComment(aChar,aScanner,mTextValue) : ConsumeComment(aChar,aScanner,mTextValue); +/* //this change is here to make the editor teams' life easier. //I'm removing the leading and trailing markup... -/* + if(0==mTextValue.Find(""; } +/* + * + * + * @update gess 3/25/98 + * @param anOutputString will recieve the result + * @return nada + */ +void CSkippedContentToken::GetSource(nsString& anOutputString){ + anOutputString="$skipped-content"; +} /** * diff --git a/mozilla/htmlparser/src/nsHTMLTokens.h b/mozilla/htmlparser/src/nsHTMLTokens.h index bd01a0a9c7d..a95fa715018 100644 --- a/mozilla/htmlparser/src/nsHTMLTokens.h +++ b/mozilla/htmlparser/src/nsHTMLTokens.h @@ -43,6 +43,7 @@ #include "nsHTMLTags.h" #include "nsParserError.h" #include +#include "nsString.h" class nsScanner; @@ -121,6 +122,8 @@ class CStartToken: public CHTMLToken { PRBool IsEmpty(void); void SetEmpty(PRBool aValue); virtual void DebugDumpSource(ostream& out); + virtual void GetSource(nsString& anOutputString); + virtual void Reinitialize(PRInt32 aTag, const nsString& aString); protected: @@ -145,6 +148,7 @@ class CEndToken: public CHTMLToken { virtual const char* GetClassName(void); virtual PRInt32 GetTokenType(void); virtual void DebugDumpSource(ostream& out); + virtual void GetSource(nsString& anOutputString); }; @@ -184,11 +188,8 @@ class CEntityToken : public CHTMLToken { virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner); static PRInt32 ConsumeEntity(PRUnichar aChar,nsString& aString,nsScanner& aScanner); static PRInt32 TranslateToUnicodeStr(PRInt32 aValue,nsString& aString); -// static PRInt32 FindEntityIndex(nsString& aString); -// static PRInt32 FindEntityIndexMax(const char* aBuffer,PRInt32 aCount=-1); -// static PRBool VerifyEntityTable(void); -// static PRInt32 ReduceEntities(nsString& aString); virtual void DebugDumpSource(ostream& out); + virtual void GetSource(nsString& anOutputString); }; @@ -220,6 +221,7 @@ class CTextToken: public CHTMLToken { CTextToken(); CTextToken(const nsString& aString); virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner); + nsresult ConsumeUntil(PRUnichar aChar,nsScanner& aScanner,nsString& aTerminalString); virtual const char* GetClassName(void); virtual PRInt32 GetTokenType(void); }; @@ -261,6 +263,7 @@ class CAttributeToken: public CHTMLToken { virtual PRInt32 GetTokenType(void); virtual nsString& GetKey(void) {return mTextKey;} virtual void DebugDumpToken(ostream& out); + virtual void GetSource(nsString& anOutputString); virtual void DebugDumpSource(ostream& out); PRBool mLastAttribute; virtual void Reinitialize(PRInt32 aTag, const nsString& aString); @@ -337,6 +340,7 @@ class CSkippedContentToken: public CAttributeToken { virtual const char* GetClassName(void); virtual PRInt32 GetTokenType(void); virtual void DebugDumpSource(ostream& out); + virtual void GetSource(nsString& anOutputString); protected: }; diff --git a/mozilla/htmlparser/src/nsIParser.h b/mozilla/htmlparser/src/nsIParser.h index 13af7417248..3d9210219a5 100644 --- a/mozilla/htmlparser/src/nsIParser.h +++ b/mozilla/htmlparser/src/nsIParser.h @@ -186,6 +186,7 @@ class nsIParser : public nsISupports { * @return ptr to scanner */ virtual eParseMode GetParseMode(void)=0; + }; /* ===========================================================* diff --git a/mozilla/htmlparser/src/nsParser.cpp b/mozilla/htmlparser/src/nsParser.cpp index 6d1f479774a..3c1be67405c 100644 --- a/mozilla/htmlparser/src/nsParser.cpp +++ b/mozilla/htmlparser/src/nsParser.cpp @@ -47,16 +47,8 @@ static const char* kNullURL = "Error: Null URL given"; static const char* kOnStartNotCalled = "Error: OnStartBinding() must be called before OnDataAvailable()"; static const char* kBadListenerInit = "Error: Parser's IStreamListener API was not setup correctly in constructor."; +//------------------------------------------------------------------- -class CTokenDeallocator: public nsDequeFunctor{ -public: - virtual void* operator()(void* anObject) { - CToken* aToken = (CToken*)anObject; - delete aToken; - return 0; - } -}; - class CDTDDeallocator: public nsDequeFunctor{ public: @@ -67,6 +59,8 @@ public: } }; +//------------------------------------------------------------------- + class CDTDFinder: public nsDequeFunctor{ public: CDTDFinder(nsIDTD* aDTD) { @@ -83,6 +77,8 @@ public: nsIDTD* mTargetDTD; }; +//------------------------------------------------------------------- + class CSharedParserObjects { public: @@ -128,14 +124,6 @@ public: nsString nsParser::gHackMetaCharset = ""; nsString nsParser::gHackMetaCharsetURL = ""; -//------------------------------------------------------------------------- - -CSharedParserObjects& GetSharedObjects() { - static CSharedParserObjects gSharedParserObjects; - return gSharedParserObjects; -} - - /********************************************************************************** This class is used as an interface between an external agent (like the DOM) and the parser. It will contain a stack full of tagnames, which is used in our @@ -173,8 +161,13 @@ public: nsDeque mTags; //will hold a deque of prunichars... }; +//------------------------------------------------------------------- -//------------------------------------------------------------------------- + +CSharedParserObjects& GetSharedObjects() { + static CSharedParserObjects gSharedParserObjects; + return gSharedParserObjects; +} /** * default constructor @@ -429,18 +422,28 @@ eParseMode DetermineParseMode(nsParser& aParser) { nsScanner* theScanner=aParser.GetScanner(); if(theScanner){ + nsString theBufCopy; nsString& theBuffer=theScanner->GetBuffer(); - PRInt32 theIndex=theBuffer.Find("HTML 4.0"); - if(kNotFound==theIndex) - theIndex=theBuffer.Find("html 4.0"); - if(kNotFound' + PRInt32 theSubIndex=theBufCopy.Find(kGreaterThan,theIndex+1); + theBufCopy.Truncate(theSubIndex); + theSubIndex=theBufCopy.Find("HTML 4.0"); + if(kNotFoundmKey!=aKey)) { @@ -1176,6 +1179,7 @@ void nsParser::DebugDumpSource(ostream& aStream) { } } + /** * Call this to get a newly constructed tagstack * @update gess 5/05/99 @@ -1188,3 +1192,4 @@ nsresult nsParser::CreateTagStack(nsITagStack** aTagStack){ return NS_OK; return NS_ERROR_HTMLPARSER_MEMORYFAILURE; } + diff --git a/mozilla/htmlparser/src/nsParser.h b/mozilla/htmlparser/src/nsParser.h index 78a4da0e0a3..32e5c467545 100644 --- a/mozilla/htmlparser/src/nsParser.h +++ b/mozilla/htmlparser/src/nsParser.h @@ -69,7 +69,7 @@ class nsIHTMLContentSink; class nsIDTD; class nsScanner; class nsIParserFilter; -class nsTagStack; + #include @@ -165,7 +165,7 @@ friend class CTokenHandler; * @param aListener is a listener to forward notifications to * @return TRUE if all went well -- FALSE otherwise */ - virtual nsresult Parse(nsIURL* aURL,nsIStreamObserver* aListener,PRBool aEnableVerify=PR_FALSE, void* aKey=0); + virtual nsresult Parse(nsIURL* aURL,nsIStreamObserver* aListener,PRBool aEnableVerify=PR_FALSE,void* aKey=0); /** * Cause parser to parse input from given stream @@ -173,7 +173,7 @@ friend class CTokenHandler; * @param aStream is the i/o source * @return TRUE if all went well -- FALSE otherwise */ - virtual nsresult Parse(nsIInputStream& aStream,PRBool aEnableVerify=PR_FALSE, void* aKey=0); + virtual nsresult Parse(nsIInputStream& aStream,PRBool aEnableVerify=PR_FALSE,void* aKey=0); /** * @update gess5/11/98 @@ -183,7 +183,6 @@ friend class CTokenHandler; */ virtual nsresult Parse(nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify=PR_FALSE,PRBool aLastCall=PR_FALSE); - virtual PRBool IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType); virtual nsresult ParseFragment(nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType); diff --git a/mozilla/htmlparser/src/nsParserNode.cpp b/mozilla/htmlparser/src/nsParserNode.cpp index 158c9066b9b..2389ae29686 100644 --- a/mozilla/htmlparser/src/nsParserNode.cpp +++ b/mozilla/htmlparser/src/nsParserNode.cpp @@ -40,13 +40,13 @@ nsAutoString& GetEmptyString() { * @param aToken -- token to init internal token * @return */ -nsCParserNode::nsCParserNode(CToken* aToken,PRInt32 aLineNumber,nsITokenRecycler* aRecycler): nsIParserNode() { +nsCParserNode::nsCParserNode(CToken* aToken,PRInt32 aLineNumber,nsITokenRecycler* aRecycler): + nsIParserNode(), mSkippedContent("") { NS_INIT_REFCNT(); mAttributeCount=0; mLineNumber=aLineNumber; mToken=aToken; memset(mAttributes,0,sizeof(mAttributes)); - mSkippedContent=0; mRecycler=aRecycler; } @@ -65,8 +65,6 @@ nsCParserNode::~nsCParserNode() { for(index=0;indexRecycleToken(mAttributes[index]); } - if(mSkippedContent) - mRecycler->RecycleToken(mSkippedContent); } } @@ -141,21 +139,6 @@ void nsCParserNode::AddAttribute(CToken* aToken) { } } -/** - * This method gets called when the parser encounters - * skipped content after a start token. - * - * @update gess 3/26/98 - * @param aToken -- really a skippedcontent token - * @return nada - */ -void nsCParserNode::SetSkippedContent(CToken* aToken){ - if(aToken) { - NS_ASSERTION(eToken_skippedcontent == aToken->GetTokenType(), "not a skipped content token"); - mSkippedContent = aToken; - } -} - /** * Gets the name of this node. Currently unused. @@ -191,10 +174,19 @@ const nsString& nsCParserNode::GetText() const { * @return string ref of text from internal token */ const nsString& nsCParserNode::GetSkippedContent() const { - if (nsnull != mSkippedContent) { - return ((CSkippedContentToken*)mSkippedContent)->GetKey(); - } - return GetEmptyString(); + return mSkippedContent; +} + +/** + * Get text value of this node, which translates into + * getting the text value of the underlying token + * + * @update gess 3/25/98 + * @param + * @return string ref of text from internal token + */ +void nsCParserNode::SetSkippedContent(nsString& aString) { + mSkippedContent=aString; } /** @@ -303,5 +295,3 @@ CToken* nsCParserNode::PopAttributeToken() } return nsnull; } - - diff --git a/mozilla/htmlparser/src/nsParserNode.h b/mozilla/htmlparser/src/nsParserNode.h index 7902a8e4fdc..359760cc42b 100644 --- a/mozilla/htmlparser/src/nsParserNode.h +++ b/mozilla/htmlparser/src/nsParserNode.h @@ -90,6 +90,13 @@ class nsCParserNode : public nsIParserNode { */ virtual const nsString& GetSkippedContent() const; + /** + * Retrieve skipped context from node + * @update gess5/11/98 + * @return string containing skipped content + */ + virtual void SetSkippedContent(nsString& aString); + /** * Retrieve the type of the parser node. * @update gess5/11/98 @@ -148,14 +155,6 @@ class nsCParserNode : public nsIParserNode { */ virtual void AddAttribute(CToken* aToken); - /** - * - * @update gess5/11/98 - * @param - * @return - */ - virtual void SetSkippedContent(CToken* aToken); - /** * This getter retrieves the line number from the input source where * the token occured. Lines are interpreted as occuring between \n characters. @@ -169,15 +168,14 @@ class nsCParserNode : public nsIParserNode { * @return token at anIndex */ virtual CToken* PopAttributeToken(); - - protected: - PRUint32 mAttributeCount; - PRInt32 mLineNumber; - CToken* mToken; - CToken* mAttributes[eMaxAttr]; // XXX Ack! This needs to be dynamic! - CToken* mSkippedContent; - nsITokenRecycler* mRecycler; + protected: + PRUint32 mAttributeCount; + PRInt32 mLineNumber; + CToken* mToken; + CToken* mAttributes[eMaxAttr]; // XXX Ack! This needs to be dynamic! + nsAutoString mSkippedContent; + nsITokenRecycler* mRecycler; }; #endif diff --git a/mozilla/htmlparser/src/nsToken.cpp b/mozilla/htmlparser/src/nsToken.cpp index 5f11070d596..0c72ee21a59 100644 --- a/mozilla/htmlparser/src/nsToken.cpp +++ b/mozilla/htmlparser/src/nsToken.cpp @@ -153,6 +153,16 @@ nsString& CToken::GetStringValueXXX(void) { return mTextValue; } +/** + * Get string of full contents, suitable for debug dump. + * It should look exactly like the input source. + * @update gess5/11/98 + * @return reference to string containing string value + */ +void CToken::GetSource(nsString& anOutputString){ + anOutputString=mTextValue; +} + /** * This method retrieves the value of this internal string * as a cstring. diff --git a/mozilla/htmlparser/src/nsToken.h b/mozilla/htmlparser/src/nsToken.h index f9a28db1e4a..a5c52724d56 100644 --- a/mozilla/htmlparser/src/nsToken.h +++ b/mozilla/htmlparser/src/nsToken.h @@ -98,6 +98,14 @@ class CToken { */ virtual nsString& GetStringValueXXX(void); + /** + * Get string of full contents, suitable for debug dump. + * It should look exactly like the input source. + * @update gess5/11/98 + * @return reference to string containing string value + */ + virtual void GetSource(nsString& anOutputString); + /** * Setter method that changes the string value of this token * @update gess5/11/98 diff --git a/mozilla/htmlparser/src/nsViewSourceHTML.cpp b/mozilla/htmlparser/src/nsViewSourceHTML.cpp index 1c327085dd1..5747feb8bec 100644 --- a/mozilla/htmlparser/src/nsViewSourceHTML.cpp +++ b/mozilla/htmlparser/src/nsViewSourceHTML.cpp @@ -526,14 +526,15 @@ nsresult CViewSourceHTML::WriteText(const nsString& aTextString,nsIContentSink& temp=""; break; case kSpace: - if((PR_TRUE==aPreserveSpace) && (kSpace==aTextString.CharAt(theOffset+1))) { - if(temp.Length()) - result=aSink.AddLeaf(theTextNode); //just dump the whole string... - WriteNBSP(1,aSink); - temp=""; - break; - } - //fall through... + if((PR_TRUE==aPreserveSpace)) { + if(aTextString.Length() > theOffset+1 && (kSpace==aTextString.CharAt(theOffset+1))) { + if(temp.Length()) + result=aSink.AddLeaf(theTextNode); //just dump the whole string... + WriteNBSP(1,aSink); + temp=""; + break; + } + } //fall through... default: //scan ahead looking for valid chars... temp+=aTextString.CharAt(theOffset); @@ -751,7 +752,7 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) { case eToken_text: { nsString& theText=aToken->GetStringValueXXX(); - WriteText(theText,*mSink,PR_FALSE); + WriteText(theText,*mSink,PR_TRUE); } break; @@ -801,8 +802,8 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) { CToken* theNextToken = mTokenizer->PopToken(); if(theNextToken) { theType=eHTMLTokenTypes(theNextToken->GetTokenType()); - if(eToken_skippedcontent==theType) { - attrNode.SetSkippedContent(theNextToken); + if(eToken_text==theType) { + attrNode.SetSkippedContent(theNextToken->GetStringValueXXX()); } } result= OpenHead(attrNode); @@ -813,7 +814,7 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) { if(NS_OK==result) result=CloseHead(attrNode); } - nsString& theText=((CAttributeToken*)theNextToken)->GetKey(); + const nsString& theText=attrNode.GetSkippedContent(); WriteText(theText,*mSink,PR_FALSE); } break; diff --git a/mozilla/htmlparser/src/nsWellFormedDTD.cpp b/mozilla/htmlparser/src/nsWellFormedDTD.cpp index 573638c3a02..9b6967cb762 100644 --- a/mozilla/htmlparser/src/nsWellFormedDTD.cpp +++ b/mozilla/htmlparser/src/nsWellFormedDTD.cpp @@ -114,8 +114,6 @@ NS_IMPL_ADDREF(CWellFormedDTD) NS_IMPL_RELEASE(CWellFormedDTD) -//static CTokenDeallocator gTokenKiller; - /** * Default constructor * diff --git a/mozilla/htmlparser/src/nsXIFDTD.cpp b/mozilla/htmlparser/src/nsXIFDTD.cpp index f9b9ee62228..562270781f8 100644 --- a/mozilla/htmlparser/src/nsXIFDTD.cpp +++ b/mozilla/htmlparser/src/nsXIFDTD.cpp @@ -1736,11 +1736,7 @@ void nsXIFDTD::EndCSSStyleSheet(const nsIParserNode& aNode) mBuffer.Append(""); - CSkippedContentToken* skipped = new CSkippedContentToken(mBuffer); - nsString& key = skipped->GetKey(); - key = mBuffer; - - startNode.SetSkippedContent(skipped); + startNode.SetSkippedContent(mBuffer); mSink->AddLeaf(startNode); } diff --git a/mozilla/parser/htmlparser/src/CNavDTD.cpp b/mozilla/parser/htmlparser/src/CNavDTD.cpp index 51423c34963..e197401d45e 100644 --- a/mozilla/parser/htmlparser/src/CNavDTD.cpp +++ b/mozilla/parser/htmlparser/src/CNavDTD.cpp @@ -44,6 +44,7 @@ #endif #include "prmem.h" +#undef ENABLE_RESIDUALSTYLE #define RICKG_DEBUG 0 #ifdef RICKG_DEBUG #include @@ -162,7 +163,6 @@ public: //CTagHandlerRegister gTagHandlerRegister; - /************************************************************************ And now for the main class -- CNavDTD... ************************************************************************/ @@ -257,8 +257,6 @@ PRInt32 NavDispatchTokenHandler(CToken* aToken,nsIDTD* aDTD) { result=theDTD->HandleAttributeToken(aToken); break; case eToken_style: result=theDTD->HandleStyleToken(aToken); break; - case eToken_skippedcontent: - result=theDTD->HandleSkippedContentToken(aToken); break; case eToken_instruction: result=theDTD->HandleProcessingInstructionToken(aToken); break; default: @@ -337,7 +335,7 @@ void CNavDTD::DeleteTokenHandlers(void) { * @param * @return */ -CNavDTD::CNavDTD() : nsIDTD(), mMisplacedContent(0) { +CNavDTD::CNavDTD() : nsIDTD(), mMisplacedContent(0), mSkippedContent(0) { NS_INIT_REFCNT(); mSink = 0; mParser=0; @@ -358,6 +356,11 @@ CNavDTD::CNavDTD() : nsIDTD(), mMisplacedContent(0) { mExpectedCRC32=0; mSaveBadTokens = PR_FALSE; // DebugDumpContainmentRules2(*this,"c:/temp/DTDRules.new","New CNavDTD Containment Rules"); +#ifdef RICKG_DEBUG + nsHTMLElement::DebugDumpContainment("c:/temp/rules.new","ElementTable Rules"); + nsHTMLElement::DebugDumpMembership("c:/temp/table.out"); + nsHTMLElement::DebugDumpContainType("c:/temp/ctnrules.out"); +#endif } @@ -477,7 +480,7 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,PRBool aNotifySink,nsString #endif result = mSink->WillBuildModel(); - + mSkipTarget=eHTMLTag_unknown; mComputedCRC32=0; mExpectedCRC32=0; } @@ -498,6 +501,7 @@ CTokenRecycler* gRecycler=0; nsresult CNavDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsITokenObserver* anObserver,nsIContentSink* aSink) { nsresult result=NS_OK; + NS_ADDREF(aSink); if(aTokenizer) { nsITokenizer* oldTokenizer=mTokenizer; mTokenizer=aTokenizer; @@ -514,6 +518,7 @@ nsresult CNavDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsIToke mTokenizer=oldTokenizer; } else result=NS_ERROR_HTMLPARSER_BADTOKENIZER; + NS_IF_RELEASE(aSink); return result; } @@ -581,7 +586,6 @@ nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParse return result; } - /** * This big dispatch method is used to route token handler calls to the right place. * What's wrong with it? This table, and the dispatch methods themselves need to be @@ -593,50 +597,93 @@ nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParse * @return */ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){ - nsresult result=NS_OK; + nsresult result=NS_OK; if(aToken) { CHTMLToken* theToken= (CHTMLToken*)(aToken); eHTMLTokenTypes theType=eHTMLTokenTypes(theToken->GetTokenType()); eHTMLTags theTag=(eHTMLTags)theToken->GetTypeID(); + PRBool execSkipContent=PR_FALSE; - static eHTMLTags passThru[]= {eHTMLTag_html,eHTMLTag_comment,eHTMLTag_newline,eHTMLTag_whitespace,eHTMLTag_script}; - if(!FindTagInSet(theTag,passThru,sizeof(passThru)/sizeof(eHTMLTag_unknown))){ - if(!gHTMLElements[eHTMLTag_html].SectionContains(theTag,PR_FALSE)) { - if(!mHadBodyOrFrameset){ - if(mHasOpenHead) { - //just fall through and handle current token - if(!gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag)){ - mMisplacedContent.Push(aToken); - return result; + /* --------------------------------------------------------------------------------- + To understand this little piece of code, you need to look below too. + In essence, this code caches "skipped content" until we find a given skiptarget. + Once we find the skiptarget, we take all skipped content up to that point and + coallate it. Then we push those tokens back onto the tokenizer deque. + --------------------------------------------------------------------------------- + */ + if(mSkipTarget){ //handle a preexisting target... + if((theTag==mSkipTarget) && (eToken_end==theType)){ + mSkipTarget=eHTMLTag_unknown; //stop skipping. + //mTokenizer->PushTokenFront(aToken); //push the end token... + execSkipContent=PR_TRUE; + gRecycler->RecycleToken(aToken); + theToken=(CHTMLToken*)mSkippedContent.PopFront(); + // result=HandleStartToken(theToken); + } + else { + mSkippedContent.Push(theToken); + return result; + } + } + + /* --------------------------------------------------------------------------------- + This section of code is used to "move" misplaced content from one location in + our document model to another. (Consider what would happen if we found a

tag + and text in the head.) To move content, we throw it onto the misplacedcontent + deque until we can deal with it. + --------------------------------------------------------------------------------- + */ + if(!execSkipContent) { + static eHTMLTags passThru[]= {eHTMLTag_html,eHTMLTag_comment,eHTMLTag_newline,eHTMLTag_whitespace,eHTMLTag_script}; + if(!FindTagInSet(theTag,passThru,sizeof(passThru)/sizeof(eHTMLTag_unknown))){ + if(!gHTMLElements[eHTMLTag_html].SectionContains(theTag,PR_FALSE)) { + if(!mHadBodyOrFrameset){ + if(mHasOpenHead) { + //just fall through and handle current token + if(!gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag)){ + mMisplacedContent.Push(aToken); + return result; + } } - } - else { - if(gHTMLElements[eHTMLTag_body].SectionContains(theTag,PR_TRUE)){ - mTokenizer->PushTokenFront(aToken); //put this token back... - mTokenizer->PrependTokens(mMisplacedContent); //push misplaced content - theToken=(CHTMLToken*)gRecycler->CreateTokenOfType(eToken_start,eHTMLTag_body); - //now open a body... + else { + if(gHTMLElements[eHTMLTag_body].SectionContains(theTag,PR_TRUE)){ + mTokenizer->PushTokenFront(aToken); //put this token back... + mTokenizer->PrependTokens(mMisplacedContent); //push misplaced content + theToken=(CHTMLToken*)gRecycler->CreateTokenOfType(eToken_start,eHTMLTag_body); + //now open a body... + } } - } - } + } + } } } if(theToken){ - CITokenHandler* theHandler=GetTokenHandler(theType); - if(theHandler) { - mParser=(nsParser*)aParser; - result=(*theHandler)(theToken,this); - if(NS_SUCCEEDED(result) || (NS_ERROR_HTMLPARSER_BLOCK==result)) { - gRecycler->RecycleToken(theToken); - } - else if(NS_ERROR_HTMLPARSER_MISPLACED!=result) - mTokenizer->PushTokenFront(theToken); - else result=NS_OK; - if (mDTDDebug) { - //mDTDDebug->Verify(this, mParser, mBodyContext->GetCount(), mBodyContext->mStack, mFilename); - } + //Before dealing with the token normally, we need to deal with skip targets + if((!execSkipContent) && + (theType!=eToken_end) && + (eHTMLTag_unknown==mSkipTarget) && + (gHTMLElements[theTag].mSkipTarget)){ //create a new target + mSkipTarget=gHTMLElements[theTag].mSkipTarget; + mSkippedContent.Push(theToken); + } + else { + + CITokenHandler* theHandler=GetTokenHandler(theType); + if(theHandler) { + mParser=(nsParser*)aParser; + result=(*theHandler)(theToken,this); + if(NS_SUCCEEDED(result) || (NS_ERROR_HTMLPARSER_BLOCK==result)) { + gRecycler->RecycleToken(theToken); + } + else if(NS_ERROR_HTMLPARSER_MISPLACED!=result) + mTokenizer->PushTokenFront(theToken); + else result=NS_OK; + if (mDTDDebug) { + //mDTDDebug->Verify(this, mParser, mBodyContext->GetCount(), mBodyContext->mStack, mFilename); + } + } //if } } @@ -678,51 +725,38 @@ nsresult CNavDTD::ReleaseTokenPump(nsITagHandler* aHandler){ nsresult CNavDTD::DidHandleStartTag(nsCParserNode& aNode,eHTMLTags aChildTag){ nsresult result=NS_OK; - CToken* theNextToken=mTokenizer->PeekToken(); - if(theNextToken){ - switch(aChildTag){ - case eHTMLTag_body: - case eHTMLTag_frameset: - mHadBodyOrFrameset=PR_TRUE; - break; + switch(aChildTag){ + case eHTMLTag_body: + case eHTMLTag_frameset: + mHadBodyOrFrameset=PR_TRUE; + break; - - case eHTMLTag_pre: - case eHTMLTag_listing: - { - if(theNextToken) { - eHTMLTokenTypes theType=eHTMLTokenTypes(theNextToken->GetTokenType()); - if(eToken_newline==theType){ - - switch(aChildTag){ - case eHTMLTag_pre: - case eHTMLTag_listing: - //we skip the first newline token inside PRE and LISTING - mTokenizer->PopToken(); - break; - default: - break; - }//switch - - }//if + case eHTMLTag_pre: + case eHTMLTag_listing: + { + CToken* theNextToken=mTokenizer->PeekToken(); + if(theNextToken) { + eHTMLTokenTypes theType=eHTMLTokenTypes(theNextToken->GetTokenType()); + if(eToken_newline==theType){ + mTokenizer->PopToken(); //skip 1st newline inside PRE and LISTING }//if - } - break; + }//if + } + break; - case eHTMLTag_plaintext: - case eHTMLTag_xmp: - //grab the skipped content and dump it out as text... - { - const nsString& theText=aNode.GetSkippedContent(); - if(0=0;i--){ if(aTagStack[i]==aTag) return i; @@ -745,6 +779,41 @@ PRInt32 GetTopmostIndexOf(eHTMLTags aTag,nsEntryStack& aTagStack) { return kNotFound; } +/** + * This method is called to determine whether or not a START tag + * can be autoclosed. This means that based on the current + * context, the stack should be closed to the nearest matching + * tag. + * + * @param aTag -- tag enum of child to be tested + * @return index of tag to be closed + */ +static PRInt32 FindAutoCloseTargetForStartTag2(eHTMLTags aChild,nsEntryStack& aTagStack,CNavDTD& aDTD) { + PRInt32 max=aTagStack.GetCount(); + + if(nsHTMLElement::IsContainer(aChild)){ + PRInt32 index=max; + CTagList* theRootTags=gHTMLElements[aChild].GetRootTags(); + + while(--index>=0){ + eHTMLTags thePrevTag=aTagStack.TagAt(index); + + if((theRootTags) && (theRootTags->Contains(thePrevTag))) { + return index+1; + } + + if(aDTD.CanOmit(thePrevTag,aChild)){ + return index+1; + } + + if(aDTD.CanContain(thePrevTag,aChild)){ + return index+1; + } + } + } + return max; //which means don't close anything... +} + /** * This method is called to determine whether or not a START tag @@ -757,19 +826,17 @@ PRInt32 GetTopmostIndexOf(eHTMLTags aTag,nsEntryStack& aTagStack) { */ static eHTMLTags FindAutoCloseTargetForStartTag(eHTMLTags aCurrentTag,nsEntryStack& aTagStack) { - int theTopIndex = aTagStack.GetSize(); + int theTopIndex = aTagStack.GetCount(); eHTMLTags thePrevTag=aTagStack.Last(); if(nsHTMLElement::IsContainer(aCurrentTag)){ if(thePrevTag==aCurrentTag) { return (gHTMLElements[aCurrentTag].CanContainSelf()) ? eHTMLTag_unknown: aCurrentTag; } - if(nsHTMLElement::IsBlockCloser(aCurrentTag)) { - - PRInt32 theRootIndex=kNotFound; - CTagList* theRootTags=gHTMLElements[aCurrentTag].GetRootTags(); + CTagList* theRootTags=gHTMLElements[aCurrentTag].GetRootTags(); + PRInt32 theRootIndex=(theRootTags) ? theRootTags->GetTopmostIndexOf(aTagStack) : kNotFound; + if(nsHTMLElement::IsBlockCloser(aCurrentTag)) { if(theRootTags) { - theRootIndex=theRootTags->GetTopmostIndexOf(aTagStack); CTagList* theStartTags=gHTMLElements[aCurrentTag].GetAutoCloseStartTags(); PRInt32 thePeerIndex=kNotFound; if(theStartTags){ @@ -798,15 +865,14 @@ eHTMLTags FindAutoCloseTargetForStartTag(eHTMLTags aCurrentTag,nsEntryStack& aTa } //if } //if }//if - else if(kNotFound

<-

- while((theRootIndex<--theTopIndex) && (!gHTMLElements[aTagStack[theTopIndex]].CanContain(aCurrentTag))) { - } - return aTagStack[theTopIndex+1]; - //return aTagStack.mTags[theRootIndex+1]; + } //if isblockcloser + if(kNotFound

<-

+ while((theRootIndex<--theTopIndex) && (!gHTMLElements[aTagStack[theTopIndex]].CanContain(aCurrentTag))) { } - - } //if + return aTagStack[theTopIndex+1]; + //return aTagStack.mTags[theRootIndex+1]; + } //else } //if return eHTMLTag_unknown; } @@ -856,25 +922,30 @@ PRBool CanBeContained(eHTMLTags aParentTag,eHTMLTags aChildTag,nsEntryStack& aTa //Note: This method is going away. First we need to get the elementtable to do closures right, and // therefore we must get residual style handling to work. +/* // I've removed this on general principle. + // If style tags want to contain each other, the state should be in the element table. + if(nsHTMLElement::IsStyleTag(aParentTag)) if(nsHTMLElement::IsStyleTag(aChildTag)) return PR_TRUE; +*/ - CTagList* theRootTags=gHTMLElements[aChildTag].GetRootTags(); - if(theRootTags) { - PRInt32 theRootIndex=theRootTags->GetTopmostIndexOf(aTagStack); - PRInt32 theChildIndex=GetIndexOfChildOrSynonym(aTagStack,aChildTag); - PRInt32 theBaseIndex=(theRootIndexGetTopmostIndexOf(aTagStack); + PRInt32 theChildIndex=GetIndexOfChildOrSynonym(aTagStack,aChildTag); - if((theRootIndex==theChildIndex) && (gHTMLElements[aChildTag].CanContainSelf())) - result=PR_TRUE; - else result=PRBool(theRootIndex>theChildIndex); + if((theRootIndex==theChildIndex) && (gHTMLElements[aChildTag].CanContainSelf())) + result=PR_TRUE; + else result=PRBool(theRootIndex>theChildIndex); + } } + return result; } - /** * This method gets called when a start token has been * encountered in the parse process. If the current container @@ -892,6 +963,77 @@ PRBool CanBeContained(eHTMLTags aParentTag,eHTMLTags aChildTag,nsEntryStack& aTa nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsIParserNode& aNode) { NS_PRECONDITION(0!=aToken,kNullToken); + nsresult result=NS_OK; + + PRBool theCanContainResult=PR_FALSE; + PRBool theChildAgrees=PR_TRUE; + + do { + + eHTMLTags theParentTag=mBodyContext->Last(); + if(CanOmit(theParentTag,aChildTag)){ + //call handleOmittedTag()... + return result; + } + + theCanContainResult=CanContain(theParentTag,aChildTag); + theChildAgrees=PR_TRUE; + if(theCanContainResult) { + + eHTMLTags theAncestor=gHTMLElements[aChildTag].mExcludingAncestor; + if(eHTMLTag_unknown!=theAncestor){ + theChildAgrees=!HasOpenContainer(theAncestor); + } + + if(theChildAgrees){ + theAncestor=gHTMLElements[aChildTag].mRequiredAncestor; + if(eHTMLTag_unknown!=theAncestor){ + theChildAgrees=HasOpenContainer(theAncestor); + } + } + } + + if(!(theCanContainResult && theChildAgrees)) { + if (!CanPropagate(theParentTag,aChildTag)) { + if(nsHTMLElement::IsContainer(aChildTag)){ + CloseTopmostContainer(); //drastic measures, to be sure! + }//if + else break; + }//if + else CreateContextStackFor(aChildTag); + }//if + } while(!(theCanContainResult && theChildAgrees)); + + + if(nsHTMLElement::IsContainer(aChildTag)){ + result=OpenContainer(aNode,PR_TRUE); + } + else { //we're writing a leaf... + result=AddLeaf(aNode); + } + + return result; +} + +#if 0 +/** + * This method gets called when a start token has been + * encountered in the parse process. If the current container + * can contain this tag, then add it. Otherwise, you have + * two choices: 1) create an implicit container for this tag + * to be stored in + * 2) close the top container, and add this to + * whatever container ends up on top. + * + * @update gess 3/25/98 + * @param aToken -- next (start) token to be handled + * @param aNode -- CParserNode representing this start token + * @return PR_TRUE if all went well; PR_FALSE if error occured + */ + +nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsIParserNode& aNode) { + NS_PRECONDITION(0!=aToken,kNullToken); + nsresult result=NS_OK; //Sick as it sounds, I have to make sure the body has been @@ -899,21 +1041,8 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI PRBool rickgSkip=PR_FALSE; if(!rickgSkip) { -/* - TRYING TO MAKE THIS CODE GO AWAY!... - static eHTMLTags gBodyBlockers[]={eHTMLTag_body,eHTMLTag_frameset,eHTMLTag_map}; - PRInt32 theBodyBlocker=GetTopmostIndexOf(gBodyBlockers,sizeof(gBodyBlockers)/sizeof(eHTMLTag_unknown)); - if((kNotFound==theBodyBlocker) && (!mHasOpenHead)){ - if(CanPropagate(eHTMLTag_body,aChildTag)) { - mHasOpenBody=PR_TRUE; - result=CreateContextStackFor(aChildTag); - //CStartToken theToken(eHTMLTag_body); //open the body container... - //result=HandleStartToken(&theToken); - } - }//if -*/ - /*********************************************************************** + /*********************************************************************** Subtlety alert: The REAL story on when tags are opened is somewhat confusing, but it's @@ -948,7 +1077,12 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI PRBool theChildAgrees=(theCanContainResult) ? CanBeContained(theParentTag,aChildTag,mBodyContext->mStack) : PR_FALSE; if(!(theCanContainResult && theChildAgrees)) { + PRInt32 theIndex=FindAutoCloseTargetForStartTag2(aChildTag,mBodyContext->mStack,*this); + eHTMLTags theTarg2=mBodyContext->TagAt(theIndex); eHTMLTags theTarget=FindAutoCloseTargetForStartTag(aChildTag,mBodyContext->mStack); + + NS_ASSERTION(theTarg2==theTarget,"Error: target mismatch"); + if(eHTMLTag_unknown!=theTarget){ result=CloseContainersTo(theTarget,PR_TRUE); theParentTag=mBodyContext->Last(); @@ -986,13 +1120,12 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI result=OpenContainer(aNode,PR_TRUE); } else { //we're writing a leaf... - OpenTransientStyles(aChildTag); result=AddLeaf(aNode); } return result; } - +#endif #ifdef RICKG_DEBUG void WriteTokenToLog(CToken* aToken) { @@ -1034,15 +1167,15 @@ public: eHTMLTags mTag; }; -/** - * This gets called before we've handled a given start tag. - * It's a generic hook to let us do pre processing. - * @param aToken contains the tag in question - * @param aChildTag is the tag itself. - * @param aNode is the node (tag) with associated attributes. - * @return TRUE if tag processing should continue; FALSE if the tag has been handled. - */ -nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsCParserNode& aNode){ +/** + * This gets called before we've handled a given start tag. + * It's a generic hook to let us do pre processing. + * @param aToken contains the tag in question + * @param aChildTag is the tag itself. + * @param aNode is the node (tag) with associated attributes. + * @return TRUE if tag processing should continue; FALSE if the tag has been handled. + */ +nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsCParserNode& aNode){ nsresult result=NS_OK; PRInt32 theAttrCount = aNode.GetAttributeCount(); @@ -1082,78 +1215,80 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsCParserNode } } - //********************************************************** - //XXX Hack until I get the node observer API in place... - if(eHTMLTag_meta==aTag) { - PRInt32 theCount=aNode.GetAttributeCount(); - if(1 - const nsString& theKey=aNode.GetKeyAt(0); - if(theKey.EqualsIgnoreCase("HTTP-EQUIV")) { - const nsString& theKey2=aNode.GetKeyAt(1); - if(theKey2.EqualsIgnoreCase("CONTENT")) { - nsScanner* theScanner=mParser->GetScanner(); - if(theScanner) { - const nsString& theValue=aNode.GetValueAt(1); - PRInt32 charsetValueStart = theValue.RFind("charset=", PR_TRUE ) ; - if(kNotFound != charsetValueStart) { + //********************************************************** + //XXX Hack until I get the node observer API in place... + + if(eHTMLTag_meta==aTag) { + PRInt32 theCount=aNode.GetAttributeCount(); + if(1 + const nsString& theKey=aNode.GetKeyAt(0); + if(theKey.EqualsIgnoreCase("HTTP-EQUIV")) { + const nsString& theKey2=aNode.GetKeyAt(1); + if(theKey2.EqualsIgnoreCase("CONTENT")) { + nsScanner* theScanner=mParser->GetScanner(); + if(theScanner) { + const nsString& theValue=aNode.GetValueAt(1); + PRInt32 charsetValueStart = theValue.RFind("charset=", PR_TRUE ) ; + if(kNotFound != charsetValueStart) { charsetValueStart += 8; // 8 = "charset=".length - PRInt32 charsetValueEnd = theValue.FindCharInSet("\'\";", charsetValueStart ); + PRInt32 charsetValueEnd = theValue.FindCharInSet("\'\";", charsetValueStart ); if(kNotFound == charsetValueEnd ) - charsetValueEnd = theValue.Length(); - nsAutoString theCharset; - theValue.Mid(theCharset, charsetValueStart, charsetValueEnd - charsetValueStart); - theScanner->SetDocumentCharset(theCharset, kCharsetFromMetaTag); - // XXX this should be delete after META charset really work - nsParser::gHackMetaCharset = theCharset; - } //if - } //if - } - } //if + charsetValueEnd = theValue.Length(); + nsAutoString theCharset; + theValue.Mid(theCharset, charsetValueStart, charsetValueEnd - charsetValueStart); + theScanner->SetDocumentCharset(theCharset, kCharsetFromMetaTag); + // XXX this should be delete after META charset really work + nsParser::gHackMetaCharset = theCharset; + } //if + } //if + } + } //if - else if(theKey.EqualsIgnoreCase("NAME")) { - const nsString& theValue1=aNode.GetValueAt(0); - if(theValue1.EqualsIgnoreCase("\"CRC\"")) { - const nsString& theKey2=aNode.GetKeyAt(1); - if(theKey2.EqualsIgnoreCase("CONTENT")) { - const nsString& theValue2=aNode.GetValueAt(1); - PRInt32 err=0; - mExpectedCRC32=theValue2.ToInteger(&err); - } //if - } //if - } //else + else if(theKey.EqualsIgnoreCase("NAME")) { + const nsString& theValue1=aNode.GetValueAt(0); + if(theValue1.EqualsIgnoreCase("\"CRC\"")) { + const nsString& theKey2=aNode.GetKeyAt(1); + if(theKey2.EqualsIgnoreCase("CONTENT")) { + const nsString& theValue2=aNode.GetValueAt(1); + PRInt32 err=0; + mExpectedCRC32=theValue2.ToInteger(&err); + } //if + } //if + } //else - } //if - }//if + } //if + }//if - //XXX Hack until I get the node observer API in place... - //********************************************************** + //XXX Hack until I get the node observer API in place... + //********************************************************** - if(NS_OK==result) { - result=gHTMLElements[aTag].HasSpecialProperty(kDiscardTag) ? 1 : NS_OK; - } + if(NS_OK==result) { + result=gHTMLElements[aTag].HasSpecialProperty(kDiscardTag) ? 1 : NS_OK; + } - PRBool isHeadChild=gHTMLElements[eHTMLTag_head].IsChildOfHead(aTag); + + PRBool isHeadChild=gHTMLElements[eHTMLTag_head].IsChildOfHead(aTag); //this code is here to make sure the head is closed before we deal - //with any tags that don't belong in the head. - if(NS_OK==result) { - if(mHasOpenHead){ - static eHTMLTags skip2[]={eHTMLTag_newline,eHTMLTag_whitespace}; - if(!FindTagInSet(aTag,skip2,sizeof(skip2)/sizeof(eHTMLTag_unknown))){ - if(!isHeadChild){ - CEndToken theToken(eHTMLTag_head); - nsCParserNode theNode(&theToken,mLineNumber); - result=CloseHead(theNode); - } - } - } - } + //with any tags that don't belong in the head. + if(NS_OK==result) { + if(mHasOpenHead){ + static eHTMLTags skip2[]={eHTMLTag_newline,eHTMLTag_whitespace}; + if(!FindTagInSet(aTag,skip2,sizeof(skip2)/sizeof(eHTMLTag_unknown))){ + if(!isHeadChild){ + CEndToken theToken(eHTMLTag_head); + nsCParserNode theNode(&theToken,mLineNumber); + result=CloseHead(theNode); + } + } + } + } - return result; -} + return result; +} /** * This method gets called when a start token has been encountered that the parent @@ -1240,7 +1375,7 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) { eHTMLTags theChildTag=(eHTMLTags)aToken->GetTypeID(); nsCParserNode attrNode((CHTMLToken*)aToken,mLineNumber,GetTokenRecycler()); PRInt16 attrCount=aToken->GetAttributeCount(); - nsresult result=(0==attrCount) ? NS_OK : CollectAttributes(attrNode,attrCount); + nsresult result=(0==attrCount) ? NS_OK : CollectAttributes(attrNode,theChildTag,attrCount); eHTMLTags theParent=mBodyContext->Last(); if(NS_OK==result) { @@ -1248,8 +1383,12 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) { if(nsHTMLElement::IsSectionTag(theChildTag)){ switch(theChildTag){ - case eHTMLTag_head: case eHTMLTag_body: + if(HasOpenContainer(theChildTag)){ + return NS_OK; //OpenContainer(attrNode,PR_FALSE); + } + break; + case eHTMLTag_head: if(mHadBodyOrFrameset) { result=HandleOmittedTag(aToken,theChildTag,theParent,attrNode); if(result == NS_OK) @@ -1318,9 +1457,13 @@ PRBool HasCloseablePeerAboveRoot(CTagList& aRootTagList,nsEntryStack& aTagStack, theChildIndex=theCloseTags->GetTopmostIndexOf(aTagStack); } else { - theChildIndex=aTagStack.GetTopmostIndexOf(aTag); + if((anEndTag) || (!gHTMLElements[aTag].CanContainSelf())) + theChildIndex=aTagStack.GetTopmostIndexOf(aTag); } - return PRBool(theRootIndex... + // + return PRBool(theRootIndex<=theChildIndex); } @@ -1335,7 +1478,7 @@ PRBool HasCloseablePeerAboveRoot(CTagList& aRootTagList,nsEntryStack& aTagStack, */ static eHTMLTags FindAutoCloseTargetForEndTag(eHTMLTags aCurrentTag,nsEntryStack& aTagStack) { - int theTopIndex=aTagStack.GetSize(); + int theTopIndex=aTagStack.GetCount(); eHTMLTags thePrevTag=aTagStack.Last(); if(nsHTMLElement::IsContainer(aCurrentTag)){ @@ -1385,7 +1528,12 @@ eHTMLTags FindAutoCloseTargetForEndTag(eHTMLTags aCurrentTag,nsEntryStack& aTagS return aCurrentTag; else return eHTMLTag_unknown; } - } //if + } //if blockcloser + else{ + //Ok, a much more sensible approach for non-block closers; use the tag group to determine closure: + //For example: %phrasal closes %phrasal, %fontstyle and %special + return gHTMLElements[aCurrentTag].GetCloseTargetForEndTag(aTagStack,theChildIndex); + } }//if } //if return eHTMLTag_unknown; @@ -1438,12 +1586,12 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) { result=HandleStartToken(theToken); } break; - + default: { //now check to see if this token should be omitted, or //if it's gated from closing by the presence of another tag. - if(PR_TRUE==CanOmitEndTag(mBodyContext->Last(),theChildTag)) { + if((gHTMLElements[theChildTag].CanOmitEndTag()) || (kNotFound==GetIndexOfChildOrSynonym(mBodyContext->mStack,theChildTag))) { UpdateStyleStackForCloseTag(theChildTag,theChildTag); } else { @@ -1452,7 +1600,7 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) { result = HandleSavedTokensAbove(theTarget); } if(eHTMLTag_unknown!=theTarget) { - result=CloseContainersTo(theTarget,PR_TRUE); + result=CloseContainersTo(theTarget,PR_FALSE); } } } @@ -1476,14 +1624,13 @@ nsresult CNavDTD::HandleSavedTokensAbove(eHTMLTags aTag) { NS_PRECONDITION(mBodyContext != nsnull && mBodyContext->GetCount() > 0,"invalid context"); - CToken* theToken; - eHTMLTags theTag; - PRInt32 attrCount; - nsresult result = NS_OK; - PRInt32 theTopIndex = GetTopmostIndexOf(aTag); - PRInt32 theTagCount = mBodyContext->GetCount(); + CToken* theToken; + eHTMLTags theTag; + PRInt32 attrCount; + nsresult result = NS_OK; + PRInt32 theTopIndex = GetTopmostIndexOf(aTag); + PRInt32 theTagCount = mBodyContext->GetCount(); - if(theTopIndex == kNotFound) return result; @@ -1491,10 +1638,11 @@ nsresult CNavDTD::HandleSavedTokensAbove(eHTMLTags aTag) PRInt32 theBadTokenCount = mBodyContext->TokenCountAt(theBadContentIndex); if(theBadTokenCount > 0) { - nsDTDContext temp; // Pause the main context and switch to the new context. mSink->BeginContext(theBadContentIndex); - + + nsDTDContext temp; + // The body context should contain contents only upto the marked position. for(PRInt32 i=0; i<(theTagCount - theTopIndex); i++) temp.Push(mBodyContext->Pop()); @@ -1520,8 +1668,7 @@ nsresult CNavDTD::HandleSavedTokensAbove(eHTMLTags aTag) theBadTokenCount--; } if(theTopIndex != mBodyContext->GetCount()) { - eHTMLTags theTarget = mBodyContext->TagAt(theTopIndex); - CloseContainersTo(theTopIndex,theTarget,PR_TRUE); + CloseContainersTo(theTopIndex,mBodyContext->TagAt(theTopIndex),PR_TRUE); } // Bad-contents were successfully processed. Now, itz time to get @@ -1599,27 +1746,6 @@ nsresult CNavDTD::HandleCommentToken(CToken* aToken) { return result; } -/** - * This method gets called when a skippedcontent token has - * been encountered in the parse process. After verifying - * that the topmost container can contain text, we call - * AddLeaf to store this token in the top container. - * - * @update gess 3/25/98 - * @param aToken -- next (start) token to be handled - * @return PR_TRUE if all went well; PR_FALSE if error occured - */ -nsresult CNavDTD::HandleSkippedContentToken(CToken* aToken) { - NS_PRECONDITION(0!=aToken,kNullToken); - - nsresult result=NS_OK; - - if(HasOpenContainer(eHTMLTag_body)) { - nsCParserNode aNode((CHTMLToken*)aToken,mLineNumber); - result=AddLeaf(aNode); - } - return result; -} /** * This method gets called when an attribute token has been @@ -1700,13 +1826,18 @@ nsresult CNavDTD::HandleProcessingInstructionToken(CToken* aToken){ * @param aCount is the # of attributes you're expecting * @return error code (should be 0) */ -nsresult CNavDTD::CollectAttributes(nsCParserNode& aNode,PRInt32 aCount){ +nsresult CNavDTD::CollectAttributes(nsCParserNode& aNode,eHTMLTags aTag,PRInt32 aCount){ int attr=0; nsresult result=NS_OK; - if(aCount<=mTokenizer->GetCount()) { + int theAvailTokenCount=mTokenizer->GetCount() + mSkippedContent.GetSize(); + if(aCount<=theAvailTokenCount) { + CToken* theToken=0; + eHTMLTags theSkipTarget=gHTMLElements[aTag].mSkipTarget; for(attr=0;attrPopToken(); + if((eHTMLTag_unknown!=theSkipTarget) && mSkippedContent.GetSize()) + theToken=(CToken*)mSkippedContent.PopFront(); + else theToken=mTokenizer->PopToken(); if(theToken) { #ifdef RICKG_DEBUG @@ -1733,27 +1864,21 @@ nsresult CNavDTD::CollectAttributes(nsCParserNode& aNode,PRInt32 aCount){ * @return Error condition. */ nsresult CNavDTD::CollectSkippedContent(nsCParserNode& aNode,PRInt32& aCount) { - nsresult result=NS_OK; - eHTMLTokenTypes theType=eToken_unknown; - aCount=0; - CToken* theToken=mTokenizer->PopToken(); - if(theToken) { - theType=eHTMLTokenTypes(theToken->GetTokenType()); - if(eToken_skippedcontent==theType) { + CTokenRecycler* theRecycler=(CTokenRecycler*)mTokenizer->GetTokenRecycler(); - #ifdef RICKG_DEBUG - WriteTokenToLog(theToken); - #endif - - aNode.SetSkippedContent(theToken); - aCount++; - } + int aIndex=0; + int aMax=mSkippedContent.GetSize(); + nsAutoString theTempStr; + nsAutoString theStr; + for(aIndex=0;aIndexGetSource(theTempStr); + theStr+=theTempStr; + theRecycler->RecycleToken(theNextToken); } - else { - result=kEOF; - } - return result; + aNode.SetSkippedContent(theStr); + return NS_OK; } @@ -1782,64 +1907,8 @@ CITokenHandler* CNavDTD::GetTokenHandler(eHTMLTokenTypes aType) const { * @return */ void CNavDTD::EmitMisplacedContent(nsITokenizer* aTokenizer){ -/* - if(aTokenizer){ - if(!mHadBodyOrFrameset){ - int index=0; - int max=mMisplacedContent.GetSize(); - PRBool isBodyContent=PR_TRUE; - for(index=0;indexGetTypeID(); - if(gHTMLElements[theTag].IsWhitespaceTag(theTag)){ - //ignore it... - } - if(gHTMLElements[eHTMLTag_body].SectionContains(theTag,PR_TRUE)){ - break; //stop, since you now know for sure to open the body... - } - else { - static eHTMLTags frameTags[]={eHTMLTag_frame,eHTMLTag_noframes,eHTMLTag_frameset}; - if(FindTagInSet(theTag,frameTags,sizeof(frameTags)/sizeof(eHTMLTag_unknown))) { - isBodyContent=PR_FALSE; - break; - } - } - } - } //for - if(isBodyContent){ - CTokenRecycler* theRecycler=(CTokenRecycler*)aTokenizer->GetTokenRecycler(); - CToken* theBodyToken=theRecycler->CreateTokenOfType(eToken_start,eHTMLTag_body); - mMisplacedContent.PushFront(theBodyToken); - //mMisplacedContent.PushFront(theBodyToken); - } - } - } -*/ - aTokenizer->PrependTokens(mMisplacedContent); } -/** - * This method is called to determine whether or not a tag - * can contain an explict style tag (font, italic, bold, etc.) - * Most can -- but some, like option, cannot. Therefore we - * don't bother to open transient styles within these elements. - * - * @update gess 4/8/98 - * @param aParent -- tag enum of parent container - * @param aChild -- tag enum of child container - * @return PR_TRUE if parent can contain child - */ -PRBool CNavDTD::CanContainStyles(eHTMLTags aParent) const { - PRBool result=PR_TRUE; - switch(aParent) { - case eHTMLTag_option: - result=PR_FALSE; break; - default: - break; - } - return result; -} /*********************************************************************************** The preceeding tables determine the set of elements each tag can contain... @@ -1879,22 +1948,29 @@ PRBool CNavDTD::CanPropagate(eHTMLTags aParentTag,eHTMLTags aChildTag) const { PRBool result=PR_FALSE; PRBool parentCanContain=CanContain(aParentTag,aChildTag); - if(nsHTMLElement::IsContainer(aChildTag)){ - if(nsHTMLElement::IsBlockParent(aParentTag) || (gHTMLElements[aParentTag].GetSpecialChildren())) { - while(eHTMLTag_unknown!=aChildTag) { - if(parentCanContain){ - result=PR_TRUE; - break; - }//if - CTagList* theTagList=gHTMLElements[aChildTag].GetRootTags(); - aChildTag=theTagList->mTags[0]; - parentCanContain=CanContain(aParentTag,aChildTag); - }//while - }//if - }//if - else if(nsHTMLElement::IsTextTag(aChildTag)){ - result=PR_TRUE; + if(aParentTag==aChildTag) { + return result; } + + int thePropLevel=0; + if(nsHTMLElement::IsContainer(aChildTag)){ + if(!gHTMLElements[aChildTag].HasSpecialProperty(kNoPropagate)){ + if(nsHTMLElement::IsBlockParent(aParentTag) || (gHTMLElements[aParentTag].GetSpecialChildren())) { + while(eHTMLTag_unknown!=aChildTag) { + if(parentCanContain){ + result=PR_TRUE; + break; + }//if + CTagList* theTagList=gHTMLElements[aChildTag].GetRootTags(); + aChildTag=theTagList->GetTagAt(0); + parentCanContain=CanContain(aParentTag,aChildTag); + ++thePropLevel; + }//while + }//if + }//if + if(thePropLevel>gHTMLElements[aParentTag].mPropagateRange) + result=PR_FALSE; + }//if else result=parentCanContain; return result; } @@ -1921,18 +1997,22 @@ PRBool CNavDTD::CanOmit(eHTMLTags aParent,eHTMLTags aChild) const { } if(gHTMLElements[aParent].HasSpecialProperty(kOmitWS)) { - if(nsHTMLElement::IsTextTag(aChild)) { + if(nsHTMLElement::IsWhitespaceTag(aChild)) { return PR_TRUE; } } + if(gHTMLElements[aParent].CanExclude(aChild)){ + return PR_TRUE; + } + //Now the obvious test: if the parent can contain the child, don't omit. - if(gHTMLElements[aParent].CanContain(aChild)){ + if((gHTMLElements[aParent].CanContain(aChild)) || (aChild==aParent)){ return PR_FALSE; } - if(nsHTMLElement::IsBlockElement(aParent)) { - if(nsHTMLElement::IsInlineElement(aChild)) { //feel free to drop inlines that a block doesn't contain. + if(nsHTMLElement::IsBlockEntity(aParent)) { + if(nsHTMLElement::IsInlineEntity(aChild)) { //feel free to drop inlines that a block doesn't contain. return PR_TRUE; } } @@ -1946,27 +2026,6 @@ PRBool CNavDTD::CanOmit(eHTMLTags aParent,eHTMLTags aChild) const { } -/** - * This method gets called to determine whether a given - * ENDtag can be omitted. Admittedly,this is a gross simplification. - * - * @update gess 3/25/98 - * @param aTag -- tag to test for containership - * @return PR_TRUE if given tag can contain other tags - */ -PRBool CNavDTD::CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild) const { - PRBool result=PR_FALSE; - - if(gHTMLElements[aChild].CanOmitEndTag(aParent)) { - return PR_TRUE; - } - - PRInt32 theChildIndex=GetIndexOfChildOrSynonym(mBodyContext->mStack,aChild); - result=PRBool(kNotFound==theChildIndex); - - return result; -} - /** * This method gets called to determine whether a given * tag is itself a container @@ -2043,7 +2102,7 @@ PRBool CNavDTD::BackwardPropagate(nsEntryStack& aStack,eHTMLTags aParentTag,eHTM do { CTagList* theRootTags=gHTMLElements[theParentTag].GetRootTags(); - theParentTag=theRootTags->mTags[0]; + theParentTag=theRootTags->GetTagAt(0); if(theParentTag!=eHTMLTag_unknown) { aStack.Push(theParentTag); } @@ -2173,43 +2232,39 @@ PRInt32 CNavDTD::GetTopmostIndexOf(eHTMLTags aTag) const { * @param tag of the container just opened * @return 0 (for now) */ -nsresult CNavDTD::OpenTransientStyles(eHTMLTags aTag){ +nsresult CNavDTD::OpenTransientStyles(eHTMLTags aChildTag){ nsresult result=NS_OK; - if(!FindTagInSet(aTag,gWhitespaceTags,sizeof(gWhitespaceTags)/sizeof(aTag))){ - //the following code builds the set of style tags to be opened... + //later, change this so that transients only open in containers that get leaked in to. -/* - eHTMLTags theStyles[50]; - int theCount=0; +#ifdef ENABLE_RESIDUALSTYLE + eHTMLTags theParentTag=mBodyContext->Last(); + if(!gHTMLElements[theParentTag].HasSpecialProperty(kNoStyleLeaksIn)) { + if(!FindTagInSet(aChildTag,gWhitespaceTags,sizeof(gWhitespaceTags)/sizeof(aChildTag))){ + //the following code builds the set of style tags to be opened... + PRUint32 theCount=mBodyContext->GetCount(); + PRUint32 theIndex=0; + for(theIndex=0;theIndexGetStylesAt(theIndex); + if(theStack){ + PRUint32 scount=theStack->GetCount(); + PRUint32 sindex=0; + for(sindex=0;sindexTagAt(sindex); - int theStackPos=0; - for(theStackPos=0;theStackPosGetCount();theStackPos++){ - nsEntryStack* theStyleStack=mBodyContext->mStyles[theStackPos]; - if(theStyleStack) { - int theTagPos=0; - int count = theStyleStack->mTags->GetSize(); - for(theTagPos=0;theTagPosTagAt(theTagPos),theStyles,theCount))) { - theStyles[theCount++]=theStyleStack->TagAt(theTagPos); + if(theTag==eHTMLTag_font) //XXX HACK DEBUG! + theTag=eHTMLTag_b; + + CStartToken theToken(theTag); + nsCParserNode theNode(&theToken,mLineNumber); + theToken.SetTypeID(theTag); + result=OpenContainer(theNode,PR_FALSE); } } } } - theStyles[theCount]=eHTMLTag_unknown; - - //now iterate style set, and open the containers... - for(theStackPos=0;theStackPosmOpenStyles=theCount; - -*/ - } +#endif return result; } @@ -2225,13 +2280,13 @@ nsresult CNavDTD::OpenTransientStyles(eHTMLTags aTag){ * @param tag of the container just opened * @return 0 (for now) */ -nsresult CNavDTD::CloseTransientStyles(eHTMLTags aTag){ +nsresult CNavDTD::CloseTransientStyles(eHTMLTags aChildTag){ nsresult result=NS_OK; int theTagPos=0; - //now iterate style set, and close the containers... -/* + +#ifdef ENABLE_RESIDUALSTYLE nsDeque* theStyleDeque=mBodyContext->GetStyles(); for(theTagPos=mBodyContext->mOpenStyles;theTagPos>0;theTagPos--){ eHTMLTags theTag=GetTopNode(); @@ -2240,7 +2295,7 @@ nsresult CNavDTD::CloseTransientStyles(eHTMLTags aTag){ token.SetTypeID(theTag); result=CloseContainer(theNode,theTag,PR_FALSE); } -*/ +#endif return result; } @@ -2323,44 +2378,30 @@ nsresult CNavDTD::OpenBody(const nsIParserNode& aNode){ NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos); nsresult result=NS_OK; - eHTMLTags topTag=mBodyContext->Last(); - 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. + PRInt32 theHTMLPos=GetTopmostIndexOf(eHTMLTag_html); + if(kNotFound==theHTMLPos){ //someone forgot to open HTML. Let's do it for them. + nsAutoString theEmpty; + CHTMLToken token(theEmpty,eHTMLTag_html); + nsCParserNode htmlNode(&token,mLineNumber); + result=OpenHTML(htmlNode); //open the html container... + theHTMLPos=GetTopmostIndexOf(eHTMLTag_html); + } - result=CloseContainersTo(0,eHTMLTag_html,PR_TRUE); //close current stack containers. - nsAutoString theEmpty; - CHTMLToken token(theEmpty,eHTMLTag_html); - nsCParserNode htmlNode(&token,mLineNumber); - result=OpenHTML(htmlNode); //open the html container... - } + PRBool theBodyIsOpen=HasOpenContainer(eHTMLTag_body); + if(!theBodyIsOpen){ + //body is not already open, but head may be so close it + result=CloseContainersTo(theHTMLPos+1,eHTMLTag_body,PR_TRUE); //close current stack containers. } if(NS_OK==result) { result=(mSink) ? mSink->OpenBody(aNode) : NS_OK; - mBodyContext->Push((eHTMLTags)aNode.GetNodeType()); - - /*now THIS is a hack to support plaintext documents in this DTD... - if((NS_OK==result) && mIsPlaintext) { - CStartToken theToken(eHTMLTag_pre); //open the body container... - result=HandleStartToken(&theToken); + if(!theBodyIsOpen) { + mBodyContext->Push((eHTMLTags)aNode.GetNodeType()); + mTokenizer->PrependTokens(mMisplacedContent); } - */ } - mTokenizer->PrependTokens(mMisplacedContent); return result; } @@ -2464,6 +2505,7 @@ nsresult CNavDTD::OpenFrameset(const nsIParserNode& aNode){ NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos); nsresult result=(mSink) ? mSink->OpenFrameset(aNode) : NS_OK; mBodyContext->Push((eHTMLTags)aNode.GetNodeType()); + mHadBodyOrFrameset=PR_TRUE; return result; } @@ -2490,10 +2532,11 @@ nsresult CNavDTD::CloseFrameset(const nsIParserNode& aNode){ * 2nd, pass this message on to the sink. * @update gess4/6/98 * @param aNode -- next node to be added to model + * @param aClosedByStartTag -- ONLY TRUE if the container is being closed by opening of another container. * @return TRUE if ok, FALSE if error */ nsresult -CNavDTD::OpenContainer(const nsIParserNode& aNode,PRBool aUpdateStyleStack){ +CNavDTD::OpenContainer(const nsIParserNode& aNode,PRBool aClosedByStartTag){ NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos); nsresult result=NS_OK; @@ -2563,9 +2606,11 @@ CNavDTD::OpenContainer(const nsIParserNode& aNode,PRBool aUpdateStyleStack){ break; } - if((NS_OK==result) && (PR_TRUE==aUpdateStyleStack)){ + /* + if((NS_OK==result) && (PR_TRUE==aClosedByStartTag)){ UpdateStyleStackForOpenTag(nodeType,nodeType); } + */ return result; } @@ -2576,18 +2621,22 @@ CNavDTD::OpenContainer(const nsIParserNode& aNode,PRBool aUpdateStyleStack){ * 2nd, pass this message on to the sink. * @update gess4/6/98 * @param aNode -- next node to be removed from our model + * @param aTag -- id of tag to be closed + * @param aClosedByStartTag -- ONLY TRUE if the container is being closed by opening of another container. * @return TRUE if ok, FALSE if error */ nsresult -CNavDTD::CloseContainer(const nsIParserNode& aNode,eHTMLTags aTag, - PRBool aUpdateStyles){ +CNavDTD::CloseContainer(const nsIParserNode& aNode,eHTMLTags aTag,PRBool aClosedByStartTag){ nsresult result=NS_OK; eHTMLTags nodeType=(eHTMLTags)aNode.GetNodeType(); - + #define K_CLOSEOP 200 CRCStruct theStruct(nodeType,K_CLOSEOP); mComputedCRC32=AccumulateCRC(mComputedCRC32,(char*)&theStruct,sizeof(theStruct)); + if(!aClosedByStartTag) + UpdateStyleStackForCloseTag(nodeType,aTag); + switch(nodeType) { case eHTMLTag_html: @@ -2621,9 +2670,8 @@ CNavDTD::CloseContainer(const nsIParserNode& aNode,eHTMLTags aTag, break; } - if((NS_OK==result) && (PR_TRUE==aUpdateStyles)){ - UpdateStyleStackForCloseTag(nodeType,aTag); - } + if(aClosedByStartTag) + UpdateStyleStackForOpenTag(nodeType,aTag); return result; } @@ -2633,10 +2681,12 @@ CNavDTD::CloseContainer(const nsIParserNode& aNode,eHTMLTags aTag, * our own internal model of the content-stack; and * 2nd, pass this message on to the sink. * @update gess4/6/98 - * @param + * @param anIndex + * @param aTag + * @param aClosedByStartTag -- if TRUE, then we're closing something because a start tag caused it * @return TRUE if ok, FALSE if error */ -nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag, PRBool aUpdateStyles){ +nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag, PRBool aClosedByStartTag){ NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos); nsresult result=NS_OK; @@ -2648,7 +2698,7 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag, PRBool aUpda while(mBodyContext->GetCount()>anIndex) { eHTMLTags theTag=mBodyContext->Last(); theToken.SetTypeID(theTag); - result=CloseContainer(theNode,aTag,aUpdateStyles); + result=CloseContainer(theNode,aTag,aClosedByStartTag); } } return result; @@ -2659,17 +2709,18 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag, PRBool aUpda * our own internal model of the content-stack; and * 2nd, pass this message on to the sink. * @update gess4/6/98 - * @param + * @param aTag -- + * @param aClosedByStartTag -- ONLY TRUE if the container is being closed by opening of another container. * @return TRUE if ok, FALSE if error */ -nsresult CNavDTD::CloseContainersTo(eHTMLTags aTag,PRBool aUpdateStyles){ +nsresult CNavDTD::CloseContainersTo(eHTMLTags aTag,PRBool aClosedByStartTag){ NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos); PRInt32 pos=GetTopmostIndexOf(aTag); if(kNotFound!=pos) { //the tag is indeed open, so close it. - return CloseContainersTo(pos,aTag,aUpdateStyles); + return CloseContainersTo(pos,aTag,aClosedByStartTag); } eHTMLTags theTopTag=mBodyContext->Last(); @@ -2687,27 +2738,27 @@ nsresult CNavDTD::CloseContainersTo(eHTMLTags aTag,PRBool aUpdateStyles){ pos=GetTopmostIndexOf(aTag); if(kNotFound!=pos) { //the tag is indeed open, so close it. - return CloseContainersTo(pos,aTag,aUpdateStyles); + return CloseContainersTo(pos,aTag,aClosedByStartTag); } } nsresult result=NS_OK; - CTagList* theTagList=gHTMLElements[aTag].GetRootTags(); - eHTMLTags theParentTag=theTagList->mTags[0]; + CTagList* theRootTags=gHTMLElements[aTag].GetRootTags(); + eHTMLTags theParentTag=theRootTags->GetTagAt(0); pos=GetTopmostIndexOf(theParentTag); if(kNotFound!=pos) { //the parent container is open, so close it instead - result=CloseContainersTo(pos+1,aTag,aUpdateStyles); + result=CloseContainersTo(pos+1,aTag,aClosedByStartTag); } return result; } /** * This method causes the topmost container on the stack - * to be closed. - * @update gess4/6/98 - * @see CloseContainer() - * @param + * to be closed. The closure is ALWAYS due to a new start + * tag be opened which forces the topmost tag closed. + * + * @update gess 4/26/99 * @return TRUE if ok, FALSE if error */ nsresult CNavDTD::CloseTopmostContainer(){ @@ -2715,7 +2766,8 @@ nsresult CNavDTD::CloseTopmostContainer(){ nsAutoString theEmpty; CEndToken theToken(theEmpty); - eHTMLTags theTag=mBodyContext->Last(); + eHTMLTags theTag=mBodyContext->Last(); + theToken.SetTypeID(theTag); nsCParserNode theNode(&theToken,mLineNumber); return CloseContainer(theNode,theTag,PR_TRUE); @@ -2730,7 +2782,13 @@ nsresult CNavDTD::CloseTopmostContainer(){ * @return error code; 0 means OK */ nsresult CNavDTD::AddLeaf(const nsIParserNode& aNode){ - nsresult result=(mSink) ? mSink->AddLeaf(aNode) : NS_OK; + nsresult result=NS_OK; + + if(mSink){ + eHTMLTags theTag=(eHTMLTags)aNode.GetNodeType(); + OpenTransientStyles(theTag); + result=mSink->AddLeaf(aNode); + } return result; } @@ -2742,7 +2800,7 @@ nsresult CNavDTD::AddLeaf(const nsIParserNode& aNode){ * @param aNode -- next node to be added to model * @return error code; 0 means OK */ -nsresult CNavDTD::AddHeadLeaf(const nsIParserNode& aNode){ +nsresult CNavDTD::AddHeadLeaf(nsIParserNode& aNode){ nsresult result=NS_OK; static eHTMLTags gNoXTags[]={eHTMLTag_noframes,eHTMLTag_nolayer,eHTMLTag_noscript}; @@ -2758,8 +2816,9 @@ nsresult CNavDTD::AddHeadLeaf(const nsIParserNode& aNode){ if(mSink) { result=OpenHead(aNode); if(NS_OK==result) { - if(eHTMLTag_title==theTag) + if(eHTMLTag_title==theTag) { mSink->SetTitle(aNode.GetSkippedContent()); + } else result=AddLeaf(aNode); // XXX If the return value tells us to block, go // ahead and close the tag out anyway, since its @@ -2843,7 +2902,7 @@ nsresult CNavDTD::CreateContextStackFor(eHTMLTags aChildTag){ //you have that aren't in the stack... nsAutoString theEmpty; CStartToken theToken(theEmpty); - PRInt32 count = kPropagationStack.GetSize(); + PRInt32 count = kPropagationStack.GetCount(); if(PR_TRUE==bResult){ while(count>0) { eHTMLTags theTag=kPropagationStack.Pop(); @@ -2893,12 +2952,13 @@ nsresult CNavDTD::ReduceContextStackFor(eHTMLTags aChildTag){ nsresult CNavDTD::UpdateStyleStackForOpenTag(eHTMLTags aTag,eHTMLTags anActualTag){ nsresult result=0; - if(nsHTMLElement::IsStyleTag(aTag)) { - nsEntryStack* theStyleStack=mBodyContext->GetStyles(); - if(theStyleStack){ - theStyleStack->Push(aTag); +#ifdef ENABLE_RESIDUALSTYLE + if(anActualTag!=eHTMLTag_font){ + if(nsHTMLElement::IsStyleTag(aTag)) { + mBodyContext->PushStyle(aTag); } } +#endif return result; } //update.. @@ -2914,15 +2974,10 @@ nsresult CNavDTD::UpdateStyleStackForOpenTag(eHTMLTags aTag,eHTMLTags anActualTa nsresult CNavDTD::UpdateStyleStackForCloseTag(eHTMLTags aTag,eHTMLTags anActualTag){ nsresult result=0; - - nsEntryStack* theStyles=mBodyContext->GetStyles(); - if(theStyles){ - if(nsHTMLElement::IsStyleTag(aTag)) { - if(aTag==anActualTag) { - theStyles->Pop(); - } - }//if - }//if + +#ifdef ENABLE_RESIDUALSTYLE + eHTMLTags theTag=mBodyContext->PopStyle(); +#endif return result; } @@ -2983,6 +3038,3 @@ nsresult CNavDTD::DoFragment(PRBool aFlag) return NS_OK; } - - - diff --git a/mozilla/parser/htmlparser/src/CNavDTD.h b/mozilla/parser/htmlparser/src/CNavDTD.h index 07084cdc321..f438aad7d96 100644 --- a/mozilla/parser/htmlparser/src/CNavDTD.h +++ b/mozilla/parser/htmlparser/src/CNavDTD.h @@ -296,17 +296,6 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD { */ virtual PRBool CanOmit(eHTMLTags aParent,eHTMLTags aChild)const; - /** - * This is called to determine if the given parent can omit the - * given child (end tag). - * - * @update gess 3/25/98 - * @param aParent -- tag type of parent - * @param aChild -- tag type of child - * @return PR_TRUE if given tag can contain omit child (end tag) - */ - virtual PRBool CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild)const; - /** * This method gets called to determine whether a given * tag is itself a container @@ -405,7 +394,6 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD { nsresult HandleEndToken(CToken* aToken); nsresult HandleEntityToken(CToken* aToken); nsresult HandleCommentToken(CToken* aToken); - nsresult HandleSkippedContentToken(CToken* aToken); nsresult HandleAttributeToken(CToken* aToken); nsresult HandleScriptToken(nsCParserNode& aNode); nsresult HandleStyleToken(CToken* aToken); @@ -431,7 +419,7 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD { nsresult OpenForm(const nsIParserNode& aNode); nsresult OpenMap(const nsIParserNode& aNode); nsresult OpenFrameset(const nsIParserNode& aNode); - nsresult OpenContainer(const nsIParserNode& aNode,PRBool aUpdateStyleStack); + nsresult OpenContainer(const nsIParserNode& aNode,PRBool aClosedByStartTag); /** * The next set of methods close the given HTML element. @@ -446,7 +434,7 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD { nsresult CloseForm(const nsIParserNode& aNode); nsresult CloseMap(const nsIParserNode& aNode); nsresult CloseFrameset(const nsIParserNode& aNode); - nsresult CloseContainer(const nsIParserNode& aNode,eHTMLTags anActualTag,PRBool aUpdateStyles); + nsresult CloseContainer(const nsIParserNode& aNode,eHTMLTags anActualTag,PRBool aClosedByStartTag); /** * The special purpose methods automatically close @@ -455,8 +443,8 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD { * @return error code - 0 if all went well. */ nsresult CloseTopmostContainer(); - nsresult CloseContainersTo(eHTMLTags aTag,PRBool aUpdateStyles); - nsresult CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag,PRBool aUpdateStyles); + nsresult CloseContainersTo(eHTMLTags aTag,PRBool aClosedByStartTag); + nsresult CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag,PRBool aClosedByStartTag); /** * Causes leaf to be added to sink at current vector pos. @@ -465,7 +453,7 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD { * @return error code - 0 if all went well. */ nsresult AddLeaf(const nsIParserNode& aNode); - nsresult AddHeadLeaf(const nsIParserNode& aNode); + nsresult AddHeadLeaf(nsIParserNode& aNode); /** * Causes auto-closures of context vector stack in order to find a @@ -495,17 +483,16 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD { * @param aTag -- represents the transient style tag to be handled. * @return error code -- usually 0 */ - nsresult OpenTransientStyles(eHTMLTags aTag); - nsresult CloseTransientStyles(eHTMLTags aTag); + nsresult OpenTransientStyles(eHTMLTags aChildTag); + nsresult CloseTransientStyles(eHTMLTags aChildTag); nsresult UpdateStyleStackForOpenTag(eHTMLTags aTag,eHTMLTags aActualTag); nsresult UpdateStyleStackForCloseTag(eHTMLTags aTag,eHTMLTags aActualTag); - PRBool CanContainStyles(eHTMLTags aTag) const; nsresult DoFragment(PRBool aFlag); protected: - nsresult CollectAttributes(nsCParserNode& aNode,PRInt32 aCount); + nsresult CollectAttributes(nsCParserNode& aNode,eHTMLTags aTag,PRInt32 aCount); nsresult CollectSkippedContent(nsCParserNode& aNode,PRInt32& aCount); nsresult WillHandleStartTag(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode); nsresult DidHandleStartTag(nsCParserNode& aNode,eHTMLTags aChildTag); @@ -531,8 +518,10 @@ protected: nsParser* mParser; nsITokenizer* mTokenizer; nsDeque mMisplacedContent; + nsDeque mSkippedContent; PRBool mHasOpenScript; PRBool mSaveBadTokens; + eHTMLTags mSkipTarget; PRUint32 mComputedCRC32; PRUint32 mExpectedCRC32; diff --git a/mozilla/parser/htmlparser/src/COtherDTD.cpp b/mozilla/parser/htmlparser/src/COtherDTD.cpp index 60d0cdf73a8..c71d8255066 100644 --- a/mozilla/parser/htmlparser/src/COtherDTD.cpp +++ b/mozilla/parser/htmlparser/src/COtherDTD.cpp @@ -254,20 +254,6 @@ nsresult COtherDTD::HandleCommentToken(CToken* aToken) { return CNavDTD::HandleCommentToken(aToken); } -/** - * This method gets called when a skippedcontent token has - * been encountered in the parse process. After verifying - * that the topmost container can contain text, we call - * AddLeaf to store this token in the top container. - * - * @update gess 3/25/98 - * @param aToken -- next (start) token to be handled - * @return PR_TRUE if all went well; PR_FALSE if error occured - */ -nsresult COtherDTD::HandleSkippedContentToken(CToken* aToken) { - return CNavDTD::HandleSkippedContentToken(aToken); -} - /** * This method gets called when an attribute token has been * encountered in the parse process. This is an error, since @@ -334,19 +320,6 @@ PRBool COtherDTD::CanOmit(eHTMLTags aParent,eHTMLTags aChild) const { } -/** - * This method gets called to determine whether a given - * ENDtag can be omitted. Admittedly,this is a gross simplification. - * - * @update gess 3/25/98 - * @param aTag -- tag to test for containership - * @return PR_TRUE if given tag can contain other tags - */ -PRBool COtherDTD::CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild) const { - return CNavDTD::CanOmitEndTag(aParent,aChild); -} - - /********************************************* Here comes code that handles the interface to our content sink. diff --git a/mozilla/parser/htmlparser/src/COtherDTD.h b/mozilla/parser/htmlparser/src/COtherDTD.h index 8cc1f83f45b..6e63a61fa59 100644 --- a/mozilla/parser/htmlparser/src/COtherDTD.h +++ b/mozilla/parser/htmlparser/src/COtherDTD.h @@ -121,17 +121,6 @@ class COtherDTD : public CNavDTD { */ virtual PRBool CanOmit(eHTMLTags aParent,eHTMLTags aChild)const; - /** - * This method gets called to determine whether a given - * tag can contain newlines. Most do not. - * - * @update gess 3/25/98 - * @param aParent -- tag type of parent - * @param aChild -- tag type of child - * @return PR_TRUE if given tag can contain other tags - */ - virtual PRBool CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild)const; - /** * This method gets called when a start token has been consumed and needs * to be handled (possibly added to content model via sink). @@ -181,15 +170,6 @@ class COtherDTD : public CNavDTD { */ nsresult HandleCommentToken(CToken* aToken); - /** - * This method gets called when a skipped-content token has been consumed and needs - * to be handled (possibly added to content model via sink). - * @update gess5/11/98 - * @param aToken is the skipped-content token to be handled - * @return TRUE if the token was handled. - */ - nsresult HandleSkippedContentToken(CToken* aToken); - /** * This method gets called when an attribute token has been consumed and needs * to be handled (possibly added to content model via sink). diff --git a/mozilla/parser/htmlparser/src/nsDTDUtils.cpp b/mozilla/parser/htmlparser/src/nsDTDUtils.cpp index 770d125e848..a7d0a155afc 100644 --- a/mozilla/parser/htmlparser/src/nsDTDUtils.cpp +++ b/mozilla/parser/htmlparser/src/nsDTDUtils.cpp @@ -19,9 +19,9 @@ #include "nsDTDUtils.h" #include "CNavDTD.h" + #include "nsIObserverService.h" #include "nsIServiceManager.h" -#include "nsIElementObserver.h" static NS_DEFINE_IID(kIObserverServiceIID, NS_IOBSERVERSERVICE_IID); static NS_DEFINE_IID(kObserverServiceCID, NS_OBSERVERSERVICE_CID); @@ -51,6 +51,8 @@ nsEntryStack::nsEntryStack() { nsEntryStack::~nsEntryStack() { if(mEntries) delete [] mEntries; + mCount=mCapacity=0; + mEntries=0; } /** @@ -182,7 +184,6 @@ PRInt32 nsEntryStack::GetTopmostIndexOf(eHTMLTags aTag) const { /** * * @update gess9/10/98 - * @update gess 4/26/99 */ nsDTDContext::nsDTDContext() : mStack(), mSkipped(0), mStyles(0) { #ifdef NS_DEBUG @@ -194,7 +195,6 @@ nsDTDContext::nsDTDContext() : mStack(), mSkipped(0), mStyles(0) { /** * * @update gess9/10/98 - * @update gess 4/26/99 */ nsDTDContext::~nsDTDContext() { } @@ -202,16 +202,14 @@ nsDTDContext::~nsDTDContext() { /** * * @update gess7/9/98, harishd 04/04/99 - * @update gess 4/26/99 */ PRInt32 nsDTDContext::GetCount(void) { - return mStack.GetSize(); + return mStack.GetCount(); } /** * * @update gess7/9/98, harishd 04/04/99 - * @update gess 4/26/99 */ void nsDTDContext::Push(eHTMLTags aTag) { #ifdef NS_DEBUG @@ -224,7 +222,6 @@ void nsDTDContext::Push(eHTMLTags aTag) { /** * @update gess7/9/98, harishd 04/04/99 - * @update gess 4/26/99 */ eHTMLTags nsDTDContext::Pop() { #ifdef NS_DEBUG @@ -232,6 +229,14 @@ eHTMLTags nsDTDContext::Pop() { mTags[mStack.mCount-1]=eHTMLTag_unknown; #endif + nsEntryStack* theStyles=0; + nsTagEntry& theEntry=mStack.EntryAt(mStack.mCount-1); + PRInt32 theIndex=theEntry.mStyleIndex; + if(-1Push(aTag); + } +} + +/** + * + * @update gess 04/28/99 + */ +eHTMLTags nsDTDContext::PopStyle(void){ + eHTMLTags result=eHTMLTag_unknown; + nsTagEntry& theEntry=mStack.EntryAt(mStack.mCount-1); + //ok, now go get the right tokenbank deque... + nsEntryStack* theStack=0; + if(-1Pop(); + } + return result; +} + + /** * * @update harishd 04/04/99 @@ -296,7 +337,7 @@ nsEntryStack* nsDTDContext::GetStyles(void) const { */ void nsDTDContext::SaveToken(CToken* aToken, PRInt32 aID) { - NS_PRECONDITION(aID <= mStack.GetSize() && aID > -1,"Out of bounds"); + NS_PRECONDITION(aID <= mStack.GetCount() && aID > -1,"Out of bounds"); if(aToken) { nsTagEntry& theEntry=mStack.EntryAt(aID); @@ -321,9 +362,9 @@ void nsDTDContext::SaveToken(CToken* aToken, PRInt32 aID) */ CToken* nsDTDContext::RestoreTokenFrom(PRInt32 aID) { - NS_PRECONDITION(aID <= mStack.GetSize() && aID > -1,"Out of bounds"); + NS_PRECONDITION(aID <= mStack.GetCount() && aID > -1,"Out of bounds"); CToken* result=0; - if(0 #include "nsITokenizer.h" #include "nsString.h" +#include "nsIElementObserver.h" /*************************************************************** Before digging into the NavDTD, we'll define a helper @@ -79,7 +80,7 @@ public: eHTMLTags operator[](PRUint32 anIndex) const; eHTMLTags Last() const; void Empty(void); - PRInt32 GetSize(void) const {return mCount;} + PRInt32 GetCount(void) const {return mCount;} nsTagEntry* mEntries; PRUint32 mCount; @@ -106,7 +107,9 @@ public: eHTMLTags Last() const; void Empty(void); PRInt32 GetCount(void); - nsEntryStack* GetStyles(void) const; + nsEntryStack* GetStylesAt(PRUint32 anIndex) const; + void PushStyle(eHTMLTags aTag); + eHTMLTags PopStyle(void); void SaveToken(CToken* aToken, PRInt32 aID); CToken* RestoreTokenFrom(PRInt32 aID); diff --git a/mozilla/parser/htmlparser/src/nsElementTable.cpp b/mozilla/parser/htmlparser/src/nsElementTable.cpp index 446a405ef4c..e655862aa7f 100644 --- a/mozilla/parser/htmlparser/src/nsElementTable.cpp +++ b/mozilla/parser/htmlparser/src/nsElementTable.cpp @@ -48,7 +48,7 @@ PRBool CTagList::Contains(eHTMLTags aTag){ * @return */ PRInt32 CTagList::GetTopmostIndexOf(nsEntryStack& aTagStack){ - int max = aTagStack.GetSize(); + int max = aTagStack.GetCount(); int index; for(index=max-1;index>=0;index--){ if(Contains(aTagStack[index])) { @@ -65,7 +65,7 @@ PRInt32 CTagList::GetTopmostIndexOf(nsEntryStack& aTagStack){ * @return */ PRInt32 CTagList::GetBottommostIndexOf(nsEntryStack& aTagStack,PRInt32 aStartOffset){ - int max = aTagStack.GetSize(); + int max = aTagStack.GetCount(); int index; for(index=aStartOffset;index*/ 0,&gContainsParam,eHTMLTag_unknown}, + /*parent,incl,exclgroups*/ kSpecial, (kSelf|SPECIALTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, + /*special parents,kids,skip*/ 0,&gContainsParam,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_area, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gAreaParent,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, kInline, kSelf, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, kInlineEntity, kSelf, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ &gAreaParent,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_b, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kFlow|kSelf), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFontStyle, (FSTYPE|kSelf), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_base, @@ -283,63 +307,63 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gInHead, &gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ 0, kNoPropRange, /*special parents,kids,skip*/ &gInHead,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_basefont, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kSpecial, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, SPECIALTYPE, kNone, + /*special props, prop-range*/ 0, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_bdo, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kSpecial, (kSelf|kInline), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, (kSelf|SPECIALTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_bgsound, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kExtensions, kNone, kNone, + /*special props, prop-range*/ 0,kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_big, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kFlow|kSelf), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFontStyle, (FSTYPE|kSelf), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_blink, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kFlow|kSelf), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFontStyle, (kFlowEntity|kSelf), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_blockquote, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_body, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_frameset, /*rootnodes,endrootnodes*/ &gInHTML, &gInHTML, /*autoclose starttags and endtags*/ &gBodyAutoClose,0,0, - /*parent,incl,exclgroups*/ kHTMLContent,(kFlow|kSelf), kNone, - /*special properties*/ kOmitEndTag|kLegalOpen, + /*parent,incl,exclgroups*/ kHTMLContent,(kFlowEntity|kSelf), kNone, + /*special props, prop-range*/ kOmitEndTag|kLegalOpen, kBodyPropRange, /*special parents,kids,skip*/ &gInNoframes,&gBodyKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_br, @@ -347,103 +371,103 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kSpecial, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ 0, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_button, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFormControl, kFlow, kFormControl, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFormControl, kFlowEntity, kFormControl, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gButtonKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_caption, - /*requiredAncestor*/ eHTMLTag_table,eHTMLTag_unknown, - /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, + /*req-parent excl-parent*/ eHTMLTag_table,eHTMLTag_unknown, + /*rootnodes,endrootnodes*/ &gInTable,&gInTable, /*autoclose starttags and endtags*/ &gCaptionAutoClose,0,0, - /*parent,incl,exclgroups*/ kNone, kInline, kSelf, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, kInlineEntity, kSelf, + /*special props, prop-range*/ kNoPropagate,kDefaultPropRange, /*special parents,kids,skip*/ &gInTable,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_center, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, (kInline|kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kBlock, (kInlineEntity|kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_cite, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kPhrase, (kInline|kSelf), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPhrase, (kFlowEntity|kSelf), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_code, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPhrase, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_col, - /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, + /*req-parent excl-parent*/ eHTMLTag_table,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gColParents,&gColParents, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ kOmitWS, + /*special props, prop-range*/ kNoPropagate|kOmitWS,kDefaultPropRange, /*special parents,kids,skip*/ &gColParents,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_colgroup, - /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, - /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, + /*req-parent excl-parent*/ eHTMLTag_table,eHTMLTag_unknown, + /*rootnodes,endrootnodes*/ &gInTable,&gInTable, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ kOmitWS, + /*special props, prop-range*/ kOmitWS|kNoPropagate,kDefaultPropRange, /*special parents,kids,skip*/ &gInTable,&gColgroupKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_dd, - /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, + /*req-parent excl-parent*/ eHTMLTag_dl,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gInDL, &gInDL, /*autoclose starttags and endtags*/ &gDTCloseTags,0,0, - /*parent,incl,exclgroups*/ kNone, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, kFlowEntity, kNone, + /*special props, prop-range*/ kNoPropagate,kDefaultPropRange, /*special parents,kids,skip*/ &gInDL,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_del, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFlowEntity, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ &gInBody,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_dfn, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPhrase, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_dir, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kList, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gULKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_div, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gDivAutoClose,0,0, - /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_dl, @@ -451,63 +475,63 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kBlock, (kSpecial|kFontStyle), kNone, - /*special properties*/ kOmitWS, + /*special props, prop-range*/ kOmitWS, kNoPropRange, /*special parents,kids,skip*/ 0,&gDLKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_dt, - /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, + /*req-parent excl-parent*/ eHTMLTag_dl,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gInDL,&gInDL, /*autoclose starttags and endtags*/ &gDTCloseTags,0,0, - /*parent,incl,exclgroups*/ kNone, kInline, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, kInlineEntity, kNone, + /*special props, prop-range*/ kNoPropagate,kDefaultPropRange, /*special parents, kids
*/ &gInDL,&gDTKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_em, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPhrase, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_embed, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kBlockEntity, kNone, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gContainsParam,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_endnote, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFlowEntity, kFlowEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_fieldset, /*requiredAncestor*/ eHTMLTag_form,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ kOmitWS, + /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ kNoPropagate|kOmitWS,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gFieldsetKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_font, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kSpecial, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, (kSelf|SPECIALTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gFontKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_form, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kBlock, kFlowEntity, kNone, + /*special props, prop-range*/ kNoStyleLeaksIn, kNoPropRange, /*special parents,kids,skip*/ 0,&gFormKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_frame, @@ -515,15 +539,15 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gInFrameset,&gInFrameset, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ kNoPropagate|kNoStyleLeaksIn, kNoPropRange, /*special parents,kids,skip*/ &gInFrameset,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_frameset, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_body, /*rootnodes,endrootnodes*/ &gFramesetParents,&gInHTML, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kNone, kSelf, kNone, - /*special properties*/ kOmitWS, + /*parent,incl,exclgroups*/ kHTMLContent, kSelf, kNone, + /*special props, prop-range*/ kOmitWS|kNoPropagate|kNoStyleLeaksIn, kNoPropRange, /*special parents,kids,skip*/ &gInHTML,&gFramesetKids,eHTMLTag_unknown}, @@ -531,56 +555,56 @@ nsHTMLElement gHTMLElements[] = { /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kHeading, kFlowEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_h2, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kHeading, kFlowEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_h3, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kHeading, kFlowEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_h4, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kHeading, kFlowEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_h5, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kHeading, kFlowEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_h6, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kHeading, kFlowEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_head, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gInHTML, &gInHTML, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kNone, (kHeadContent|kHeadMisc), kNone, - /*special properties*/ kOmitWS, + /*parent,incl,exclgroups*/ kHTMLContent, (kHeadContent|kHeadMisc), kNone, + /*special props, prop-range*/ kOmitWS|kNoStyleLeaksIn, kDefaultPropRange, /*special parents,kids,skip*/ &gInHTML,&gHeadKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_hr, @@ -588,55 +612,55 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gHRAutoClose,0,0, /*parent,incl,exclgroups*/ kBlock, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_html, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_html, /*rootnodes,endrootnodes*/ &gHTMLRootTags, &gHTMLRootTags, - /*autoclose starttags and endtags*/ &gAutoClose,0,0, + /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kHTMLContent, kNone, - /*special properties*/ kOmitEndTag|kOmitWS, + /*special props, prop-range*/ kOmitEndTag|kOmitWS|kNoStyleLeaksIn, kDefaultPropRange, /*special parents,kids,skip*/ 0,&gHtmlKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_i, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFontStyle, (kSelf|FSTYPE), kNone, + /*special props, prop-range*/ 0, kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_iframe, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kSpecial, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, (kSelf|SPECIALTYPE), kNone, + /*special props, prop-range*/ kNoStyleLeaksIn, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_ilayer, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kBlock, kFlowEntity, kNone, + /*special props, prop-range*/ kNoStyleLeaksIn, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_image, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, kNone, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_img, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, kNone, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_input, @@ -644,31 +668,31 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kFormControl, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_ins, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, (kSelf|kNone), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFlowEntity, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_isindex, - /*requiredAncestor*/ eHTMLTag_form,eHTMLTag_unknown, + /*requiredAncestor*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ (kBlock|kHeadContent), kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ (kBlock|kHeadContent), kFlowEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ &gInBody,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_kbd, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kPhrase, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPhrase, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_keygen, @@ -676,39 +700,39 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_label, - /*requiredAncestor*/ eHTMLTag_form,eHTMLTag_unknown, + /*req-parent excl-parent*/ eHTMLTag_form,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFormControl, kInline, kSelf, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFormControl, kInlineEntity, kSelf, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_layer, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, kFlow, kSelf, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kBlock, kFlowEntity, kSelf, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_legend, /*requiredAncestor*/ eHTMLTag_form,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gInFieldset,&gInFieldset, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kNone, kInline, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, kInlineEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ &gInFieldset,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_li, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gLIRootTags,&gLIRootTags, /*autoclose starttags and endtags*/ &gLIAutoClose,0,0, - /*parent,incl,exclgroups*/ kList, kFlow, kSelf, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFlowEntity, kFlowEntity, kSelf, + /*special props, prop-range*/ kNoPropagate, kDefaultPropRange, /*special parents,kids,skip*/ 0,&gLIKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_link, @@ -716,31 +740,31 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gInHead,&gInHead, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kHeadMisc, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ &gInHead,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_listing, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPreformatted, kNone, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_map, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kSpecial, kBlock, kNone, - /*special properties*/ kOmitWS, + /*parent,incl,exclgroups*/ kSpecial, SPECIALTYPE, kNone, + /*special props, prop-range*/ kOmitWS, kDefaultPropRange, /*special parents,kids,skip*/ 0,&gMapKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_menu, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kList, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kList, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gULKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_meta, @@ -748,23 +772,23 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gInHead, &gInHead, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kHeadMisc, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ kNoStyleLeaksIn, kDefaultPropRange, /*special parents,kids,skip*/ &gInHead,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_multicol, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kExtensions, kNone, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_nobr, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, (kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kExtensions, (kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_noembed, @@ -772,15 +796,15 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ kDiscardTag, + /*special props, prop-range*/ kDiscardTag, kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_noembed}, { /*tag*/ eHTMLTag_noframes, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gNoframeRoot,&gNoframeRoot, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ kDiscardTag, + /*parent,incl,exclgroups*/ kBlock, kFlowEntity, kNone, + /*special props, prop-range*/ kDiscardTag, kNoPropRange, /*special parents,kids,skip*/ &gNoframeRoot,&gNoframesKids,eHTMLTag_noframes}, { /*tag*/ eHTMLTag_nolayer, @@ -788,31 +812,31 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ kDiscardTag, + /*special props, prop-range*/ kDiscardTag, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_nolayer}, { /*tag*/ eHTMLTag_noscript, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, kFlow, kNone, - /*special properties*/ kDiscardTag, + /*parent,incl,exclgroups*/ kBlock, kFlowEntity, kNone, + /*special props, prop-range*/ kDiscardTag, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_noscript}, { /*tag*/ eHTMLTag_object, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ (kHeadMisc|kSpecial), (kFlow|kSelf), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ (kHeadMisc|kSpecial), (SPECIALTYPE|kSelf), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gContainsParam,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_ol, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gOLRootTags,&gOLRootTags, /*autoclose starttags and endtags*/ &gOLAutoClose, &gULCloseTags, 0, - /*parent,incl,exclgroups*/ kBlock, (kFlow|kSelf), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kList, (kFlowEntity|kSelf), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gULKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_optgroup, @@ -820,79 +844,79 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gOptgroupParents,&gOptgroupParents, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ &gOptgroupParents,&gContainsOpts,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_option, /*requiredAncestor*/ eHTMLTag_form,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gOptgroupParents,&gOptgroupParents, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kNone, kPCDATA, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, kPCDATA, kFlowEntity, + /*special props, prop-range*/ kNoStyleLeaksIn, kDefaultPropRange, /*special parents,kids,skip*/ &gOptgroupParents,&gContainsText,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_p, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, - /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, + /*rootnodes,endrootnodes*/ &gInBody,&gInBody, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, kInline, kNone, //this used to contain FLOW. But it's really an inline container. - /*special properties*/ 0, //otherwise it tries to contain things like H1..H6 + /*parent,incl,exclgroups*/ kBlock, kInlineEntity, kNone, //this used to contain FLOW. But it's really an inline container. + /*special props, prop-range*/ 0,kDefaultPropRange, //otherwise it tries to contain things like H1..H6 /*special parents,kids,skip*/ 0,&gInP,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_param, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gParamParents, &gParamParents, /*autoclose starttags and endtags*/ &gPAutoClose,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, kNone, kNone, + /*special props, prop-range*/ 0, kNoPropRange, /*special parents,kids,skip*/ &gParamParents,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_parsererror, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gDivAutoClose,0,0, - /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_plaintext, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kFlow, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kExtensions, kFlowEntity, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_html}, { /*tag*/ eHTMLTag_pre, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kPreformatted, kInline, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPreformatted, kFlowEntity, kNone, //I'm allowing WAY too much in here. Spec says inline. + /*special props, prop-range*/ kNoStyleLeaksIn, kDefaultPropRange, /*special parents,kids,skip*/ 0,&gPreKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_q, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kSpecial, (kSelf|kInline), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, (kSelf|SPECIALTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, - + { /*tag*/ eHTMLTag_s, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFontStyle, (kSelf|FSTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_samp, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPhrase, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_script, @@ -900,15 +924,15 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ (kSpecial|kHeadMisc), kPCDATA, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ kNoStyleLeaksIn, kNoPropRange, /*special parents,kids,skip*/ 0,&gContainsText,eHTMLTag_script}, { /*tag*/ eHTMLTag_select, /*requiredAncestor*/ eHTMLTag_form, eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gInForm,&gInForm, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFormControl, kNone, kNone, - /*special properties*/ kOmitWS, + /*parent,incl,exclgroups*/ kFormControl, kNone, kFlowEntity, + /*special props, prop-range*/ kOmitWS|kNoStyleLeaksIn, kDefaultPropRange, /*special parents,kids,skip*/ &gInForm,&gContainsOpts,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_server, @@ -916,15 +940,15 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ kNoStyleLeaksIn, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_small, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFontStyle, (kSelf|FSTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_sound, @@ -932,47 +956,47 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_sourcetext, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ &gDivAutoClose,0,0, - /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_spacer, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kExtensions, kNone, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_span, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kSpecial, (kSelf|kInline), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, (kSelf|SPECIALTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_strike, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFontStyle, (kSelf|FSTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_strong, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ (kPhrase|kFontStyle), (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPhrase, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gContainsText,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_style, @@ -980,55 +1004,55 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gInHead, &gInHead, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kHeadMisc, kPCDATA, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ kNoStyleLeaksIn, kNoPropRange, /*special parents,kids,skip*/ &gInHead,0,eHTMLTag_style}, { /*tag*/ eHTMLTag_sub, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, (kSelf|SPECIALTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_sup, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kSpecial, (kSelf|SPECIALTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_table, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gInBody, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kBlock, kNone, kSelf, - /*special properties*/ (kOmitWS|kBadContentWatch), + /*parent,incl,exclgroups*/ kBlock, kNone, (kSelf|kInlineEntity), + /*special props, prop-range*/ (kOmitWS|kBadContentWatch|kNoStyleLeaksIn), 2, /*special parents,kids,skip*/ 0,&gTableKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_tbody, /*requiredAncestor*/ eHTMLTag_table, eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gInTable, &gInTable, /*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0, - /*parent,incl,exclgroups*/ kNone, kNone, kSelf, - /*special properties*/ (kOmitWS|kBadContentWatch), + /*parent,incl,exclgroups*/ kNone, kNone, (kSelf|kInlineEntity), + /*special props, prop-range*/ (kNoPropagate|kOmitWS|kBadContentWatch|kNoStyleLeaksIn), kDefaultPropRange, /*special parents,kids,skip*/ &gInTable,&gTBodyKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_td, /*requiredAncestor*/ eHTMLTag_table, eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gTDRootTags,&gTDRootTags, /*autoclose starttags and endtags*/ &gTDCloseTags,&gTDCloseTags,0, - /*parent,incl,exclgroups*/ kNone, kFlow, kSelf, - /*special properties*/ 0, - /*special parents,kids,skip*/ &gTDRootTags,0,eHTMLTag_unknown}, + /*parent,incl,exclgroups*/ kNone, kFlowEntity, kSelf, + /*special props, prop-range*/ kNoStyleLeaksIn, kDefaultPropRange, + /*special parents,kids,skip*/ &gTDRootTags,&gBodyKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_textarea, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gInForm, &gInForm, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kFormControl, kPCDATA, kNone, - /*special properties*/ 0, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ &gInForm,&gContainsText,eHTMLTag_textarea}, { /*tag*/ eHTMLTag_tfoot, @@ -1036,15 +1060,15 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gInTable, &gInTable, /*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kSelf, - /*special properties*/ (kOmitWS|kBadContentWatch), + /*special props, prop-range*/ (kNoPropagate|kOmitWS|kBadContentWatch|kNoStyleLeaksIn), kNoPropRange, /*special parents,kids,skip*/ &gInTable,&gTableElemKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_th, /*requiredAncestor*/ eHTMLTag_table, eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gTDRootTags,&gTDRootTags, /*autoclose starttags and endtags*/ &gTDCloseTags,&gTDCloseTags,0, - /*parent,incl,exclgroups*/ kNone, kFlow, kSelf, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kNone, kFlowEntity, kSelf, + /*special props, prop-range*/ kNoStyleLeaksIn, kDefaultPropRange, /*special parents,kids,skip*/ &gTDRootTags,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_thead, @@ -1052,111 +1076,111 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gInTable,&gInTable, /*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kSelf, - /*special properties*/ (kOmitWS|kBadContentWatch), + /*special props, prop-range*/ (kNoPropagate|kOmitWS|kBadContentWatch|kNoStyleLeaksIn), kNoPropRange, /*special parents,kids,skip*/ &gInTable,&gTableElemKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_title, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gInHead,&gInHead, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kNone, (kHeadMisc|kPCDATA), kNone, - /*special properties*/ kOmitWS, + /*parent,incl,exclgroups*/ kHeadMisc,kPCDATA, kNone, + /*special props, prop-range*/ kOmitWS|kNoStyleLeaksIn, kNoPropRange, /*special parents,kids,skip*/ &gInHead,&gContainsText,eHTMLTag_title}, { /*tag*/ eHTMLTag_tr, /*requiredAncestor*/ eHTMLTag_table, eHTMLTag_unknown, - /*rootnodes,endrootnodes*/ &gTRParents,&gTRParents, + /*rootnodes,endrootnodes*/ &gTRParents,&gTREndParents, /*autoclose starttags and endtags*/ &gTRCloseTags,0,0, - /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ (kOmitWS|kBadContentWatch), + /*parent,incl,exclgroups*/ kNone, kNone, kInlineEntity, + /*special props, prop-range*/ (kOmitWS|kBadContentWatch|kNoStyleLeaksIn), kNoPropRange, /*special parents,kids,skip*/ &gTRParents,&gTRKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_tt, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFontStyle, (kSelf|FSTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_u, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFontStyle, (kSelf|FSTYPE), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_ul, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gOLRootTags,&gOLRootTags, /*autoclose starttags and endtags*/ &gOLAutoClose,&gULCloseTags,0, - /*parent,incl,exclgroups*/ kBlock, (kFlow|kSelf), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kList, (kFlowEntity|kSelf), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,&gULKids,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_var, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kPhrase, (kSelf|kFlowEntity), kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_wbr, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kExtensions, kNone, kNone, + /*special props, prop-range*/ 0,kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_xmp, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, - /*special parents,kids,skip*/ 0,0,eHTMLTag_xmp}, + /*parent,incl,exclgroups*/ kPreformatted, kNone, kNone, + /*special props, prop-range*/ 0,kDefaultPropRange, + /*special parents,kids,skip*/ 0,0,eHTMLTag_xmp}, { /*tag*/ eHTMLTag_text, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, - /*rootnodes,endrootnodes*/ &gTextRootTags,&gTextRootTags, + /*rootnodes,endrootnodes*/ &gInBody,&gInBody, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFlowEntity, kNone, kNone, + /*special props, prop-range*/ 0,kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_whitespace, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, - /*rootnodes,endrootnodes*/ &gTextRootTags,&gTextRootTags, + /*rootnodes,endrootnodes*/ &gInBody,&gInBody, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFlowEntity, kNone, kNone, + /*special props, prop-range*/ 0,kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_newline, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, - /*rootnodes,endrootnodes*/ &gTextRootTags,&gTextRootTags, + /*rootnodes,endrootnodes*/ &gInBody,&gInBody, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFlowEntity, kNone, kNone, + /*special props, prop-range*/ 0, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_comment, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ kOmitEndTag, + /*parent,incl,exclgroups*/ kFlowEntity, kNone, kNone, + /*special props, prop-range*/ kOmitEndTag,kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_entity, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown, - /*rootnodes,endrootnodes*/ &gTextRootTags,&gTextRootTags, + /*rootnodes,endrootnodes*/ &gInBody,&gInBody, /*autoclose starttags and endtags*/ 0,0,0, - /*parent,incl,exclgroups*/ kFlow, kNone, kNone, - /*special properties*/ 0, + /*parent,incl,exclgroups*/ kFlowEntity, kNone, kNone, + /*special props, prop-range*/ 0, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, { /*tag*/ eHTMLTag_userdefined, @@ -1164,7 +1188,7 @@ nsHTMLElement gHTMLElements[] = { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0, /*parent,incl,exclgroups*/ kNone, kNone, kNone, - /*special properties*/ kOmitEndTag, + /*special props, prop-range*/ kOmitEndTag, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown}, }; @@ -1203,14 +1227,16 @@ PRBool nsHTMLElement::IsContainer(eHTMLTags aChild) { if(!result){ static eHTMLTags gNonContainers[]={ eHTMLTag_unknown, - eHTMLTag_area, eHTMLTag_base, eHTMLTag_basefont, - eHTMLTag_br, eHTMLTag_col, eHTMLTag_embed, - eHTMLTag_frame, eHTMLTag_hr, eHTMLTag_whitespace, - eHTMLTag_input, eHTMLTag_link, eHTMLTag_isindex, - eHTMLTag_meta, eHTMLTag_param, eHTMLTag_plaintext, - eHTMLTag_style, eHTMLTag_spacer, eHTMLTag_wbr, - eHTMLTag_newline, eHTMLTag_text, eHTMLTag_img, - eHTMLTag_unknown, eHTMLTag_xmp}; + eHTMLTag_area, eHTMLTag_base, eHTMLTag_basefont, + eHTMLTag_br, eHTMLTag_col, eHTMLTag_embed, + eHTMLTag_frame, eHTMLTag_hr, + eHTMLTag_img, eHTMLTag_image, eHTMLTag_input, + eHTMLTag_link, eHTMLTag_isindex, eHTMLTag_meta, + eHTMLTag_newline, eHTMLTag_param, eHTMLTag_plaintext, + eHTMLTag_style, eHTMLTag_spacer, eHTMLTag_text, + eHTMLTag_unknown, eHTMLTag_wbr, eHTMLTag_whitespace, + eHTMLTag_xmp}; + result=!FindTagInSet(aChild,gNonContainers,sizeof(gNonContainers)/sizeof(eHTMLTag_unknown)); } @@ -1226,22 +1252,7 @@ PRBool nsHTMLElement::IsContainer(eHTMLTags aChild) { */ inline PRBool TestBits(int aBitset,int aTest) { PRInt32 result=aBitset & aTest; - return PRBool(result==aTest); -} - -/** - * - * @update gess 01/04/99 - * @param - * @return - */ -PRBool nsHTMLElement::IsContainerType(eHTMLTags aTag,int aType) { - PRBool result=PR_FALSE; - - if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_userdefined)){ - result=TestBits(gHTMLElements[aTag].mInclusionBits,aType); - } - return result; + return (aTest) ? PRBool(result==aTest) : PR_FALSE; //was aTest } @@ -1251,11 +1262,11 @@ PRBool nsHTMLElement::IsContainerType(eHTMLTags aTag,int aType) { * @param * @return */ -PRBool nsHTMLElement::IsBlockElement(eHTMLTags aTag){ +PRBool nsHTMLElement::IsBlockEntity(eHTMLTags aTag){ PRBool result=PR_FALSE; if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_userdefined)){ - result=TestBits(gHTMLElements[aTag].mParentBits,kBlock); + result=TestBits(gHTMLElements[aTag].mParentBits,kBlockEntity); } return result; } @@ -1272,11 +1283,12 @@ PRBool nsHTMLElement::IsBlockCloser(eHTMLTags aTag){ if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_userdefined)){ // result=IsFlowElement(aTag); - result=gHTMLElements[aTag].IsMemberOf(kFlow); + result=gHTMLElements[aTag].IsMemberOf(kBlockEntity); //was kFlowEntity... if(!result) { - static eHTMLTags gClosers[]={ eHTMLTag_table,eHTMLTag_caption,eHTMLTag_dd,eHTMLTag_dt, - eHTMLTag_td,eHTMLTag_tfoot,eHTMLTag_th,eHTMLTag_thead,eHTMLTag_tr}; + static eHTMLTags gClosers[]={ eHTMLTag_table,eHTMLTag_tbody,eHTMLTag_caption,eHTMLTag_dd,eHTMLTag_dt, + eHTMLTag_td,eHTMLTag_tfoot,eHTMLTag_th,eHTMLTag_thead,eHTMLTag_tr, + eHTMLTag_optgroup}; result=FindTagInSet(aTag,gClosers,sizeof(gClosers)/sizeof(eHTMLTag_body)); } } @@ -1290,10 +1302,10 @@ PRBool nsHTMLElement::IsBlockCloser(eHTMLTags aTag){ * @param * @return */ -PRBool nsHTMLElement::IsInlineElement(eHTMLTags aTag){ +PRBool nsHTMLElement::IsInlineEntity(eHTMLTags aTag){ PRBool result=PR_FALSE; if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_userdefined)){ - result=TestBits(gHTMLElements[aTag].mParentBits,kInline); + result=TestBits(gHTMLElements[aTag].mParentBits,kInlineEntity); } return result; } @@ -1304,11 +1316,11 @@ PRBool nsHTMLElement::IsInlineElement(eHTMLTags aTag){ * @param * @return */ -PRBool nsHTMLElement::IsFlowElement(eHTMLTags aTag){ +PRBool nsHTMLElement::IsFlowEntity(eHTMLTags aTag){ PRBool result=PR_FALSE; if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_userdefined)){ - result=TestBits(gHTMLElements[aTag].mParentBits,kFlow); + result=TestBits(gHTMLElements[aTag].mParentBits,kFlowEntity); } return result; } @@ -1322,7 +1334,7 @@ PRBool nsHTMLElement::IsFlowElement(eHTMLTags aTag){ PRBool nsHTMLElement::IsBlockParent(eHTMLTags aTag){ PRBool result=PR_FALSE; if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_userdefined)){ - result=TestBits(gHTMLElements[aTag].mInclusionBits,kBlock); + result=TestBits(gHTMLElements[aTag].mInclusionBits,kBlockEntity); } return result; } @@ -1337,7 +1349,7 @@ PRBool nsHTMLElement::IsBlockParent(eHTMLTags aTag){ PRBool nsHTMLElement::IsInlineParent(eHTMLTags aTag){ PRBool result=PR_FALSE; if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_userdefined)){ - result=TestBits(gHTMLElements[aTag].mInclusionBits,kInline); + result=TestBits(gHTMLElements[aTag].mInclusionBits,kInlineEntity); } return result; } @@ -1352,7 +1364,7 @@ PRBool nsHTMLElement::IsInlineParent(eHTMLTags aTag){ PRBool nsHTMLElement::IsFlowParent(eHTMLTags aTag){ PRBool result=PR_FALSE; if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_userdefined)){ - result=TestBits(gHTMLElements[aTag].mInclusionBits,kFlow); + result=TestBits(gHTMLElements[aTag].mInclusionBits,kFlowEntity); } return result; } @@ -1399,8 +1411,34 @@ PRBool nsHTMLElement::CanContain(eHTMLTags aParent,eHTMLTags aChild){ * @param * @return */ -PRBool nsHTMLElement::CanOmitEndTag(eHTMLTags aParent) const{ - PRBool result=TestBits(mSpecialProperties,kOmitEndTag); +PRBool nsHTMLElement::CanExclude(eHTMLTags aChild) const{ + PRBool result=PR_FALSE; + + //Note that special kids takes precedence over exclusions... + if(mSpecialKids) { + if(mSpecialKids->Contains(aChild)) { + return PR_FALSE; + } + } + + if(eHTMLTag_unknown!=mExclusionBits){ + if(gHTMLElements[aChild].IsMemberOf(mExclusionBits)) { + result=PR_TRUE; + } + } + return result; +} + +/** + * + * @update gess 01/04/99 + * @param + * @return + */ +PRBool nsHTMLElement::CanOmitEndTag(void) const{ + PRBool result=!IsContainer(mTagID); + if(!result) + result=TestBits(mSpecialProperties,kOmitEndTag); return result; } @@ -1476,7 +1514,8 @@ PRBool nsHTMLElement::IsHeadingTag(eHTMLTags aChild) { * @return */ PRBool nsHTMLElement::CanContainType(PRInt32 aType) const{ - PRBool result=(aType && TestBits(mInclusionBits,aType)); + PRInt32 answer=mInclusionBits & aType; + PRBool result=PRBool(0!=answer); return result; } @@ -1515,11 +1554,79 @@ PRBool nsHTMLElement::IsTextTag(eHTMLTags aChild) { return result; } -PRBool nsHTMLElement::CanContainSelf() const { +/** + * + * @update gess12/13/98 + * @param + * @return + */ +PRBool nsHTMLElement::CanContainSelf(void) const { PRBool result=PRBool(TestBits(mInclusionBits,kSelf)!=0); return result; } +/** + * + * @update gess12/13/98 + * @param + * @return + */ +eHTMLTags nsHTMLElement::GetCloseTargetForEndTag(nsEntryStack& aTagStack,PRInt32 anIndex) const{ + eHTMLTags result=eHTMLTag_unknown; + + int theCount=aTagStack.GetCount(); + int theIndex=theCount; + if(IsMemberOf(kPhrase)){ + while((--theIndex>=anIndex) && (eHTMLTag_unknown==result)){ + eHTMLTags theTag=aTagStack.TagAt(theIndex); + if(theTag!=mTagID) { + //phrasal elements can close other phrasals, along with fontstyle and special tags... + if(!gHTMLElements[theTag].IsMemberOf(kSpecial|kFontStyle|kPhrase)) { + break; //it's not something I can close + } + } + else { + result=theTag; //stop because you just found yourself on the stack + break; + } + } + } + else if(IsMemberOf(kSpecial)){ + while((--theIndex>=anIndex) && (eHTMLTag_unknown==result)){ + eHTMLTags theTag=aTagStack.TagAt(theIndex); + if(theTag!=mTagID) { + //phrasal elements can close other phrasals, along with fontstyle and special tags... + if(gHTMLElements[theTag].IsMemberOf(kSpecial) || + gHTMLElements[theTag].IsMemberOf(kFontStyle)){ + } + else { + break; //it's not something I can close + } + } + else { + result=theTag; //stop because you just found yourself on the stack + break; + } + } + } + else if(IsMemberOf(kFormControl|kExtensions)){ + while((--theIndex>=anIndex) && (eHTMLTag_unknown==result)){ + eHTMLTags theTag=aTagStack.TagAt(theIndex); + if(theTag!=mTagID) { + if(!CanContain(theTag)) { + break; //it's not something I can close + } + } + else { + result=theTag; //stop because you just found yourself on the stack + break; + } + } + } + return result; +} + + /** * See whether this tag can DIRECTLY contain the given child. * @update gess12/13/98 @@ -1541,13 +1648,13 @@ PRBool nsHTMLElement::CanContain(eHTMLTags aChild) const{ } - if(nsHTMLElement::IsInlineElement(aChild)){ + if(nsHTMLElement::IsInlineEntity(aChild)){ if(nsHTMLElement::IsInlineParent(mTagID)){ return PR_TRUE; } } - if(nsHTMLElement::IsFlowElement(aChild)) { + if(nsHTMLElement::IsFlowEntity(aChild)) { if(nsHTMLElement::IsFlowParent(mTagID)){ return PR_TRUE; } @@ -1559,7 +1666,7 @@ PRBool nsHTMLElement::CanContain(eHTMLTags aChild) const{ } } - if(nsHTMLElement::IsBlockElement(aChild)){ + if(nsHTMLElement::IsBlockEntity(aChild)){ if(nsHTMLElement::IsBlockParent(mTagID) || IsStyleTag(mTagID)){ return PR_TRUE; } @@ -1595,3 +1702,151 @@ PRBool nsHTMLElement::HasSpecialProperty(PRInt32 aProperty) const{ return result; } +void nsHTMLElement::DebugDumpContainment(const char* aFilename,const char* aTitle){ + + PRBool t=CanContain(eHTMLTag_address,eHTMLTag_object); + + const char* prefix=" "; + fstream out(aFilename,ios::out); + out << "==================================================" << endl; + out << aTitle << endl; + out << "=================================================="; + int i,j=0; + int written; + int linenum=5; + for(i=1;i" << endl; + out << prefix; + linenum+=3; + written=0; + char startChar=0; + if(IsContainer((eHTMLTags)i)) { + for(j=1;j"); - - CTokenRecycler* theRecycler=(CTokenRecycler*)GetTokenRecycler(); - aToken=theRecycler->CreateTokenOfType(eToken_skippedcontent,aChildTag,endTag); - return aToken->Consume(aChar,aScanner); //tell new token to finish consuming text... -} - -/** - * + * 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. * @update gess12/28/98 * @param * @return */ -nsresult nsHTMLTokenizer::HandleSkippedContent(nsScanner& aScanner,CToken*& aToken) { +nsresult nsHTMLTokenizer::ConsumeScriptContent(nsScanner& aScanner,CToken*& aToken) { nsresult result=NS_OK; - eHTMLTags theTag=(eHTMLTags)aToken->GetTypeID(); - if(eHTMLTag_unknown!=gHTMLElements[theTag].mSkipTarget) { - - //Do special case handling for "); + CTokenRecycler* theRecycler=(CTokenRecycler*)GetTokenRecycler(); + CToken* textToken=theRecycler->CreateTokenOfType(eToken_text,theTag,endTag); + result=((CTextToken*)textToken)->ConsumeUntil(0,aScanner,endTag); //tell new token to finish consuming text... + AddToken(textToken,result,mTokenDeque,theRecycler); + CToken* endToken=theRecycler->CreateTokenOfType(eToken_end,theTag); + AddToken(endToken,result,mTokenDeque,theRecycler); } //EEEEECCCCKKKK!!! diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.h b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.h index 65a3e96f1a9..3c8a4a12468 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.h +++ b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.h @@ -69,7 +69,7 @@ public: protected: - virtual nsresult HandleSkippedContent(nsScanner& aScanner,CToken*& aToken); + virtual nsresult ConsumeScriptContent(nsScanner& aScanner,CToken*& aToken); virtual nsresult ConsumeTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); virtual nsresult ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); virtual nsresult ConsumeEndTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); @@ -79,7 +79,6 @@ protected: virtual nsresult ConsumeComment(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); virtual nsresult ConsumeNewline(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); virtual nsresult ConsumeText(const nsString& aString,CToken*& aToken,nsScanner& aScanner); - virtual nsresult ConsumeContentToEndTag(PRUnichar aChar,eHTMLTags aChildTag,nsScanner& aScanner,CToken*& aToken); virtual nsresult ConsumeProcessingInstruction(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); static void AddToken(CToken*& aToken,nsresult aResult,nsDeque& aDeque,CTokenRecycler* aRecycler); diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp index d06836445aa..5d11f8a8ff3 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp @@ -29,7 +29,6 @@ #include "nsHTMLTags.h" #include "nsHTMLEntities.h" #include "nsCRT.h" -#include "nsStr.h" //#define GESS_MACHINE #ifdef GESS_MACHINE @@ -79,7 +78,6 @@ void CHTMLToken::SetStringValue(const char* name){ } } - /* * constructor from tag id * @@ -272,6 +270,19 @@ void CStartToken::DebugDumpSource(ostream& out) { out << ">"; } +/* + * + * + * @update gess 3/25/98 + * @param anOutputString will recieve the result + * @return nada + */ +void CStartToken::GetSource(nsString& anOutputString){ + anOutputString="<"; + anOutputString+=mTextValue; + if(!mAttributed) + anOutputString+=">"; +} /* * constructor from tag id @@ -303,7 +314,6 @@ CEndToken::CEndToken(const nsString& aName) : CHTMLToken(aName) { * @return error result */ nsresult CEndToken::Consume(PRUnichar aChar, nsScanner& aScanner) { - //if you're here, we've already Consumed the '. @@ -388,6 +398,19 @@ void CEndToken::DebugDumpSource(ostream& out) { out << ""; } +/* + * + * + * @update gess 3/25/98 + * @param anOutputString will recieve the result + * @return nada + */ +void CEndToken::GetSource(nsString& anOutputString){ + anOutputString=""; +} + /* * default constructor * @@ -474,6 +497,70 @@ nsresult CTextToken::Consume(PRUnichar aChar, nsScanner& aScanner) { return result; } +/* + * Consume as much clear text from scanner as possible. + * + * @update gess 3/25/98 + * @param aChar -- last char consumed from stream + * @param aScanner -- controller of underlying input source + * @return error result + */ +nsresult CTextToken::ConsumeUntil(PRUnichar aChar,nsScanner& aScanner,nsString& aTerminalString){ + PRBool done=PR_FALSE; + nsresult result=NS_OK; + nsString temp; + PRUnichar theChar; + + //We're going to try a new algorithm here. Rather than scan for the matching + //end tag like we used to do, we're now going to scan for whitespace and comments. + //If we find either, just eat them. If we find text or a tag, then go to the + //target endtag, or the start of another comment. + + static nsAutoString theWhitespace2("\b\t "); + + while((!done) && (NS_OK==result)) { + result=aScanner.GetChar(aChar); + if((NS_OK==result) && (kLessThan==aChar)) { + //we're reading a tag or a comment... + result=aScanner.GetChar(theChar); + if((NS_OK==result) && (kExclamation==theChar)) { + //read a comment... + static CCommentToken theComment; + result=theComment.Consume(aChar,aScanner); + if(NS_OK==result) { + //result=aScanner.SkipWhitespace(); + //temp.Append(""); + } + } else { + //read a tag... + temp+=aChar; + temp+=theChar; + result=aScanner.ReadUntil(temp,kGreaterThan,PR_TRUE); + } + } + else if(0<=theWhitespace2.BinarySearch(aChar)) { + static CWhitespaceToken theWS; + result=theWS.Consume(aChar,aScanner); + if(NS_OK==result) { + temp.Append(theWS.GetStringValueXXX()); + } + } + else { + temp+=aChar; + result=aScanner.ReadUntil(temp,kLessThan,PR_FALSE); + } + nsAutoString theRight; + temp.Right(theRight,aTerminalString.Length()); + done=PRBool(0==theRight.Compare(aTerminalString,PR_TRUE)); + } //while + int len=temp.Length(); + temp.Truncate(len-aTerminalString.Length()); + mTextValue=temp; + return result; +} + /* * default constructor * @@ -759,14 +846,16 @@ nsresult CCommentToken::Consume(PRUnichar aChar, nsScanner& aScanner) { PRBool theStrictForm=PR_FALSE; nsresult result=(theStrictForm) ? ConsumeStrictComment(aChar,aScanner,mTextValue) : ConsumeComment(aChar,aScanner,mTextValue); +/* //this change is here to make the editor teams' life easier. //I'm removing the leading and trailing markup... -/* + if(0==mTextValue.Find(""; } +/* + * + * + * @update gess 3/25/98 + * @param anOutputString will recieve the result + * @return nada + */ +void CSkippedContentToken::GetSource(nsString& anOutputString){ + anOutputString="$skipped-content"; +} /** * diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokens.h b/mozilla/parser/htmlparser/src/nsHTMLTokens.h index bd01a0a9c7d..a95fa715018 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLTokens.h +++ b/mozilla/parser/htmlparser/src/nsHTMLTokens.h @@ -43,6 +43,7 @@ #include "nsHTMLTags.h" #include "nsParserError.h" #include +#include "nsString.h" class nsScanner; @@ -121,6 +122,8 @@ class CStartToken: public CHTMLToken { PRBool IsEmpty(void); void SetEmpty(PRBool aValue); virtual void DebugDumpSource(ostream& out); + virtual void GetSource(nsString& anOutputString); + virtual void Reinitialize(PRInt32 aTag, const nsString& aString); protected: @@ -145,6 +148,7 @@ class CEndToken: public CHTMLToken { virtual const char* GetClassName(void); virtual PRInt32 GetTokenType(void); virtual void DebugDumpSource(ostream& out); + virtual void GetSource(nsString& anOutputString); }; @@ -184,11 +188,8 @@ class CEntityToken : public CHTMLToken { virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner); static PRInt32 ConsumeEntity(PRUnichar aChar,nsString& aString,nsScanner& aScanner); static PRInt32 TranslateToUnicodeStr(PRInt32 aValue,nsString& aString); -// static PRInt32 FindEntityIndex(nsString& aString); -// static PRInt32 FindEntityIndexMax(const char* aBuffer,PRInt32 aCount=-1); -// static PRBool VerifyEntityTable(void); -// static PRInt32 ReduceEntities(nsString& aString); virtual void DebugDumpSource(ostream& out); + virtual void GetSource(nsString& anOutputString); }; @@ -220,6 +221,7 @@ class CTextToken: public CHTMLToken { CTextToken(); CTextToken(const nsString& aString); virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner); + nsresult ConsumeUntil(PRUnichar aChar,nsScanner& aScanner,nsString& aTerminalString); virtual const char* GetClassName(void); virtual PRInt32 GetTokenType(void); }; @@ -261,6 +263,7 @@ class CAttributeToken: public CHTMLToken { virtual PRInt32 GetTokenType(void); virtual nsString& GetKey(void) {return mTextKey;} virtual void DebugDumpToken(ostream& out); + virtual void GetSource(nsString& anOutputString); virtual void DebugDumpSource(ostream& out); PRBool mLastAttribute; virtual void Reinitialize(PRInt32 aTag, const nsString& aString); @@ -337,6 +340,7 @@ class CSkippedContentToken: public CAttributeToken { virtual const char* GetClassName(void); virtual PRInt32 GetTokenType(void); virtual void DebugDumpSource(ostream& out); + virtual void GetSource(nsString& anOutputString); protected: }; diff --git a/mozilla/parser/htmlparser/src/nsIParser.h b/mozilla/parser/htmlparser/src/nsIParser.h index 13af7417248..3d9210219a5 100644 --- a/mozilla/parser/htmlparser/src/nsIParser.h +++ b/mozilla/parser/htmlparser/src/nsIParser.h @@ -186,6 +186,7 @@ class nsIParser : public nsISupports { * @return ptr to scanner */ virtual eParseMode GetParseMode(void)=0; + }; /* ===========================================================* diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp index 6d1f479774a..3c1be67405c 100644 --- a/mozilla/parser/htmlparser/src/nsParser.cpp +++ b/mozilla/parser/htmlparser/src/nsParser.cpp @@ -47,16 +47,8 @@ static const char* kNullURL = "Error: Null URL given"; static const char* kOnStartNotCalled = "Error: OnStartBinding() must be called before OnDataAvailable()"; static const char* kBadListenerInit = "Error: Parser's IStreamListener API was not setup correctly in constructor."; +//------------------------------------------------------------------- -class CTokenDeallocator: public nsDequeFunctor{ -public: - virtual void* operator()(void* anObject) { - CToken* aToken = (CToken*)anObject; - delete aToken; - return 0; - } -}; - class CDTDDeallocator: public nsDequeFunctor{ public: @@ -67,6 +59,8 @@ public: } }; +//------------------------------------------------------------------- + class CDTDFinder: public nsDequeFunctor{ public: CDTDFinder(nsIDTD* aDTD) { @@ -83,6 +77,8 @@ public: nsIDTD* mTargetDTD; }; +//------------------------------------------------------------------- + class CSharedParserObjects { public: @@ -128,14 +124,6 @@ public: nsString nsParser::gHackMetaCharset = ""; nsString nsParser::gHackMetaCharsetURL = ""; -//------------------------------------------------------------------------- - -CSharedParserObjects& GetSharedObjects() { - static CSharedParserObjects gSharedParserObjects; - return gSharedParserObjects; -} - - /********************************************************************************** This class is used as an interface between an external agent (like the DOM) and the parser. It will contain a stack full of tagnames, which is used in our @@ -173,8 +161,13 @@ public: nsDeque mTags; //will hold a deque of prunichars... }; +//------------------------------------------------------------------- -//------------------------------------------------------------------------- + +CSharedParserObjects& GetSharedObjects() { + static CSharedParserObjects gSharedParserObjects; + return gSharedParserObjects; +} /** * default constructor @@ -429,18 +422,28 @@ eParseMode DetermineParseMode(nsParser& aParser) { nsScanner* theScanner=aParser.GetScanner(); if(theScanner){ + nsString theBufCopy; nsString& theBuffer=theScanner->GetBuffer(); - PRInt32 theIndex=theBuffer.Find("HTML 4.0"); - if(kNotFound==theIndex) - theIndex=theBuffer.Find("html 4.0"); - if(kNotFound' + PRInt32 theSubIndex=theBufCopy.Find(kGreaterThan,theIndex+1); + theBufCopy.Truncate(theSubIndex); + theSubIndex=theBufCopy.Find("HTML 4.0"); + if(kNotFoundmKey!=aKey)) { @@ -1176,6 +1179,7 @@ void nsParser::DebugDumpSource(ostream& aStream) { } } + /** * Call this to get a newly constructed tagstack * @update gess 5/05/99 @@ -1188,3 +1192,4 @@ nsresult nsParser::CreateTagStack(nsITagStack** aTagStack){ return NS_OK; return NS_ERROR_HTMLPARSER_MEMORYFAILURE; } + diff --git a/mozilla/parser/htmlparser/src/nsParser.h b/mozilla/parser/htmlparser/src/nsParser.h index 78a4da0e0a3..32e5c467545 100644 --- a/mozilla/parser/htmlparser/src/nsParser.h +++ b/mozilla/parser/htmlparser/src/nsParser.h @@ -69,7 +69,7 @@ class nsIHTMLContentSink; class nsIDTD; class nsScanner; class nsIParserFilter; -class nsTagStack; + #include @@ -165,7 +165,7 @@ friend class CTokenHandler; * @param aListener is a listener to forward notifications to * @return TRUE if all went well -- FALSE otherwise */ - virtual nsresult Parse(nsIURL* aURL,nsIStreamObserver* aListener,PRBool aEnableVerify=PR_FALSE, void* aKey=0); + virtual nsresult Parse(nsIURL* aURL,nsIStreamObserver* aListener,PRBool aEnableVerify=PR_FALSE,void* aKey=0); /** * Cause parser to parse input from given stream @@ -173,7 +173,7 @@ friend class CTokenHandler; * @param aStream is the i/o source * @return TRUE if all went well -- FALSE otherwise */ - virtual nsresult Parse(nsIInputStream& aStream,PRBool aEnableVerify=PR_FALSE, void* aKey=0); + virtual nsresult Parse(nsIInputStream& aStream,PRBool aEnableVerify=PR_FALSE,void* aKey=0); /** * @update gess5/11/98 @@ -183,7 +183,6 @@ friend class CTokenHandler; */ virtual nsresult Parse(nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify=PR_FALSE,PRBool aLastCall=PR_FALSE); - virtual PRBool IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType); virtual nsresult ParseFragment(nsString& aSourceBuffer,void* aKey,nsITagStack& aStack,PRUint32 anInsertPos,const nsString& aContentType); diff --git a/mozilla/parser/htmlparser/src/nsParserNode.cpp b/mozilla/parser/htmlparser/src/nsParserNode.cpp index 158c9066b9b..2389ae29686 100644 --- a/mozilla/parser/htmlparser/src/nsParserNode.cpp +++ b/mozilla/parser/htmlparser/src/nsParserNode.cpp @@ -40,13 +40,13 @@ nsAutoString& GetEmptyString() { * @param aToken -- token to init internal token * @return */ -nsCParserNode::nsCParserNode(CToken* aToken,PRInt32 aLineNumber,nsITokenRecycler* aRecycler): nsIParserNode() { +nsCParserNode::nsCParserNode(CToken* aToken,PRInt32 aLineNumber,nsITokenRecycler* aRecycler): + nsIParserNode(), mSkippedContent("") { NS_INIT_REFCNT(); mAttributeCount=0; mLineNumber=aLineNumber; mToken=aToken; memset(mAttributes,0,sizeof(mAttributes)); - mSkippedContent=0; mRecycler=aRecycler; } @@ -65,8 +65,6 @@ nsCParserNode::~nsCParserNode() { for(index=0;indexRecycleToken(mAttributes[index]); } - if(mSkippedContent) - mRecycler->RecycleToken(mSkippedContent); } } @@ -141,21 +139,6 @@ void nsCParserNode::AddAttribute(CToken* aToken) { } } -/** - * This method gets called when the parser encounters - * skipped content after a start token. - * - * @update gess 3/26/98 - * @param aToken -- really a skippedcontent token - * @return nada - */ -void nsCParserNode::SetSkippedContent(CToken* aToken){ - if(aToken) { - NS_ASSERTION(eToken_skippedcontent == aToken->GetTokenType(), "not a skipped content token"); - mSkippedContent = aToken; - } -} - /** * Gets the name of this node. Currently unused. @@ -191,10 +174,19 @@ const nsString& nsCParserNode::GetText() const { * @return string ref of text from internal token */ const nsString& nsCParserNode::GetSkippedContent() const { - if (nsnull != mSkippedContent) { - return ((CSkippedContentToken*)mSkippedContent)->GetKey(); - } - return GetEmptyString(); + return mSkippedContent; +} + +/** + * Get text value of this node, which translates into + * getting the text value of the underlying token + * + * @update gess 3/25/98 + * @param + * @return string ref of text from internal token + */ +void nsCParserNode::SetSkippedContent(nsString& aString) { + mSkippedContent=aString; } /** @@ -303,5 +295,3 @@ CToken* nsCParserNode::PopAttributeToken() } return nsnull; } - - diff --git a/mozilla/parser/htmlparser/src/nsParserNode.h b/mozilla/parser/htmlparser/src/nsParserNode.h index 7902a8e4fdc..359760cc42b 100644 --- a/mozilla/parser/htmlparser/src/nsParserNode.h +++ b/mozilla/parser/htmlparser/src/nsParserNode.h @@ -90,6 +90,13 @@ class nsCParserNode : public nsIParserNode { */ virtual const nsString& GetSkippedContent() const; + /** + * Retrieve skipped context from node + * @update gess5/11/98 + * @return string containing skipped content + */ + virtual void SetSkippedContent(nsString& aString); + /** * Retrieve the type of the parser node. * @update gess5/11/98 @@ -148,14 +155,6 @@ class nsCParserNode : public nsIParserNode { */ virtual void AddAttribute(CToken* aToken); - /** - * - * @update gess5/11/98 - * @param - * @return - */ - virtual void SetSkippedContent(CToken* aToken); - /** * This getter retrieves the line number from the input source where * the token occured. Lines are interpreted as occuring between \n characters. @@ -169,15 +168,14 @@ class nsCParserNode : public nsIParserNode { * @return token at anIndex */ virtual CToken* PopAttributeToken(); - - protected: - PRUint32 mAttributeCount; - PRInt32 mLineNumber; - CToken* mToken; - CToken* mAttributes[eMaxAttr]; // XXX Ack! This needs to be dynamic! - CToken* mSkippedContent; - nsITokenRecycler* mRecycler; + protected: + PRUint32 mAttributeCount; + PRInt32 mLineNumber; + CToken* mToken; + CToken* mAttributes[eMaxAttr]; // XXX Ack! This needs to be dynamic! + nsAutoString mSkippedContent; + nsITokenRecycler* mRecycler; }; #endif diff --git a/mozilla/parser/htmlparser/src/nsToken.cpp b/mozilla/parser/htmlparser/src/nsToken.cpp index 5f11070d596..0c72ee21a59 100644 --- a/mozilla/parser/htmlparser/src/nsToken.cpp +++ b/mozilla/parser/htmlparser/src/nsToken.cpp @@ -153,6 +153,16 @@ nsString& CToken::GetStringValueXXX(void) { return mTextValue; } +/** + * Get string of full contents, suitable for debug dump. + * It should look exactly like the input source. + * @update gess5/11/98 + * @return reference to string containing string value + */ +void CToken::GetSource(nsString& anOutputString){ + anOutputString=mTextValue; +} + /** * This method retrieves the value of this internal string * as a cstring. diff --git a/mozilla/parser/htmlparser/src/nsToken.h b/mozilla/parser/htmlparser/src/nsToken.h index f9a28db1e4a..a5c52724d56 100644 --- a/mozilla/parser/htmlparser/src/nsToken.h +++ b/mozilla/parser/htmlparser/src/nsToken.h @@ -98,6 +98,14 @@ class CToken { */ virtual nsString& GetStringValueXXX(void); + /** + * Get string of full contents, suitable for debug dump. + * It should look exactly like the input source. + * @update gess5/11/98 + * @return reference to string containing string value + */ + virtual void GetSource(nsString& anOutputString); + /** * Setter method that changes the string value of this token * @update gess5/11/98 diff --git a/mozilla/parser/htmlparser/src/nsViewSourceHTML.cpp b/mozilla/parser/htmlparser/src/nsViewSourceHTML.cpp index 1c327085dd1..5747feb8bec 100644 --- a/mozilla/parser/htmlparser/src/nsViewSourceHTML.cpp +++ b/mozilla/parser/htmlparser/src/nsViewSourceHTML.cpp @@ -526,14 +526,15 @@ nsresult CViewSourceHTML::WriteText(const nsString& aTextString,nsIContentSink& temp=""; break; case kSpace: - if((PR_TRUE==aPreserveSpace) && (kSpace==aTextString.CharAt(theOffset+1))) { - if(temp.Length()) - result=aSink.AddLeaf(theTextNode); //just dump the whole string... - WriteNBSP(1,aSink); - temp=""; - break; - } - //fall through... + if((PR_TRUE==aPreserveSpace)) { + if(aTextString.Length() > theOffset+1 && (kSpace==aTextString.CharAt(theOffset+1))) { + if(temp.Length()) + result=aSink.AddLeaf(theTextNode); //just dump the whole string... + WriteNBSP(1,aSink); + temp=""; + break; + } + } //fall through... default: //scan ahead looking for valid chars... temp+=aTextString.CharAt(theOffset); @@ -751,7 +752,7 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) { case eToken_text: { nsString& theText=aToken->GetStringValueXXX(); - WriteText(theText,*mSink,PR_FALSE); + WriteText(theText,*mSink,PR_TRUE); } break; @@ -801,8 +802,8 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) { CToken* theNextToken = mTokenizer->PopToken(); if(theNextToken) { theType=eHTMLTokenTypes(theNextToken->GetTokenType()); - if(eToken_skippedcontent==theType) { - attrNode.SetSkippedContent(theNextToken); + if(eToken_text==theType) { + attrNode.SetSkippedContent(theNextToken->GetStringValueXXX()); } } result= OpenHead(attrNode); @@ -813,7 +814,7 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) { if(NS_OK==result) result=CloseHead(attrNode); } - nsString& theText=((CAttributeToken*)theNextToken)->GetKey(); + const nsString& theText=attrNode.GetSkippedContent(); WriteText(theText,*mSink,PR_FALSE); } break; diff --git a/mozilla/parser/htmlparser/src/nsWellFormedDTD.cpp b/mozilla/parser/htmlparser/src/nsWellFormedDTD.cpp index 573638c3a02..9b6967cb762 100644 --- a/mozilla/parser/htmlparser/src/nsWellFormedDTD.cpp +++ b/mozilla/parser/htmlparser/src/nsWellFormedDTD.cpp @@ -114,8 +114,6 @@ NS_IMPL_ADDREF(CWellFormedDTD) NS_IMPL_RELEASE(CWellFormedDTD) -//static CTokenDeallocator gTokenKiller; - /** * Default constructor * diff --git a/mozilla/parser/htmlparser/src/nsXIFDTD.cpp b/mozilla/parser/htmlparser/src/nsXIFDTD.cpp index f9b9ee62228..562270781f8 100644 --- a/mozilla/parser/htmlparser/src/nsXIFDTD.cpp +++ b/mozilla/parser/htmlparser/src/nsXIFDTD.cpp @@ -1736,11 +1736,7 @@ void nsXIFDTD::EndCSSStyleSheet(const nsIParserNode& aNode) mBuffer.Append(""); - CSkippedContentToken* skipped = new CSkippedContentToken(mBuffer); - nsString& key = skipped->GetKey(); - key = mBuffer; - - startNode.SetSkippedContent(skipped); + startNode.SetSkippedContent(mBuffer); mSink->AddLeaf(startNode); }