major rev to parsing engine

This commit is contained in:
rickg%netscape.com 1999-04-05 06:55:49 +00:00
parent df308f0007
commit 3f87b86577
76 changed files with 1466 additions and 800 deletions

View File

@ -331,7 +331,7 @@ void CNavDTD::DeleteTokenHandlers(void) {
* @param
* @return
*/
CNavDTD::CNavDTD() : nsIDTD(){
CNavDTD::CNavDTD() : nsIDTD(), mMisplacedContent(0) {
NS_INIT_REFCNT();
mSink = 0;
mParser=0;
@ -342,7 +342,6 @@ CNavDTD::CNavDTD() : nsIDTD(){
mHasOpenHead=0;
mHasOpenForm=PR_FALSE;
mHasOpenMap=PR_FALSE;
mAllowUnknownTags=PR_FALSE;
InitializeDefaultTokenHandlers();
mHeadContext=new nsDTDContext();
mBodyContext=new nsDTDContext();
@ -461,7 +460,7 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,PRBool aNotifySink,nsString
mHasOpenBody=PR_FALSE;
mHadBodyOrFrameset=PR_FALSE;
mLineNumber=1;
mIsPlaintext=aSourceType.Equals(kPlainTextContentType);
mHasOpenScript=PR_FALSE;
mSink=(nsIHTMLContentSink*)aSink;
if((aNotifySink) && (mSink)) {
@ -490,6 +489,8 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,PRBool aNotifySink,nsString
nsresult CNavDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsITokenObserver* anObserver,nsIContentSink* aSink) {
nsresult result=NS_OK;
nsString2 s2;
if(aTokenizer) {
nsITokenizer* oldTokenizer=mTokenizer;
mTokenizer=aTokenizer;
@ -500,13 +501,12 @@ nsresult CNavDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsIToke
CToken* theToken=mTokenizer->PopToken();
if(theToken) {
result=HandleToken(theToken,aParser);
if(NS_SUCCEEDED(result)) {
if(NS_SUCCEEDED(result) || (NS_ERROR_HTMLPARSER_BLOCK==result)) {
theRecycler->RecycleToken(theToken);
}
else if(NS_ERROR_HTMLPARSER_BLOCK!=result){
else if(NS_ERROR_HTMLPARSER_MISPLACED!=result)
mTokenizer->PushTokenFront(theToken);
}
// theRootDTD->Verify(kEmptyString,aParser);
else result=NS_OK;
}
else break;
}//while
@ -525,10 +525,16 @@ nsresult CNavDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsIToke
nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParser* aParser,nsIContentSink* aSink){
nsresult result= NS_OK;
/*
if((NS_OK==anErrorCode) && (!mHadBodyOrFrameset)) {
CStartToken theToken(eHTMLTag_body); //open the body container...
result=HandleStartToken(&theToken);
if(NS_SUCCEEDED(result)) {
result=BuildModel(aParser,mTokenizer,0,aSink);
}
}
*/
if(aParser){
mSink=(nsIHTMLContentSink*)aSink;
@ -597,13 +603,39 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){
if(aToken) {
CHTMLToken* theToken= (CHTMLToken*)(aToken);
eHTMLTokenTypes theType=eHTMLTokenTypes(theToken->GetTokenType());
CITokenHandler* theHandler=GetTokenHandler(theType);
eHTMLTags theTag=(eHTMLTags)theToken->GetTypeID();
if(theHandler) {
mParser=(nsParser*)aParser;
result=(*theHandler)(theToken,this);
if (mDTDDebug) {
//mDTDDebug->Verify(this, mParser, mBodyContext->GetCount(), mBodyContext->mTags, mFilename);
//Ok, now the real work begins.
//First, find out which section of the document the tag is supposed to go into.
//If that section is not open, push this tag (and it's attributes) onto the misplacedContent deque.
static eHTMLTags docElements[]=
{eHTMLTag_html,eHTMLTag_body,eHTMLTag_head,eHTMLTag_frameset,eHTMLTag_comment,eHTMLTag_newline,eHTMLTag_whitespace};
if(!mHadBodyOrFrameset){
PRBool isHeadChild=gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag);
if((!isHeadChild) && (mHasOpenScript || (!FindTagInSet(theTag,docElements,sizeof(docElements)/sizeof(eHTMLTag_unknown))))){
//really we want to push the token and all its skipped content and attributes...
if(0==mMisplacedContent.GetSize()){
CTokenRecycler* theRecycler=(CTokenRecycler*)mTokenizer->GetTokenRecycler();
CToken* theBodyToken=theRecycler->CreateTokenOfType(eToken_start,eHTMLTag_body);
mMisplacedContent.Push(theBodyToken);
}
mMisplacedContent.Push(theToken);
theToken=0; //force us to fall to bottom of this method...
result=NS_ERROR_HTMLPARSER_MISPLACED;
}
}
if(theToken){
CITokenHandler* theHandler=GetTokenHandler(theType);
if(theHandler) {
mParser=(nsParser*)aParser;
result=(*theHandler)(theToken,this);
if (mDTDDebug) {
//mDTDDebug->Verify(this, mParser, mBodyContext->GetCount(), mBodyContext->mTags, mFilename);
}
}
}
@ -809,18 +841,29 @@ PRInt32 GetIndexOfChildOrSynonym(nsTagStack& aTagStack,eHTMLTags aChildTag) {
* @return PR_TRUE if child agrees to be opened here.
*/
static
PRBool CanBeContained(eHTMLTags aChildTag,nsTagStack& aTagStack) {
PRBool CanBeContained(eHTMLTags aParentTag,eHTMLTags aChildTag,nsTagStack& aTagStack) {
PRBool result=PR_TRUE;
/* # Interesting test cases: Result:
* 1. <UL><LI>..<B>..<LI> inner <LI> closes outer <LI>
* 2. <CENTER><DL><DT><A><CENTER> allow nested <CENTER>
* 3. <TABLE><TR><TD><TABLE>... allow nested <TABLE>
*/
//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.
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);
if(theRootIndex<theChildIndex){
eHTMLTags thePrevTag=aTagStack.Last();
result=gHTMLElements[thePrevTag].CanContainType(gHTMLElements[aChildTag].mParentBits);
return result;
}
PRInt32 theBaseIndex=(theRootIndex<theChildIndex) ? theRootIndex : theChildIndex;
result=PRBool(theRootIndex>theChildIndex);
}
return result;
@ -851,16 +894,20 @@ 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;
CStartToken theToken(eHTMLTag_body); //open the body container...
result=HandleStartToken(&theToken);
result=CreateContextStackFor(aChildTag);
//CStartToken theToken(eHTMLTag_body); //open the body container...
//result=HandleStartToken(&theToken);
}
}//if
*/
/***********************************************************************
Subtlety alert:
@ -876,24 +923,24 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI
that the <HTML> tag is only *supposed* to contain certain tags --
no one would expect it to accept a rogue <LI> tag (for example).
After the parent decides it CAN accept a child (usually based on the class
of the tag, the child decides it if agrees. For example, consider this stack:
<HTML><BODY>
Here's an interested case we should not break:
<HTML>
<BODY>
<DL>
<DT>
<DD>
<LI>
<DT>
Technically, the <LI> *can* contain the <DT> tag, but the <DT> knows that
this isn't appropriate, since another <DT> is already open on the stack.
Therefore the child will refuse the placement.
The DT is not a child of the LI, so the LI closes. Then the DT also
closes the DD, and it's parent DT. At last, it reopens itself below DL.
***********************************************************************/
eHTMLTags theParentTag=mBodyContext->Last();
PRBool theCanContainResult=CanContain(theParentTag,aChildTag);
PRBool theChildAgrees=CanBeContained(aChildTag,mBodyContext->mTags);
PRBool theChildAgrees=(theCanContainResult) ? CanBeContained(theParentTag,aChildTag,mBodyContext->mTags) : PR_FALSE;
if(!(theCanContainResult && theChildAgrees)) {
eHTMLTags theTarget=FindAutoCloseTargetForStartTag(aChildTag,mBodyContext->mTags);
@ -904,7 +951,6 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI
}
}
if(PR_FALSE==theCanContainResult){
if(CanPropagate(theParentTag,aChildTag))
result=CreateContextStackFor(aChildTag);
@ -1014,13 +1060,16 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsCParserNode
result=gHTMLElements[aTag].HasSpecialProperty(kDiscardTag) ? 1 : NS_OK;
}
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(!gHTMLElements[eHTMLTag_head].IsChildOfHead(aTag)){
if(!isHeadChild){
CEndToken theToken(eHTMLTag_head);
nsCParserNode theNode(&theToken,mLineNumber);
result=CloseHead(theNode);
@ -1032,6 +1081,28 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsCParserNode
return result;
}
/**
* This method gets called when a start token has been encountered that the parent
* wants to omit.
*
* @update gess 3/25/98
* @param aToken -- next (start) token to be handled
* @param aChildTag -- id of the child in question
* @param aParent -- id of the parent in question
* @param aNode -- CParserNode representing this start token
* @return PR_TRUE if all went well; PR_FALSE if error occured
*/
nsresult CNavDTD::HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags aParent,nsIParserNode& aNode) {
nsresult result=NS_OK;
//The trick here is to see if the parent can contain the child, but prefers not to.
//Only if the parent CANNOT contain the child should we look to see if it's potentially a child
//of another section. If it is, the cache it for later.
// 1. Get the root node for the child. See if the ultimate node is the BODY, FRAMESET, HEAD or HTML
return result;
}
/**
* This method gets called when a start token has been
* encountered in the parse process. If the current container
@ -1058,8 +1129,31 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
if(NS_OK==result) {
if(NS_OK==WillHandleStartTag(aToken,theChildTag,attrNode)) {
PRBool theHeadIsParent=nsHTMLElement::IsChildOfHead(theChildTag);
if(nsHTMLElement::IsSectionTag(theChildTag)){
switch(theChildTag){
case eHTMLTag_head:
case eHTMLTag_body:
if(mHadBodyOrFrameset) {
result=HandleOmittedTag(aToken,theChildTag,theParent,attrNode);
return result;
}
break;
case eHTMLTag_frameset:
if(mHasOpenBody) {
result=HandleOmittedTag(aToken,theChildTag,theParent,attrNode);
return result;
}
break;
default:
if(HasOpenContainer(theChildTag)) {
result=HandleOmittedTag(aToken,theChildTag,theParent,attrNode);
return result;
}
}
}
PRBool theHeadIsParent=nsHTMLElement::IsChildOfHead(theChildTag);
switch(theChildTag) {
case eHTMLTag_area:
@ -1067,14 +1161,21 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
result=mSink->AddLeaf(attrNode);
break;
case eHTMLTag_comment:
case eHTMLTag_userdefined:
break; //drop them on the floor for now...
case eHTMLTag_script:
theHeadIsParent=(!mHasOpenBody); //intentionally fall through...
mHasOpenScript=PR_TRUE;
default:
if(theHeadIsParent)
result=AddHeadLeaf(attrNode);
else if(PR_FALSE==CanOmit(theParent,theChildTag)) {
result=HandleDefaultStartToken(aToken,theChildTag,attrNode);
{
if(theHeadIsParent)
result=AddHeadLeaf(attrNode);
else if(CanOmit(theParent,theChildTag))
result=HandleOmittedTag(aToken,theChildTag,theParent,attrNode);
else result=HandleDefaultStartToken(aToken,theChildTag,attrNode);
}
break;
} //switch
@ -1204,12 +1305,13 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) {
nsCParserNode theNode((CHTMLToken*)aToken,mLineNumber);
switch(theChildTag) {
case eHTMLTag_script:
mHasOpenScript=PR_FALSE;
case eHTMLTag_style:
case eHTMLTag_link:
case eHTMLTag_meta:
case eHTMLTag_textarea:
case eHTMLTag_title:
case eHTMLTag_script:
break;
case eHTMLTag_map:
@ -1452,6 +1554,19 @@ CITokenHandler* CNavDTD::GetTokenHandler(eHTMLTokenTypes aType) const {
return result;
}
/**
*
*
* @update gess 4/01/99
* @param aTokenizer
* @return
*/
void CNavDTD::EmitMisplacedContent(nsITokenizer* aTokenizer){
if(aTokenizer){
aTokenizer->PrependTokens(mMisplacedContent);
}
}
/**
* This method is called to determine whether or not a tag
* can contain an explict style tag (font, italic, bold, etc.)
@ -1530,8 +1645,7 @@ PRBool CNavDTD::CanPropagate(eHTMLTags aParentTag,eHTMLTags aChildTag) const {
}
else result=parentCanContain;
return result;
}
}
/**
* This method gets called to determine whether a given
@ -1542,169 +1656,30 @@ PRBool CNavDTD::CanPropagate(eHTMLTags aParentTag,eHTMLTags aChildTag) const {
* @return PR_TRUE if given tag can contain other tags
*/
PRBool CNavDTD::CanOmit(eHTMLTags aParent,eHTMLTags aChild) const {
PRBool result=PR_FALSE;
if((eHTMLTag_userdefined==aParent) && mAllowUnknownTags)
return result;
eHTMLTags theReqAncestor=gHTMLElements[aChild].mRequiredAncestor;
if(eHTMLTag_unknown!=theReqAncestor){
return !HasOpenContainer(theReqAncestor);
}
if(eHTMLTag_head==aChild) {
if(HasOpenContainer(eHTMLTag_body))
if(gHTMLElements[aParent].HasSpecialProperty(kOmitWS)) {
if(nsHTMLElement::IsTextTag(aChild)) {
return PR_TRUE;
}
}
static eHTMLTags canSkip[]={eHTMLTag_body,eHTMLTag_html,eHTMLTag_head};
if(FindTagInSet(aChild,canSkip,sizeof(canSkip)/sizeof(eHTMLTag_unknown))) {
if(HasOpenContainer(aChild))
//Now the obvious test: if the parent can contain the child, don't omit.
if(gHTMLElements[aParent].CanContain(aChild)){
return PR_FALSE;
}
if(nsHTMLElement::IsBlockElement(aParent)) {
if(nsHTMLElement::IsInlineElement(aChild)) { //feel free to drop inlines that a block doesn't contain.
return PR_TRUE;
}
}
//begin with some simple (and obvious) cases...
switch(aParent) {
case eHTMLTag_table:
case eHTMLTag_tbody:
if((eHTMLTag_form==aChild) || (eHTMLTag_table==aChild))
result=PR_FALSE;
else if(FindTagInSet(aChild,gFormElementTags,sizeof(gFormElementTags)/sizeof(eHTMLTag_unknown)))
result=!HasOpenContainer(eHTMLTag_form);
else result=!FindTagInSet(aChild,gTableChildTags,sizeof(gTableChildTags)/sizeof(eHTMLTag_unknown));
break;
case eHTMLTag_tr:
switch(aChild) {
case eHTMLTag_td:
case eHTMLTag_th:
case eHTMLTag_form:
case eHTMLTag_tr:
result=PR_FALSE;
break;
default:
if(FindTagInSet(aChild,gFormElementTags,sizeof(gFormElementTags)/sizeof(eHTMLTag_unknown)))
result=!HasOpenContainer(eHTMLTag_form);
else if(!gHTMLElements[aParent].CanContain(aChild)) {
result=PR_TRUE;
}
}
break;
case eHTMLTag_frameset:
result=!gFramesetKids.Contains(aChild);
break;
case eHTMLTag_unknown:
{
static eHTMLTags canSkip2[]={eHTMLTag_newline,eHTMLTag_whitespace};
if(FindTagInSet(aChild,canSkip2,sizeof(canSkip2)/sizeof(eHTMLTag_unknown))) {
result=PR_TRUE;
}
}
break;
case eHTMLTag_head:
if(eHTMLTag_body==aChild)
result=PR_FALSE;
else result=!nsHTMLElement::IsChildOfHead(aChild);
break;
default:
//ok, since no parent claimed it, test based on the child...
switch(aChild) {
case eHTMLTag_textarea:
break;
case eHTMLTag_userdefined:
case eHTMLTag_comment:
result=PR_TRUE;
break;
case eHTMLTag_body:
result=HasOpenContainer(eHTMLTag_frameset);
break;
// case eHTMLTag_input:
case eHTMLTag_fieldset: case eHTMLTag_isindex:
case eHTMLTag_label: case eHTMLTag_legend:
case eHTMLTag_select: //case eHTMLTag_textarea:
case eHTMLTag_option:
result=!HasOpenContainer(eHTMLTag_form);
break;
case eHTMLTag_newline:
case eHTMLTag_whitespace:
switch(aParent) {
case eHTMLTag_html: case eHTMLTag_head:
case eHTMLTag_title: case eHTMLTag_map:
case eHTMLTag_tr: case eHTMLTag_table:
case eHTMLTag_thead: case eHTMLTag_tfoot:
case eHTMLTag_tbody: case eHTMLTag_col:
case eHTMLTag_colgroup: case eHTMLTag_unknown:
case eHTMLTag_select: case eHTMLTag_fieldset:
case eHTMLTag_frameset: case eHTMLTag_dl:
result=PR_TRUE;
default:
break;
} //switch
break;
//this code prevents table container elements from
//opening unless a table is actually already opened.
case eHTMLTag_tr: case eHTMLTag_thead:
case eHTMLTag_tfoot: case eHTMLTag_tbody:
case eHTMLTag_td: case eHTMLTag_th:
case eHTMLTag_caption:
result=!HasOpenContainer(eHTMLTag_table);
break;
case eHTMLTag_entity:
switch(aParent) {
case eHTMLTag_tr: case eHTMLTag_table:
case eHTMLTag_thead: case eHTMLTag_tfoot:
case eHTMLTag_tbody:
result=PR_TRUE;
default:
break;
} //switch
break;
default:
static eHTMLTags kNonStylizedTabletags[]={eHTMLTag_table,eHTMLTag_tbody,eHTMLTag_tr};
if(nsHTMLElement::IsStyleTag(aChild)) {
if(FindTagInSet(aParent,kNonStylizedTabletags,sizeof(kNonStylizedTabletags)/sizeof(eHTMLTag_unknown)))
return PR_TRUE;
}
else {
//if you're here, then its time to try somthing really different.
//Let's go to the element table, and see who the parent tag of this child is.
//Make sure they're compatible.
CTagList* theRootTags=gHTMLElements[aChild].GetRootTags();
if(theRootTags && HasCloseablePeerAboveRoot(*theRootTags,mBodyContext->mTags,aChild,PR_FALSE)) {
return PR_FALSE;
}
CTagList* theCloseTags=gHTMLElements[aChild].GetAutoCloseStartTags();
if(theCloseTags) {
if(theCloseTags->Contains(aParent)) {
//we can't omit this tag; it will likely close the parent...
return PR_FALSE;
}
}
CTagList* theParents=gHTMLElements[aChild].GetSpecialParents();
if(theParents) {
PRInt32 theParentIndex=theParents->GetTopmostIndexOf(mBodyContext->mTags);
return PRBool(kNotFound==theParentIndex);
// result=!theParents->Contains(aParent); THE OLD WAY
}
}
if(!gHTMLElements[aParent].CanContain(aChild)){
return PR_TRUE;
}
break;
} //switch
break;
}
return result;
return PR_FALSE;
}
@ -2106,13 +2081,15 @@ nsresult CNavDTD::OpenBody(const nsIParserNode& aNode){
result=(mSink) ? mSink->OpenBody(aNode) : NS_OK;
mBodyContext->Push((eHTMLTags)aNode.GetNodeType());
//now THIS is a hack to support plaintext documents in this DTD...
/*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);
}
*/
}
mTokenizer->PrependTokens(mMisplacedContent);
return result;
}
@ -2266,11 +2243,14 @@ CNavDTD::OpenContainer(const nsIParserNode& aNode,PRBool aUpdateStyleStack){
break;
case eHTMLTag_body:
mHasOpenBody=PR_TRUE;
if(mHasOpenHead)
mHasOpenHead=1;
CloseHead(aNode); //do this just in case someone left it open...
result=OpenBody(aNode); break;
if(!mHasOpenBody){
mHasOpenBody=PR_TRUE;
if(mHasOpenHead)
mHasOpenHead=1;
CloseHead(aNode); //do this just in case someone left it open...
result=OpenBody(aNode);
}
break;
case eHTMLTag_style:
case eHTMLTag_title:

View File

@ -261,6 +261,8 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
*/
NS_IMETHOD WillInterruptParse(void);
virtual void EmitMisplacedContent(nsITokenizer* aTokenizer);
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.
@ -507,7 +509,7 @@ protected:
nsresult CollectSkippedContent(nsCParserNode& aNode,PRInt32& aCount);
nsresult WillHandleStartTag(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode);
nsresult DidHandleStartTag(nsCParserNode& aNode,eHTMLTags aChildTag);
nsresult HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags aParent,nsIParserNode& aNode);
nsIHTMLContentSink* mSink;
@ -517,7 +519,6 @@ protected:
nsDTDContext* mBodyContext;
nsDTDContext* mFormContext;
nsDTDContext* mMapContext;
PRBool mAllowUnknownTags;
PRBool mHasOpenForm;
PRBool mHasOpenMap;
PRInt32 mHasOpenHead;
@ -528,7 +529,8 @@ protected:
PRInt32 mLineNumber;
nsParser* mParser;
nsITokenizer* mTokenizer;
PRBool mIsPlaintext;
nsDeque mMisplacedContent;
PRBool mHasOpenScript;
PRUint32 mComputedCRC32;
PRUint32 mExpectedCRC32;

View File

@ -305,7 +305,7 @@ nsresult COtherDTD::HandleScriptToken(nsCParserNode& aNode) {
nsresult COtherDTD::HandleStyleToken(CToken* aToken){
return CNavDTD::HandleStyleToken(aToken);
}
/**
* This method is called to determine whether or not a tag

View File

@ -353,6 +353,16 @@ PRBool CRtfDTD::IsContainer(PRInt32 aTag) const{
return result;
}
/**
*
*
* @update gess 4/01/99
* @param aTokenizer
* @return
*/
void CRtfDTD::EmitMisplacedContent(nsITokenizer* aTokenizer){
}
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.

View File

@ -310,6 +310,8 @@ class CRtfDTD : public nsIDTD {
*/
virtual void SetVerification(PRBool aEnable);
virtual void EmitMisplacedContent(nsITokenizer* aTokenizer);
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.

View File

@ -265,7 +265,9 @@ CTokenRecycler::CTokenRecycler() : nsITokenRecycler() {
int i=0;
for(i=0;i<eToken_last-1;i++) {
mTokenCache[i]=new nsDeque(new CTokenDeallocator());
//mTotals[i]=0;
#ifdef NS_DEBUG
mTotals[i]=0;
#endif
}
}
@ -330,16 +332,18 @@ CToken* CTokenRecycler::CreateTokenOfType(eHTMLTokenTypes aType,eHTMLTags aTag,
result->Reinitialize(aTag,aString);
}
else {
//mTotals[aType-1]++;
#ifdef NS_DEBUG
mTotals[aType-1]++;
#endif
switch(aType){
case eToken_start: result=new CStartToken(aTag); break;
case eToken_end: result=new CEndToken(aTag); break;
case eToken_comment: result=new CCommentToken(); break;
case eToken_attribute: result=new CAttributeToken(); break;
case eToken_entity: result=new CEntityToken(); break;
case eToken_whitespace: result=new CWhitespaceToken(); break;
case eToken_newline: result=new CNewlineToken(); break;
case eToken_text: result=new CTextToken(aString); break;
case eToken_attribute: result=new CAttributeToken(); break;
case eToken_script: result=new CScriptToken(); break;
case eToken_style: result=new CStyleToken(); break;
case eToken_skippedcontent: result=new CSkippedContentToken(aString); break;
@ -367,7 +371,9 @@ CToken* CTokenRecycler::CreateTokenOfType(eHTMLTokenTypes aType,eHTMLTags aTag)
result->Reinitialize(aTag,theEmpty);
}
else {
//mTotals[aType-1]++;
#ifdef NS_DEBUG
mTotals[aType-1]++;
#endif
switch(aType){
case eToken_start: result=new CStartToken(aTag); break;
case eToken_end: result=new CEndToken(aTag); break;

View File

@ -148,7 +148,9 @@ public:
protected:
nsDeque* mTokenCache[eToken_last-1];
// int mTotals[eToken_last-1];
#ifdef NS_DEBUG
int mTotals[eToken_last-1];
#endif
};
/************************************************************************

View File

@ -75,37 +75,6 @@ PRInt32 CTagList::GetBottommostIndexOf(nsTagStack& aTagStack,PRInt32 aStartOffse
return kNotFound;
}
//*********************************************************************************************
// The following ints define the standard groups of HTML elements...
//*********************************************************************************************
static const int kNone= 0x0;
static const int kHTMLContent = 0x0001; // HEAD, (FRAMESET | BODY)
static const int kHeadContent = 0x0002; // TITLE, ISINDEX, BASE
static const int kHeadMisc = 0x0004; // SCRIPT, STYLE, META, LINK, OBJECT
static const int kSpecial = 0x0008; // A, IMG, APPLET, OBJECT, FONT, BASEFONT, BR, SCRIPT,
// MAP, Q, SUB, SUP, SPAN, BDO, IFRAME
static const int kFormControl = 0x0010; // INPUT SELECT TEXTAREA LABEL BUTTON
static const int kPreformatted = 0x0011; // PRE
static const int kPreExclusion = 0x0012; // IMG, OBJECT, APPLET, BIG, SMALL, SUB, SUP, FONT, BASEFONT
static const int kFontStyle = 0x0014; // TT, I, B, U, S, STRIKE, BIG, SMALL
static const int kPhrase = 0x0018; // EM, STRONG, DFN, CODE, SAMP, KBD, VAR, CITE, ABBR, ACRONYM
static const int kHeading = 0x0020; // H1..H6
static const int kBlockMisc = 0x0021; // P, DL, DIV, CENTER, NOSCRIPT, NOFRAMES, BLOCKQUOTE
// FORM, ISINDEX, HR, TABLE, FIELDSET, ADDRESS
static const int kList = 0x0024; // UL, OL, DIR, MENU
static const int kPCDATA = 0x0028; // just plain text...
static const int kSelf = 0x0040; // whatever THIS tag is...
static const int kInline = (kPCDATA|kFontStyle|kPhrase|kSpecial|kFormControl); // #PCDATA, %fontstyle, %phrase, %special, %formctrl
static const int kBlock = (kHeading|kList|kPreformatted|kBlockMisc); // %heading, %list, %preformatted, %blockmisc
static const int kFlow = (kBlock|kInline); // %block, %inline
static eHTMLTags gStyleTags[]={
eHTMLTag_a, eHTMLTag_acronym, eHTMLTag_b,
@ -113,7 +82,7 @@ static eHTMLTags gStyleTags[]={
eHTMLTag_center, eHTMLTag_cite, eHTMLTag_code,
eHTMLTag_del, eHTMLTag_dfn, eHTMLTag_em,
eHTMLTag_font, eHTMLTag_i, eHTMLTag_ins,
eHTMLTag_kbd, eHTMLTag_nobr, eHTMLTag_q,
eHTMLTag_kbd, eHTMLTag_q,
eHTMLTag_s, eHTMLTag_samp, eHTMLTag_small,
eHTMLTag_span, eHTMLTag_strike, eHTMLTag_strong,
eHTMLTag_sub, eHTMLTag_sup, eHTMLTag_tt,
@ -135,10 +104,10 @@ CTagList gInBody(1,0,eHTMLTag_body);
CTagList gInForm(1,0,eHTMLTag_form);
CTagList gInFieldset(1,0,eHTMLTag_fieldset);
CTagList gInTR(1,0,eHTMLTag_tr);
CTagList gInDL(1,0,eHTMLTag_dl);
CTagList gInDL(2,0,eHTMLTag_dl,eHTMLTag_body);
CTagList gInFrameset(1,0,eHTMLTag_frameset);
CTagList gInNoframes(1,0,eHTMLTag_noframes);
CTagList gInP(2,0,eHTMLTag_address,eHTMLTag_form);
CTagList gInP(3,0,eHTMLTag_address,eHTMLTag_form,eHTMLTag_table);
CTagList gOptgroupParents(2,0,eHTMLTag_optgroup,eHTMLTag_select);
CTagList gBodyParents(2,0,eHTMLTag_html,eHTMLTag_noframes);
CTagList gColParents(2,0,eHTMLTag_colgroup,eHTMLTag_table);
@ -239,20 +208,30 @@ CTagList gULCloseTags(1,0,eHTMLTag_li);
nsHTMLElement gHTMLElements[] = {
{ /*tag*/ eHTMLTag_unknown,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ 0,&gContainsHTML,eHTMLTag_unknown},
/*************************************************
Note: I changed A to contain flow elements
since it's such a popular (but illegal)
idiom.
*************************************************/
{ /*tag*/ eHTMLTag_a,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, kInline, kNone,
/*special properties*/ 0,
/*parent,incl,exclgroups*/ kSpecial, kFlow, kNone,
/*special properties*/ 0,
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_abbr,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPhrase, kInline, kNone,
@ -260,6 +239,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_acronym,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPhrase, (kInline|kSelf), kNone,
@ -267,6 +247,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_address,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, kInline, kNone,
@ -274,6 +255,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gAddressKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_applet,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, kFlow, kNone,
@ -281,6 +263,7 @@ nsHTMLElement gHTMLElements[] = {
/*special kids: <PARAM>*/ 0,&gContainsParam,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_area,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gAreaParent,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, kInline, kSelf,
@ -288,6 +271,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gAreaParent,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_b,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kFlow|kSelf), kNone,
@ -295,6 +279,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_base,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInHead, &gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -302,6 +287,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInHead,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_basefont,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, kNone, kNone,
@ -309,6 +295,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_bdo,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, (kSelf|kInline), kNone,
@ -316,6 +303,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_bgsound,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -323,6 +311,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_big,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kFlow|kSelf), kNone,
@ -330,6 +319,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_blink,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kFlow|kSelf), kNone,
@ -337,6 +327,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_blockquote,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -344,6 +335,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_body,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInHTML, &gInHTML,
/*autoclose starttags and endtags*/ &gBodyAutoClose,0,0,
/*parent,incl,exclgroups*/ kHTMLContent, kFlow, kNone,
@ -351,6 +343,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInNoframes,&gBodyKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_br,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, kNone, kNone,
@ -358,6 +351,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_button,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFormControl, kFlow, kFormControl,
@ -365,6 +359,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gButtonKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_caption,
/*requiredAncestor*/ eHTMLTag_table,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gCaptionAutoClose,0,0,
/*parent,incl,exclgroups*/ kNone, kInline, kSelf,
@ -372,6 +367,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInTable,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_center,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, (kInline|kSelf|kFlow), kNone,
@ -379,6 +375,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_cite,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPhrase, (kInline|kSelf), kNone,
@ -386,6 +383,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_code,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone,
@ -393,20 +391,23 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_col,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gColParents,&gColParents,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gColParents,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_colgroup,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gInTable,&gColgroupKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_dd,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInDL, &gInDL,
/*autoclose starttags and endtags*/ &gDTCloseTags,0,0,
/*parent,incl,exclgroups*/ kNone, kFlow, kNone,
@ -414,6 +415,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInDL,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_del,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, (kSelf|kFlow), kNone,
@ -421,6 +423,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInBody,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_dfn,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone,
@ -428,6 +431,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_dir,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, (kSelf|kFlow), kNone,
@ -435,6 +439,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gULKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_div,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gDivAutoClose,0,0,
/*parent,incl,exclgroups*/ kBlock, (kSelf|kFlow), kNone,
@ -442,13 +447,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_dl,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, (kSpecial|kFontStyle), kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ 0,&gDLKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_dt,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInDL,&gInDL,
/*autoclose starttags and endtags*/ &gDTCloseTags,0,0,
/*parent,incl,exclgroups*/ kNone, kInline, kNone,
@ -456,6 +463,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents, kids <DT>*/ &gInDL,&gDTKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_em,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone,
@ -463,20 +471,31 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_embed,
/*requiredAncestor*/ 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,&gContainsParam,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_endnote,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kFlow, kNone,
/*special properties*/ 0,
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_fieldset,
/*requiredAncestor*/ eHTMLTag_form,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ 0,&gFieldsetKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_font,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, (kSelf|kFlow), kNone,
@ -484,6 +503,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gFontKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_form,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -491,6 +511,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gFormKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_frame,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInFrameset,&gInFrameset,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -498,14 +519,16 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInFrameset,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_frameset,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInHTML,&gInHTML,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kSelf, kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gInHTML,&gFramesetKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_h1,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -513,6 +536,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_h2,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -520,6 +544,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_h3,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -527,6 +552,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_h4,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -534,6 +560,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_h5,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -541,6 +568,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_h6,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -548,13 +576,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_head,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInHTML, &gInHTML,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, (kHeadContent|kHeadMisc), kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gInHTML,&gHeadKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_hr,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gHRAutoClose,0,0,
/*parent,incl,exclgroups*/ kBlock, kNone, kNone,
@ -562,13 +592,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_html,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gHTMLRootTags, &gHTMLRootTags,
/*autoclose starttags and endtags*/ &gAutoClose,0,0,
/*parent,incl,exclgroups*/ kNone, kHTMLContent, kNone,
/*special properties*/ kOmitEndTag,
/*special properties*/ kOmitEndTag|kOmitWS,
/*special parents,kids,skip*/ 0,&gHtmlKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_i,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone,
@ -576,6 +608,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_iframe,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, kFlow, kNone,
@ -583,13 +616,23 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_ilayer,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
/*special properties*/ 0,
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_image,
/*requiredAncestor*/ 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_unknown},
{ /*tag*/ eHTMLTag_img,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -597,6 +640,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_input,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFormControl, kNone, kNone,
@ -604,6 +648,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_ins,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, (kSelf|kNone), kNone,
@ -611,6 +656,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_isindex,
/*requiredAncestor*/ eHTMLTag_form,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ (kBlock|kHeadContent), kFlow, kNone,
@ -618,6 +664,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInBody,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_kbd,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPhrase, (kSelf|kFlow), kNone,
@ -625,6 +672,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_keygen,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -632,6 +680,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_label,
/*requiredAncestor*/ eHTMLTag_form,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFormControl, kInline, kSelf,
@ -639,6 +688,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_layer,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, kFlow, kSelf,
@ -646,6 +696,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_legend,
/*requiredAncestor*/ eHTMLTag_form,
/*rootnodes,endrootnodes*/ &gInFieldset,&gInFieldset,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kInline, kNone,
@ -653,6 +704,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInFieldset,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_li,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gLIRootTags,&gLIRootTags,
/*autoclose starttags and endtags*/ &gLIAutoClose,0,0,
/*parent,incl,exclgroups*/ kList, kFlow, kSelf,
@ -660,6 +712,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gLIKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_link,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInHead,&gInHead,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kHeadMisc, kNone, kNone,
@ -667,6 +720,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInHead,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_listing,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -674,13 +728,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_map,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, kBlock, kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ 0,&gMapKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_menu,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kList, (kSelf|kFlow), kNone,
@ -688,6 +744,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gULKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_meta,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInHead, &gInHead,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kHeadMisc, kNone, kNone,
@ -695,6 +752,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInHead,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_multicol,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -702,13 +760,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_nobr,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, (kFlow|kSelf), kNone,
/*parent,incl,exclgroups*/ kFlow, (kFlow), kNone,
/*special properties*/ 0,
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_noembed,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -716,6 +776,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_noembed},
{ /*tag*/ eHTMLTag_noframes,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gNoframeRoot,&gNoframeRoot,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -723,6 +784,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gNoframeRoot,&gNoframesKids,eHTMLTag_noframes},
{ /*tag*/ eHTMLTag_nolayer,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -730,6 +792,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_nolayer},
{ /*tag*/ eHTMLTag_noscript,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -737,13 +800,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_noscript},
{ /*tag*/ eHTMLTag_object,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ (kHeadMisc|kSpecial), kFlow, kNone,
/*parent,incl,exclgroups*/ (kHeadMisc|kSpecial), (kFlow|kSelf), kNone,
/*special properties*/ 0,
/*special parents,kids,skip*/ 0,&gContainsParam,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_ol,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gOLRootTags,&gOLRootTags,
/*autoclose starttags and endtags*/ &gOLAutoClose, &gULCloseTags, 0,
/*parent,incl,exclgroups*/ kBlock, (kFlow|kSelf), kNone,
@ -751,6 +816,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gULKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_optgroup,
/*requiredAncestor*/ eHTMLTag_select,
/*rootnodes,endrootnodes*/ &gOptgroupParents,&gOptgroupParents,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -758,6 +824,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gOptgroupParents,&gContainsOpts,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_option,
/*requiredAncestor*/ eHTMLTag_form,
/*rootnodes,endrootnodes*/ &gOptgroupParents,&gOptgroupParents,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kPCDATA, kNone,
@ -765,13 +832,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gOptgroupParents,&gContainsText,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_p,
/*requiredAncestor*/ 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, 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
/*special parents,kids,skip*/ 0,&gInP,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_param,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gParamParents, &gParamParents,
/*autoclose starttags and endtags*/ &gPAutoClose,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -779,6 +848,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gParamParents,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_parsererror,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gDivAutoClose,0,0,
/*parent,incl,exclgroups*/ kBlock, (kSelf|kFlow), kNone,
@ -786,6 +856,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_plaintext,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kFlow, kNone,
@ -793,6 +864,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_html},
{ /*tag*/ eHTMLTag_pre,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPreformatted, kInline, kNone,
@ -800,6 +872,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gPreKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_q,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, (kSelf|kInline), kNone,
@ -807,6 +880,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_s,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone,
@ -814,6 +888,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_samp,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone,
@ -821,6 +896,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_script,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ (kSpecial|kHeadMisc), kPCDATA, kNone,
@ -828,13 +904,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gContainsText,eHTMLTag_script},
{ /*tag*/ eHTMLTag_select,
/*requiredAncestor*/ eHTMLTag_form,
/*rootnodes,endrootnodes*/ &gInForm,&gInForm,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFormControl, kNone, kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gInForm,&gContainsOpts,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_server,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -842,6 +920,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_small,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone,
@ -849,6 +928,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_sound,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -856,6 +936,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_sourcetext,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gDivAutoClose,0,0,
/*parent,incl,exclgroups*/ kBlock, (kSelf|kFlow), kNone,
@ -863,6 +944,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_spacer,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -870,6 +952,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_span,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, (kSelf|kInline), kNone,
@ -877,6 +960,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_strike,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone,
@ -884,6 +968,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_strong,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ (kPhrase|kFontStyle), (kSelf|kFlow), kNone,
@ -891,6 +976,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gContainsText,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_style,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInHead, &gInHead,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kHeadMisc, kPCDATA, kNone,
@ -898,6 +984,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInHead,0,eHTMLTag_style},
{ /*tag*/ eHTMLTag_sub,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone,
@ -905,6 +992,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_sup,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone,
@ -912,20 +1000,23 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_table,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gInBody,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, kNone, kSelf,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ 0,&gTableKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_tbody,
/*requiredAncestor*/ eHTMLTag_table,
/*rootnodes,endrootnodes*/ &gInTable, &gInTable,
/*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kSelf,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gInTable,&gTBodyKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_td,
/*requiredAncestor*/ eHTMLTag_table,
/*rootnodes,endrootnodes*/ &gTDRootTags,&gTDRootTags,
/*autoclose starttags and endtags*/ &gTDCloseTags,&gTDCloseTags,0,
/*parent,incl,exclgroups*/ kNone, kFlow, kSelf,
@ -933,6 +1024,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gTDRootTags,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_textarea,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInForm, &gInForm,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFormControl, kPCDATA, kNone,
@ -940,13 +1032,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInForm,&gContainsText,eHTMLTag_textarea},
{ /*tag*/ eHTMLTag_tfoot,
/*requiredAncestor*/ eHTMLTag_table,
/*rootnodes,endrootnodes*/ &gInTable, &gInTable,
/*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kSelf,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gInTable,&gTableElemKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_th,
/*requiredAncestor*/ eHTMLTag_table,
/*rootnodes,endrootnodes*/ &gTDRootTags,&gTDRootTags,
/*autoclose starttags and endtags*/ &gTDCloseTags,&gTDCloseTags,0,
/*parent,incl,exclgroups*/ kNone, kFlow, kSelf,
@ -954,27 +1048,31 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gTDRootTags,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_thead,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInTable,&gInTable,
/*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kSelf,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gInTable,&gTableElemKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_title,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInHead,&gInHead,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, (kHeadMisc|kPCDATA), kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gInHead,&gContainsText,eHTMLTag_title},
{ /*tag*/ eHTMLTag_tr,
/*requiredAncestor*/ eHTMLTag_table,
/*rootnodes,endrootnodes*/ &gTRParents,&gTRParents,
/*autoclose starttags and endtags*/ &gTRCloseTags,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gTRParents,&gTRKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_tt,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone,
@ -982,6 +1080,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_u,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone,
@ -989,6 +1088,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_ul,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gOLRootTags,&gOLRootTags,
/*autoclose starttags and endtags*/ &gOLAutoClose,&gULCloseTags,0,
/*parent,incl,exclgroups*/ kBlock, (kFlow|kSelf), kNone,
@ -996,6 +1096,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gULKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_var,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone,
@ -1003,6 +1104,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_wbr,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -1010,6 +1112,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_xmp,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -1017,13 +1120,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_xmp},
{ /*tag*/ eHTMLTag_text,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gTextRootTags,&gTextRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
/*special properties*/ 0,
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_whitespace,
{ /*tag*/ eHTMLTag_whitespace,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gTextRootTags,&gTextRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -1031,6 +1136,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_newline,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gTextRootTags,&gTextRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -1038,6 +1144,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_comment,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -1045,6 +1152,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_entity,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gTextRootTags,&gTextRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -1052,6 +1160,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_userdefined,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -1248,6 +1357,28 @@ PRBool nsHTMLElement::IsFlowParent(eHTMLTags aTag){
return result;
}
/**
* Tells us whether the given tag opens a section
* @update gess 01/04/99
* @param id of tag
* @return TRUE if opens section
*/
PRBool nsHTMLElement::IsSectionTag(eHTMLTags aTag){
PRBool result=PR_FALSE;
switch(aTag){
case eHTMLTag_html:
case eHTMLTag_frameset:
case eHTMLTag_body:
case eHTMLTag_head:
result=PR_TRUE;
break;
default:
result=PR_FALSE;
}
return result;
}
/**
*
* @update gess 01/04/99
@ -1339,6 +1470,18 @@ PRBool nsHTMLElement::IsMemberOf(PRInt32 aSet) const{
return result;
}
/**
*
* @update gess12/13/98
* @param
* @return
*/
PRBool nsHTMLElement::IsWhitespaceTag(eHTMLTags aChild) {
static eHTMLTags gWSTags[]={eHTMLTag_newline, eHTMLTag_whitespace};
PRBool result=FindTagInSet(aChild,gWSTags,sizeof(gWSTags)/sizeof(eHTMLTag_body));
return result;
}
/**
*
* @update gess12/13/98

View File

@ -84,6 +84,7 @@ struct nsHTMLElement {
static PRBool IsBlockParent(eHTMLTags aTag);
static PRBool IsInlineParent(eHTMLTags aTag);
static PRBool IsFlowParent(eHTMLTags aTag);
static PRBool IsSectionTag(eHTMLTags aTag);
CTagList* GetSpecialChildren(void) const {return mSpecialKids;}
CTagList* GetSpecialParents(void) const {return mSpecialParents;}
@ -104,8 +105,10 @@ struct nsHTMLElement {
static PRBool IsHeadingTag(eHTMLTags aTag) ;
static PRBool IsChildOfHead(eHTMLTags aTag) ;
static PRBool IsTextTag(eHTMLTags aTag);
static PRBool IsWhitespaceTag(eHTMLTags aTag);
eHTMLTags mTagID;
eHTMLTags mRequiredAncestor;
CTagList* mRootNodes; //These are the tags above which you many not autoclose a START tag
CTagList* mEndRootNodes; //These are the tags above which you many not autoclose an END tag
CTagList* mAutocloseStart; //these are the start tags that you can automatically close with this START tag
@ -125,9 +128,40 @@ extern CTagList gFramesetKids;
extern CTagList gHeadingTags;
//special property bits...
static const int kDiscardTag = 0x0001; //tells us to toss this tag
static const int kOmitEndTag = 0x0002; //safely ignore end tag
static const int kLegalOpen = 0x0004; //Lets BODY, TITLE, SCRIPT to reopen
static const int kDiscardTag = 0x0001; //tells us to toss this tag
static const int kOmitEndTag = 0x0002; //safely ignore end tag
static const int kLegalOpen = 0x0004; //Lets BODY, TITLE, SCRIPT to reopen
static const int kOmitWS = 0x0008; //If set, the tag can omit all ws and newlines
//*********************************************************************************************
// The following ints define the standard groups of HTML elements...
//*********************************************************************************************
static const int kNone= 0x0;
static const int kHTMLContent = 0x0001; // HEAD, (FRAMESET | BODY)
static const int kHeadContent = 0x0002; // TITLE, ISINDEX, BASE
static const int kHeadMisc = 0x0004; // SCRIPT, STYLE, META, LINK, OBJECT
static const int kSpecial = 0x0008; // A, IMG, APPLET, OBJECT, FONT, BASEFONT, BR, SCRIPT,
// MAP, Q, SUB, SUP, SPAN, BDO, IFRAME
static const int kFormControl = 0x0010; // INPUT SELECT TEXTAREA LABEL BUTTON
static const int kPreformatted = 0x0011; // PRE
static const int kPreExclusion = 0x0012; // IMG, OBJECT, APPLET, BIG, SMALL, SUB, SUP, FONT, BASEFONT
static const int kFontStyle = 0x0014; // TT, I, B, U, S, STRIKE, BIG, SMALL
static const int kPhrase = 0x0018; // EM, STRONG, DFN, CODE, SAMP, KBD, VAR, CITE, ABBR, ACRONYM
static const int kHeading = 0x0020; // H1..H6
static const int kBlockMisc = 0x0021; // P, DL, DIV, CENTER, NOSCRIPT, NOFRAMES, BLOCKQUOTE
// FORM, ISINDEX, HR, TABLE, FIELDSET, ADDRESS
static const int kList = 0x0024; // UL, OL, DIR, MENU
static const int kPCDATA = 0x0028; // just plain text...
static const int kSelf = 0x0040; // whatever THIS tag is...
static const int kInline = (kPCDATA|kFontStyle|kPhrase|kSpecial|kFormControl); // #PCDATA, %fontstyle, %phrase, %special, %formctrl
static const int kBlock = (kHeading|kList|kPreformatted|kBlockMisc); // %heading, %list, %preformatted, %blockmisc
static const int kFlow = (kBlock|kInline); // %block, %inline
#endif

View File

@ -367,6 +367,16 @@ PRBool nsExpatDTD::Verify(nsString& aURLRef,nsIParser* aParser) {
void nsExpatDTD::SetVerification(PRBool aEnabled){
}
/**
*
*
* @update gess 4/01/99
* @param aTokenizer
* @return
*/
void nsExpatDTD::EmitMisplacedContent(nsITokenizer* aTokenizer){
}
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.

View File

@ -203,6 +203,8 @@ class nsExpatDTD : public nsIDTD {
*/
virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild) const;
virtual void EmitMisplacedContent(nsITokenizer* aTokenizer);
/**
* This method gets called to determine whether a given
* tag is itself a container

View File

@ -133,6 +133,7 @@ void nsExpatTokenizer::SetupExpatCallbacks(void) {
nsExpatTokenizer::nsExpatTokenizer() : nsHTMLTokenizer() {
NS_INIT_REFCNT();
mExpatParser = XML_ParserCreate(NULL);
gTokenRecycler=(CTokenRecycler*)GetTokenRecycler();
if (mExpatParser) {
SetupExpatCallbacks();
}
@ -222,7 +223,7 @@ void nsExpatTokenizer::PushXMLErrorToken(const char *aBuffer, PRUint32 aLength)
token->SetError(error);
CToken* theToken = (CToken* )token;
AddToken(theToken, NS_OK, *gTokenDeque);
AddToken(theToken, NS_OK, *gTokenDeque,gTokenRecycler);
}
nsresult nsExpatTokenizer::ParseXMLBuffer(const char *aBuffer, PRUint32 aLength){
@ -264,7 +265,6 @@ nsresult nsExpatTokenizer::ConsumeToken(nsScanner& aScanner) {
if(0 < length) {
char* expatBuffer = theBuffer.ToNewCString();
if (expatBuffer) {
gTokenRecycler=(CTokenRecycler*)GetTokenRecycler();
gTokenDeque=&mTokenDeque;
gExpatParser = mExpatParser;
result = ParseXMLBuffer(expatBuffer, length);
@ -277,6 +277,16 @@ nsresult nsExpatTokenizer::ConsumeToken(nsScanner& aScanner) {
return result;
}
/**
*
* @update gess12/29/98
* @param
* @return
*/
void nsExpatTokenizer::FrontloadMisplacedContent(nsDeque& aDeque){
}
/***************************************/
/* Expat Callback Functions start here */
/***************************************/
@ -286,7 +296,7 @@ void nsExpatTokenizer::HandleStartElement(void *userData, const XML_Char *name,
if(theToken) {
nsString& theString=theToken->GetStringValueXXX();
theString.SetString(name);
AddToken(theToken,NS_OK,*gTokenDeque);
AddToken(theToken,NS_OK,*gTokenDeque,gTokenRecycler);
int theAttrCount=0;
while(*atts){
theAttrCount++;
@ -298,7 +308,7 @@ void nsExpatTokenizer::HandleStartElement(void *userData, const XML_Char *name,
theValue.SetString(*atts++);
}
CToken* theTok=(CToken*)theAttrToken;
AddToken(theTok,NS_OK,*gTokenDeque);
AddToken(theTok,NS_OK,*gTokenDeque,gTokenRecycler);
}
theToken->SetAttributeCount(theAttrCount);
}
@ -312,7 +322,7 @@ void nsExpatTokenizer::HandleEndElement(void *userData, const XML_Char *name) {
if(theToken) {
nsString& theString=theToken->GetStringValueXXX();
theString.SetString(name);
AddToken(theToken,NS_OK,*gTokenDeque);
AddToken(theToken,NS_OK,*gTokenDeque,gTokenRecycler);
}
else{
//THROW A HUGE ERROR IF WE CANT CREATE A TOKEN!
@ -336,7 +346,7 @@ void nsExpatTokenizer::HandleCharacterData(void *userData, const XML_Char *s, in
// We've reached the end of the current CDATA section. Push the current CDATA token
// onto the token queue and reset state to being outside a CDATA section.
CToken* tempCDATAToken = (CToken*) currentCDataToken;
AddToken(tempCDATAToken,NS_OK,*gTokenDeque);
AddToken(tempCDATAToken,NS_OK,*gTokenDeque,gTokenRecycler);
currentCDataToken = 0;
XML_SetUserData(gExpatParser, 0);
}
@ -364,7 +374,7 @@ void nsExpatTokenizer::HandleCharacterData(void *userData, const XML_Char *s, in
nsString& theString=newToken->GetStringValueXXX();
theString.Append(s,len);
}
AddToken(newToken,NS_OK,*gTokenDeque);
AddToken(newToken,NS_OK,*gTokenDeque,gTokenRecycler);
}
else {
//THROW A HUGE ERROR IF WE CANT CREATE A TOKEN!
@ -383,7 +393,7 @@ void nsExpatTokenizer::HandleProcessingInstruction(void *userData, const XML_Cha
theString.Append(data);
}
theString.Append("?>");
AddToken(theToken,NS_OK,*gTokenDeque);
AddToken(theToken,NS_OK,*gTokenDeque,gTokenRecycler);
}
else{
//THROW A HUGE ERROR IF WE CANT CREATE A TOKEN!

View File

@ -53,6 +53,9 @@ public:
/* nsITokenizer methods */
virtual nsresult ConsumeToken(nsScanner& aScanner);
virtual void FrontloadMisplacedContent(nsDeque& aDeque);
protected:
/**

View File

@ -25,16 +25,17 @@ static char* tagTable[] = {
"a", "abbr", "acronym", "address", "applet", "area", "b", "base",
"basefont", "bdo", "bgsound", "big", "blink", "blockquote", "body", "br",
"button", "caption", "center", "cite", "code", "col", "colgroup", "dd",
"del", "dfn", "dir", "div", "dl", "dt", "em", "embed", "fieldset", "font",
"form", "frame", "frameset", "h1", "h2", "h3", "h4", "h5", "h6", "head",
"hr", "html", "i", "iframe", "ilayer", "img", "input", "ins", "isindex",
"kbd", "keygen", "label", "layer", "legend", "li", "link", "listing",
"map", "menu", "meta", "multicol", "nobr", "noembed", "noframes",
"nolayer", "noscript", "object", "ol", "optgroup", "option", "p", "param",
"parsererror", "plaintext", "pre", "q", "s", "samp", "script", "select",
"server", "small", "sound", "sourcetext", "spacer", "span", "strike",
"strong", "style", "sub", "sup", "table", "tbody", "td", "textarea",
"tfoot", "th", "thead", "title", "tr", "tt", "u", "ul", "var", "wbr", "xmp"
"del", "dfn", "dir", "div", "dl", "dt", "em", "embed", "endnote",
"fieldset", "font", "form", "frame", "frameset", "h1", "h2", "h3", "h4",
"h5", "h6", "head", "hr", "html", "i", "iframe", "ilayer", "image", "img",
"input", "ins", "isindex", "kbd", "keygen", "label", "layer", "legend",
"li", "link", "listing", "map", "menu", "meta", "multicol", "nobr",
"noembed", "noframes", "nolayer", "noscript", "object", "ol", "optgroup",
"option", "p", "param", "parsererror", "plaintext", "pre", "q", "s",
"samp", "script", "select", "server", "small", "sound", "sourcetext",
"spacer", "span", "strike", "strong", "style", "sub", "sup", "table",
"tbody", "td", "textarea", "tfoot", "th", "thead", "title", "tr", "tt",
"u", "ul", "var", "wbr", "xmp"
};
nsHTMLTag NS_TagToEnum(const char* aTagName) {

View File

@ -34,37 +34,39 @@ enum nsHTMLTag {
eHTMLTag_center=19, eHTMLTag_cite=20, eHTMLTag_code=21, eHTMLTag_col=22,
eHTMLTag_colgroup=23, eHTMLTag_dd=24, eHTMLTag_del=25, eHTMLTag_dfn=26,
eHTMLTag_dir=27, eHTMLTag_div=28, eHTMLTag_dl=29, eHTMLTag_dt=30,
eHTMLTag_em=31, eHTMLTag_embed=32, eHTMLTag_fieldset=33, eHTMLTag_font=34,
eHTMLTag_form=35, eHTMLTag_frame=36, eHTMLTag_frameset=37, eHTMLTag_h1=38,
eHTMLTag_h2=39, eHTMLTag_h3=40, eHTMLTag_h4=41, eHTMLTag_h5=42,
eHTMLTag_h6=43, eHTMLTag_head=44, eHTMLTag_hr=45, eHTMLTag_html=46,
eHTMLTag_i=47, eHTMLTag_iframe=48, eHTMLTag_ilayer=49, eHTMLTag_img=50,
eHTMLTag_input=51, eHTMLTag_ins=52, eHTMLTag_isindex=53, eHTMLTag_kbd=54,
eHTMLTag_keygen=55, eHTMLTag_label=56, eHTMLTag_layer=57,
eHTMLTag_legend=58, eHTMLTag_li=59, eHTMLTag_link=60, eHTMLTag_listing=61,
eHTMLTag_map=62, eHTMLTag_menu=63, eHTMLTag_meta=64, eHTMLTag_multicol=65,
eHTMLTag_nobr=66, eHTMLTag_noembed=67, eHTMLTag_noframes=68,
eHTMLTag_nolayer=69, eHTMLTag_noscript=70, eHTMLTag_object=71,
eHTMLTag_ol=72, eHTMLTag_optgroup=73, eHTMLTag_option=74, eHTMLTag_p=75,
eHTMLTag_param=76, eHTMLTag_parsererror=77, eHTMLTag_plaintext=78,
eHTMLTag_pre=79, eHTMLTag_q=80, eHTMLTag_s=81, eHTMLTag_samp=82,
eHTMLTag_script=83, eHTMLTag_select=84, eHTMLTag_server=85,
eHTMLTag_small=86, eHTMLTag_sound=87, eHTMLTag_sourcetext=88,
eHTMLTag_spacer=89, eHTMLTag_span=90, eHTMLTag_strike=91,
eHTMLTag_strong=92, eHTMLTag_style=93, eHTMLTag_sub=94, eHTMLTag_sup=95,
eHTMLTag_table=96, eHTMLTag_tbody=97, eHTMLTag_td=98, eHTMLTag_textarea=99,
eHTMLTag_tfoot=100, eHTMLTag_th=101, eHTMLTag_thead=102,
eHTMLTag_title=103, eHTMLTag_tr=104, eHTMLTag_tt=105, eHTMLTag_u=106,
eHTMLTag_ul=107, eHTMLTag_var=108, eHTMLTag_wbr=109, eHTMLTag_xmp=110,
eHTMLTag_em=31, eHTMLTag_embed=32, eHTMLTag_endnote=33,
eHTMLTag_fieldset=34, eHTMLTag_font=35, eHTMLTag_form=36,
eHTMLTag_frame=37, eHTMLTag_frameset=38, eHTMLTag_h1=39, eHTMLTag_h2=40,
eHTMLTag_h3=41, eHTMLTag_h4=42, eHTMLTag_h5=43, eHTMLTag_h6=44,
eHTMLTag_head=45, eHTMLTag_hr=46, eHTMLTag_html=47, eHTMLTag_i=48,
eHTMLTag_iframe=49, eHTMLTag_ilayer=50, eHTMLTag_image=51, eHTMLTag_img=52,
eHTMLTag_input=53, eHTMLTag_ins=54, eHTMLTag_isindex=55, eHTMLTag_kbd=56,
eHTMLTag_keygen=57, eHTMLTag_label=58, eHTMLTag_layer=59,
eHTMLTag_legend=60, eHTMLTag_li=61, eHTMLTag_link=62, eHTMLTag_listing=63,
eHTMLTag_map=64, eHTMLTag_menu=65, eHTMLTag_meta=66, eHTMLTag_multicol=67,
eHTMLTag_nobr=68, eHTMLTag_noembed=69, eHTMLTag_noframes=70,
eHTMLTag_nolayer=71, eHTMLTag_noscript=72, eHTMLTag_object=73,
eHTMLTag_ol=74, eHTMLTag_optgroup=75, eHTMLTag_option=76, eHTMLTag_p=77,
eHTMLTag_param=78, eHTMLTag_parsererror=79, eHTMLTag_plaintext=80,
eHTMLTag_pre=81, eHTMLTag_q=82, eHTMLTag_s=83, eHTMLTag_samp=84,
eHTMLTag_script=85, eHTMLTag_select=86, eHTMLTag_server=87,
eHTMLTag_small=88, eHTMLTag_sound=89, eHTMLTag_sourcetext=90,
eHTMLTag_spacer=91, eHTMLTag_span=92, eHTMLTag_strike=93,
eHTMLTag_strong=94, eHTMLTag_style=95, eHTMLTag_sub=96, eHTMLTag_sup=97,
eHTMLTag_table=98, eHTMLTag_tbody=99, eHTMLTag_td=100,
eHTMLTag_textarea=101, eHTMLTag_tfoot=102, eHTMLTag_th=103,
eHTMLTag_thead=104, eHTMLTag_title=105, eHTMLTag_tr=106, eHTMLTag_tt=107,
eHTMLTag_u=108, eHTMLTag_ul=109, eHTMLTag_var=110, eHTMLTag_wbr=111,
eHTMLTag_xmp=112,
/* The remaining enums are not for tags */
eHTMLTag_text=111, eHTMLTag_whitespace=112, eHTMLTag_newline=113,
eHTMLTag_comment=114, eHTMLTag_entity=115, eHTMLTag_userdefined=116,
eHTMLTag_secret_h1style=117, eHTMLTag_secret_h2style=118,
eHTMLTag_secret_h3style=119, eHTMLTag_secret_h4style=120,
eHTMLTag_secret_h5style=121, eHTMLTag_secret_h6style=122
eHTMLTag_text=113, eHTMLTag_whitespace=114, eHTMLTag_newline=115,
eHTMLTag_comment=116, eHTMLTag_entity=117, eHTMLTag_userdefined=118,
eHTMLTag_secret_h1style=119, eHTMLTag_secret_h2style=120,
eHTMLTag_secret_h3style=121, eHTMLTag_secret_h4style=122,
eHTMLTag_secret_h5style=123, eHTMLTag_secret_h6style=124
};
#define NS_HTML_TAG_MAX 110
#define NS_HTML_TAG_MAX 112
extern NS_HTMLPARS nsHTMLTag NS_TagToEnum(const char* aTag);
extern NS_HTMLPARS const char* NS_EnumToTag(nsHTMLTag aEnum);

View File

@ -26,7 +26,6 @@
#include "nsHTMLTokenizer.h"
#include "nsParser.h"
#include "nsScanner.h"
#include "nsDTDUtils.h"
#include "nsElementTable.h"
#include "nsHTMLEntities.h"
@ -37,7 +36,6 @@
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kITokenizerIID, NS_ITOKENIZER_IID);
static NS_DEFINE_IID(kClassIID, NS_HTMLTOKENIZER_IID);
static CTokenRecycler* gTokenRecycler=0;
/**
* This method gets called as part of our COM-like interfaces.
@ -103,7 +101,7 @@ NS_IMPL_RELEASE(nsHTMLTokenizer)
* @param
* @return
*/
nsHTMLTokenizer::nsHTMLTokenizer() : nsITokenizer(), mTokenDeque(new CTokenDeallocator()) {
nsHTMLTokenizer::nsHTMLTokenizer() : nsITokenizer(), mTokenDeque(new CTokenDeallocator()){
NS_INIT_REFCNT();
mDoXMLEmptyTags=PR_FALSE;
}
@ -123,13 +121,16 @@ nsHTMLTokenizer::~nsHTMLTokenizer(){
Here begins the real working methods for the tokenizer.
*******************************************************************/
void nsHTMLTokenizer::AddToken(CToken*& aToken,nsresult aResult,nsDeque& aDeque) {
void nsHTMLTokenizer::AddToken(CToken*& aToken,nsresult aResult,nsDeque& aDeque,CTokenRecycler* aRecycler) {
if(aToken) {
if(NS_SUCCEEDED(aResult)) {
aDeque.Push(aToken);
}
else {
delete aToken;
if(aRecycler) {
aRecycler->RecycleToken(aToken);
}
else delete aToken;
aToken=0;
}
}
@ -141,10 +142,8 @@ void nsHTMLTokenizer::AddToken(CToken*& aToken,nsresult aResult,nsDeque& aDeque)
* @return ptr to recycler (or null)
*/
nsITokenRecycler* nsHTMLTokenizer::GetTokenRecycler(void) {
if (! gTokenRecycler) {
gTokenRecycler=new CTokenRecycler();
}
return gTokenRecycler;
static CTokenRecycler gTokenRecycler;
return (nsITokenRecycler*)&gTokenRecycler;
}
@ -202,10 +201,38 @@ PRInt32 nsHTMLTokenizer::GetCount(void) {
return mTokenDeque.GetSize();
}
/**
*
* @update gess12/29/98
* @param
* @return
*/
CToken* nsHTMLTokenizer::GetTokenAt(PRInt32 anIndex){
return (CToken*)mTokenDeque.ObjectAt(anIndex);
}
/**
*
* @update gess12/29/98
* @param
* @return
*/
void nsHTMLTokenizer::PrependTokens(nsDeque& aDeque){
PRInt32 aCount=aDeque.GetSize();
//last but not least, let's check the misplaced content list.
//if we find it, then we have to push it all into the body before continuing...
PRInt32 anIndex=0;
for(anIndex=0;anIndex<aCount;anIndex++){
CToken* theToken=(CToken*)aDeque.Pop();
PushTokenFront(theToken);
}
}
/**
* This method repeatedly called by the tokenizer.
* Each time, we determine the kind of token were about to
@ -353,13 +380,14 @@ nsresult nsHTMLTokenizer::ConsumeAttributes(PRUnichar aChar,CStartToken* aToken,
}
else {
theAttrCount++;
AddToken(theToken,result,mTokenDeque);
AddToken(theToken,result,mTokenDeque,theRecycler);
}
}
else { //if(NS_ERROR_HTMLPARSER_BADATTRIBUTE==result){
aToken->SetEmpty(PR_TRUE);
theRecycler->RecycleToken(theToken);
result=NS_OK;
if(NS_ERROR_HTMLPARSER_BADATTRIBUTE==result)
result=NS_OK;
}
}//if
@ -422,13 +450,13 @@ nsresult nsHTMLTokenizer::HandleSkippedContent(nsScanner& aScanner,CToken*& aTok
PRUnichar theChar=0;
result=ConsumeContentToEndTag(theChar,gHTMLElements[theTag].mSkipTarget,aScanner,skippedToken);
if((NS_OK==result) && skippedToken){
AddToken(skippedToken,result,mTokenDeque);
CTokenRecycler* theRecycler=(CTokenRecycler*)GetTokenRecycler();
AddToken(skippedToken,result,mTokenDeque,theRecycler);
if(NS_SUCCEEDED(result) && skippedToken){
//In the case that we just read a given tag, we should go and
//consume all the tag content itself (and throw it all away).
CTokenRecycler* theRecycler=(CTokenRecycler*)GetTokenRecycler();
nsString& theTagStr=skippedToken->GetStringValueXXX();
CToken* endtoken=theRecycler->CreateTokenOfType(eToken_end,theTag,theTagStr);
if(endtoken){
@ -436,7 +464,7 @@ nsresult nsHTMLTokenizer::HandleSkippedContent(nsScanner& aScanner,CToken*& aTok
theTagStr.Mid(temp,2,theTagStr.Length()-3);
//now strip the leading and trailing delimiters...
endtoken->Reinitialize(theTag,temp);
AddToken(endtoken,result,mTokenDeque);
AddToken(endtoken,result,mTokenDeque,theRecycler);
}
} //if
} //if
@ -460,7 +488,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan
result= aToken->Consume(aChar,aScanner); //tell new token to finish consuming text...
if(NS_SUCCEEDED(result)) {
AddToken(aToken,result,mTokenDeque);
AddToken(aToken,result,mTokenDeque,theRecycler);
eHTMLTags theTag=(eHTMLTags)aToken->GetTypeID();
if(((CStartToken*)aToken)->IsAttributed()) {
@ -505,7 +533,7 @@ nsresult nsHTMLTokenizer::ConsumeEndTag(PRUnichar aChar,CToken*& aToken,nsScanne
if(aToken) {
result= aToken->Consume(aChar,aScanner); //tell new token to finish consuming text...
AddToken(aToken,result,mTokenDeque);
AddToken(aToken,result,mTokenDeque,theRecycler);
} //if
return result;
}
@ -553,7 +581,7 @@ nsresult nsHTMLTokenizer::ConsumeEntity(PRUnichar aChar,CToken*& aToken,nsScanne
theRecycler->RecycleToken(aToken);
aToken=theToken;
}
AddToken(aToken,result,mTokenDeque);
AddToken(aToken,result,mTokenDeque,theRecycler);
}
}//if
return result;
@ -576,7 +604,7 @@ nsresult nsHTMLTokenizer::ConsumeWhitespace(PRUnichar aChar,CToken*& aToken,nsSc
nsresult result=NS_OK;
if(aToken) {
result=aToken->Consume(aChar,aScanner);
AddToken(aToken,result,mTokenDeque);
AddToken(aToken,result,mTokenDeque,theRecycler);
}
return result;
}
@ -597,7 +625,7 @@ nsresult nsHTMLTokenizer::ConsumeComment(PRUnichar aChar,CToken*& aToken,nsScann
nsresult result=NS_OK;
if(aToken) {
result=aToken->Consume(aChar,aScanner);
AddToken(aToken,result,mTokenDeque);
AddToken(aToken,result,mTokenDeque,theRecycler);
}
return result;
}
@ -619,15 +647,15 @@ nsresult nsHTMLTokenizer::ConsumeText(const nsString& aString,CToken*& aToken,ns
if(aToken) {
PRUnichar ch=0;
result=aToken->Consume(ch,aScanner);
if(result) {
if(!NS_SUCCEEDED(result)) {
nsString& temp=aToken->GetStringValueXXX();
if(0==temp.Length()){
delete aToken;
theRecycler->RecycleToken(aToken);
aToken = nsnull;
}
else result=NS_OK;
}
AddToken(aToken,result,mTokenDeque);
AddToken(aToken,result,mTokenDeque,theRecycler);
}
return result;
}
@ -647,7 +675,7 @@ nsresult nsHTMLTokenizer::ConsumeNewline(PRUnichar aChar,CToken*& aToken,nsScann
nsresult result=NS_OK;
if(aToken) {
result=aToken->Consume(aChar,aScanner);
AddToken(aToken,result,mTokenDeque);
AddToken(aToken,result,mTokenDeque,theRecycler);
}
return result;
}
@ -668,7 +696,7 @@ nsresult nsHTMLTokenizer::ConsumeProcessingInstruction(PRUnichar aChar,CToken*&
nsresult result=NS_OK;
if(aToken) {
result=aToken->Consume(aChar,aScanner);
AddToken(aToken,result,mTokenDeque);
AddToken(aToken,result,mTokenDeque,theRecycler);
}
return result;
}

View File

@ -33,6 +33,7 @@
#include "nsDeque.h"
#include "nsScanner.h"
#include "nsHTMLTokens.h"
#include "nsDTDUtils.h"
#define NS_HTMLTOKENIZER_IID \
{0xe4238ddd, 0x9eb6, 0x11d2, \
@ -64,6 +65,8 @@ public:
virtual CToken* GetTokenAt(PRInt32 anIndex);
virtual PRInt32 GetCount(void);
virtual void PrependTokens(nsDeque& aDeque);
protected:
virtual nsresult HandleSkippedContent(nsScanner& aScanner,CToken*& aToken);
@ -79,8 +82,7 @@ protected:
virtual nsresult ConsumeContentToEndTag(PRUnichar aChar,eHTMLTags aChildTag,nsScanner& aScanner,CToken*& aToken);
virtual nsresult ConsumeProcessingInstruction(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner);
protected:
static void AddToken(CToken*& aToken,nsresult aResult,nsDeque& aDeque);
static void AddToken(CToken*& aToken,nsresult aResult,nsDeque& aDeque,CTokenRecycler* aRecycler);
nsDeque mTokenDeque;
PRBool mDoXMLEmptyTags;

View File

@ -232,6 +232,10 @@ nsresult CStartToken::Consume(PRUnichar aChar, nsScanner& aScanner) {
mTextValue.ToCString(buffer,sizeof(buffer)-1);
mTypeID = NS_TagToEnum(buffer);
if(eHTMLTag_image==mTypeID){
mTypeID=eHTMLTag_img;
}
//Good. Now, let's skip whitespace after the identifier,
//and see if the next char is ">". If so, we have a complete
//tag without attributes.
@ -1564,7 +1568,7 @@ nsresult CSkippedContentToken::Consume(PRUnichar aChar,nsScanner& aScanner) {
static CCommentToken theComment;
result=theComment.Consume(aChar,aScanner);
if(NS_OK==result) {
result=aScanner.SkipWhitespace();
//result=aScanner.SkipWhitespace();
temp.Append(theComment.GetStringValueXXX());
}
} else {

View File

@ -189,9 +189,6 @@ class CEntityToken : public CHTMLToken {
// static PRBool VerifyEntityTable(void);
// static PRInt32 ReduceEntities(nsString& aString);
virtual void DebugDumpSource(ostream& out);
private:
static PRInt32 mEntityTokenCount;
};

View File

@ -135,6 +135,8 @@ class nsIDTD : public nsISupports {
virtual nsITokenRecycler* GetTokenRecycler(void)=0;
virtual void EmitMisplacedContent(nsITokenizer* aTokenizer)=0;
/**
* This method causes all tokens to be dispatched to the given tag handler.
*

View File

@ -48,7 +48,9 @@ public:
virtual void SetNotationDeclHandler(XML_NotationDeclHandler handler)=0;
virtual void SetExternalEntityRefHandler(XML_ExternalEntityRefHandler handler)=0;
virtual void SetUnknownEncodingHandler(XML_UnknownEncodingHandler handler, void *encodingHandlerData)=0;
virtual void FrontloadMisplacedContent(nsDeque& aDeque)=0;
};

View File

@ -126,6 +126,8 @@ class nsIParser : public nsISupports {
virtual nsresult Parse(fstream& aStream,PRBool aEnableVerify=PR_FALSE) = 0;
virtual nsresult Parse(nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify,PRBool aLastCall) = 0;
//virtual PRBool IsValid(nsString& aSourceBuffer,const nsString& aContentTypeaLastCall) = 0;
/**
* This method gets called when the tokens have been consumed, and it's time
* to build the model via the content sink.
@ -164,6 +166,8 @@ class nsIParser : public nsISupports {
#define NS_ERROR_HTMLPARSER_BADTOKENIZER NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1008)
#define NS_ERROR_HTMLPARSER_BADATTRIBUTE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1009)
#define NS_ERROR_HTMLPARSER_UNRESOLVEDDTD NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1010)
#define NS_ERROR_HTMLPARSER_MISPLACED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1011)
/**
* Return codes for parsing routines.

View File

@ -42,7 +42,7 @@
#include "nsString.h"
#include "nsDebug.h"
class CToken;
// class CToken;
// 6e59f160-2717-11d2-9246-00805f8a7ab6
#define NS_IPARSER_NODE_IID \
@ -110,7 +110,7 @@ class nsIParserNode : public nsISupports {
* @param anIndex is the index of the key you want
* @return string containing key.
*/
virtual const nsString& GetKeyAt(PRInt32 anIndex) const =0;
virtual const nsString& GetKeyAt(PRUint32 anIndex) const =0;
/**
* Retrieve the value (of key/value pair) at given index
@ -118,7 +118,7 @@ class nsIParserNode : public nsISupports {
* @param anIndex is the index of the value you want
* @return string containing value.
*/
virtual const nsString& GetValueAt(PRInt32 anIndex) const =0;
virtual const nsString& GetValueAt(PRUint32 anIndex) const =0;
/**
* NOTE: When the node is an entity, this will translate the entity

View File

@ -32,6 +32,7 @@
class CToken;
class nsScanner;
class nsDeque;
#define NS_ITOKENIZER_IID \
{0xe4238ddc, 0x9eb6, 0x11d2, {0xba, 0xa5, 0x0, 0x10, 0x4b, 0x98, 0x3f, 0xd4 }}
@ -65,13 +66,14 @@ public:
virtual nsresult ConsumeToken(nsScanner& aScanner)=0;
virtual nsITokenRecycler* GetTokenRecycler(void)=0;
virtual CToken* PushTokenFront(CToken* theToken)=0;
virtual CToken* PushToken(CToken* theToken)=0;
virtual CToken* PushTokenFront(CToken* aToken)=0;
virtual CToken* PushToken(CToken* aToken)=0;
virtual CToken* PopToken(void)=0;
virtual CToken* PeekToken(void)=0;
virtual PRInt32 GetCount(void)=0;
virtual CToken* GetTokenAt(PRInt32 anIndex)=0;
virtual void PrependTokens(nsDeque& aDeque)=0;
};

View File

@ -91,7 +91,7 @@ public:
nsIDTD* theDTD;
NS_NewWellFormed_DTD(&theDTD);
RegisterDTD(theDTD);
mDTDDeque.Push(theDTD);
NS_NewNavHTMLDTD(&theDTD); //do this as the default HTML DTD...
mDTDDeque.Push(theDTD);
@ -123,13 +123,18 @@ public:
nsDeque mDTDDeque;
};
static CSharedParserObjects* gSharedParserObjects=0;
//static CSharedParserObjects* gSharedParserObjects=0;
nsString nsParser::gHackMetaCharset = "";
nsString nsParser::gHackMetaCharsetURL = "";
//----------------------------------------
CSharedParserObjects& GetSharedObjects() {
static CSharedParserObjects gSharedParserObjects;
return gSharedParserObjects;
}
/**
* default constructor
*
@ -146,9 +151,6 @@ nsParser::nsParser(nsITokenObserver* anObserver) : mCommand(""), mUnusedInput(""
mTokenObserver=anObserver;
mStreamStatus=0;
mDTDVerification=PR_FALSE;
if(!gSharedParserObjects) {
gSharedParserObjects = new CSharedParserObjects();
}
}
@ -283,7 +285,8 @@ nsIContentSink* nsParser::GetContentSink(void){
* @return nothing.
*/
void nsParser::RegisterDTD(nsIDTD* aDTD){
gSharedParserObjects->RegisterDTD(aDTD);
CSharedParserObjects& theShare=GetSharedObjects();
theShare.RegisterDTD(aDTD);
}
/**
@ -328,8 +331,9 @@ PRBool FindSuitableDTD( CParserContext& aParserContext,nsString& aCommand,nsStri
if(aParserContext.mDTD->CanParse(aParserContext.mSourceType,aCommand,aBuffer,0))
return PR_TRUE;
nsDequeIterator b=gSharedParserObjects->mDTDDeque.Begin();
nsDequeIterator e=gSharedParserObjects->mDTDDeque.End();
CSharedParserObjects& gSharedObjects=GetSharedObjects();
nsDequeIterator b=gSharedObjects.mDTDDeque.Begin();
nsDequeIterator e=gSharedObjects.mDTDDeque.End();
aParserContext.mAutoDetectStatus=eUnknownDetect;
nsIDTD* theBestDTD=0;
@ -732,6 +736,27 @@ nsresult nsParser::Parse(nsString& aSourceBuffer,void* aKey,const nsString& aCon
return result;
}
/**
*
* @update gess 04/01/99
* @param
* @return
*/
PRBool nsParser::IsValidFragment(nsString& aSourceBuffer,nsTagStack& aStack,nsHTMLTag aTag,const nsString& aContentType){
PRBool result=PR_FALSE;
return result;
}
/**
*
* @update gess 04/01/99
* @param
* @return
*/
PRBool nsParser::ParseFragment(nsString& aSourceBuffer,void* aKey,nsTagStack& aStack,nsHTMLTag aTag,const nsString& aContentType){
PRBool result=PR_FALSE;
return result;
}
/**
* This routine is called to cause the parser to continue
@ -753,6 +778,10 @@ nsresult nsParser::ResumeParse(nsIDTD* aDefaultDTD) {
if(NS_OK==result) {
result=Tokenize();
if(eOnStop==mParserContext->mStreamListenerState){
nsITokenizer* theTokenizer=mParserContext->mDTD->GetTokenizer();
mParserContext->mDTD->EmitMisplacedContent(theTokenizer);
}
result=BuildModel();
if((!mParserContext->mMultipart) || ((eOnStop==mParserContext->mStreamListenerState) && (NS_OK==result))){
@ -973,7 +1002,7 @@ nsresult nsParser::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRUin
* This is called by the networking library once the last block of data
* has been collected from the net.
*
* @update vidur 12/11/98
* @update gess 04/01/99
* @param
* @return
*/
@ -1044,6 +1073,10 @@ nsresult nsParser::Tokenize(){
result=theTokenizer->ConsumeToken(*mParserContext->mScanner);
if(!NS_SUCCEEDED(result)) {
mParserContext->mScanner->RewindToMark();
if(kEOF==result){
result=NS_OK;
break;
}
}
}
DidTokenize();
@ -1053,7 +1086,7 @@ nsresult nsParser::Tokenize(){
/**
* This is the tail-end of the code sandwich for the
* tokenization process. It gets called once tokenziation
* has completed.
* has completed for each phase.
*
* @update gess 01/04/99
* @param

View File

@ -62,12 +62,15 @@
#include "CParserContext.h"
#include "nsParserCIID.h"
#include "nsITokenizer.h"
#include "nsHTMLTags.h"
class IContentSink;
class nsIHTMLContentSink;
class nsIDTD;
class nsScanner;
class nsIParserFilter;
class nsTagStack;
#include <fstream.h>
#ifndef XP_MAC
@ -168,6 +171,9 @@ friend class CTokenHandler;
*/
virtual nsresult Parse(nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify=PR_FALSE,PRBool aLastCall=PR_FALSE);
virtual PRBool IsValidFragment(nsString& aSourceBuffer,nsTagStack& aStack,nsHTMLTag aTag,const nsString& aContentType);
virtual PRBool ParseFragment(nsString& aSourceBuffer,void* aKey,nsTagStack& aStack,nsHTMLTag aTag,const nsString& aContentType);
/**
* Call this when you want control whether or not the parser will parse

View File

@ -23,12 +23,16 @@
#include "nshtmlpars.h"
#include "nsITokenizer.h"
const nsString* nsCParserNode::mEmptyString=0;
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kClassIID, NS_PARSER_NODE_IID);
static NS_DEFINE_IID(kIParserNodeIID, NS_IPARSER_NODE_IID);
nsAutoString& GetEmptyString() {
static nsAutoString theEmptyString("");
return theEmptyString;
}
/**
* Default constructor
*
@ -38,9 +42,6 @@ static NS_DEFINE_IID(kIParserNodeIID, NS_IPARSER_NODE_IID);
*/
nsCParserNode::nsCParserNode(CToken* aToken,PRInt32 aLineNumber,nsITokenRecycler* aRecycler): nsIParserNode() {
NS_INIT_REFCNT();
if(!mEmptyString) {
mEmptyString=new nsString(""); //this is going to leak, but it's a singleton
}
mAttributeCount=0;
mLineNumber=aLineNumber;
mToken=aToken;
@ -60,7 +61,7 @@ nsCParserNode::nsCParserNode(CToken* aToken,PRInt32 aLineNumber,nsITokenRecycler
*/
nsCParserNode::~nsCParserNode() {
if(mRecycler) {
int index=0;
PRUint32 index=0;
for(index=0;index<mAttributeCount;index++){
mRecycler->RecycleToken(mAttributes[index]);
}
@ -140,7 +141,6 @@ void nsCParserNode::AddAttribute(CToken* aToken) {
}
}
/**
* This method gets called when the parser encounters
* skipped content after a start token.
@ -165,7 +165,7 @@ void nsCParserNode::SetSkippedContent(CToken* aToken){
* @return string ref containing node name
*/
const nsString& nsCParserNode::GetName() const {
return *mEmptyString;
return GetEmptyString();
// return mName;
}
@ -194,7 +194,7 @@ const nsString& nsCParserNode::GetSkippedContent() const {
if (nsnull != mSkippedContent) {
return ((CSkippedContentToken*)mSkippedContent)->GetKey();
}
return *mEmptyString;
return GetEmptyString();
}
/**
@ -244,12 +244,12 @@ PRInt32 nsCParserNode::GetAttributeCount(PRBool askToken) const{
* @param anIndex-- offset of attribute to retrieve
* @return string rep of given attribute text key
*/
const nsString& nsCParserNode::GetKeyAt(PRInt32 anIndex) const {
const nsString& nsCParserNode::GetKeyAt(PRUint32 anIndex) const {
if(anIndex<mAttributeCount) {
CAttributeToken* tkn=(CAttributeToken*)(mAttributes[anIndex]);
return tkn->GetKey();
}
return *mEmptyString;
return GetEmptyString();
}
@ -260,12 +260,12 @@ const nsString& nsCParserNode::GetKeyAt(PRInt32 anIndex) const {
* @param anIndex-- offset of attribute to retrieve
* @return string rep of given attribute text value
*/
const nsString& nsCParserNode::GetValueAt(PRInt32 anIndex) const {
const nsString& nsCParserNode::GetValueAt(PRUint32 anIndex) const {
NS_PRECONDITION(anIndex<mAttributeCount, "Bad attr index");
if(anIndex<mAttributeCount){
return (mAttributes[anIndex])->GetStringValueXXX();
}
return *mEmptyString;
return GetEmptyString();
}

View File

@ -121,7 +121,7 @@ class nsCParserNode : public nsIParserNode {
* @param anIndex is the index of the key you want
* @return string containing key.
*/
virtual const nsString& GetKeyAt(PRInt32 anIndex) const;
virtual const nsString& GetKeyAt(PRUint32 anIndex) const;
/**
* Retrieve the value (of key/value pair) at given index
@ -129,7 +129,7 @@ class nsCParserNode : public nsIParserNode {
* @param anIndex is the index of the value you want
* @return string containing value.
*/
virtual const nsString& GetValueAt(PRInt32 anIndex) const;
virtual const nsString& GetValueAt(PRUint32 anIndex) const;
/**
* NOTE: When the node is an entity, this will translate the entity
@ -165,17 +165,13 @@ class nsCParserNode : public nsIParserNode {
virtual PRInt32 GetSourceLineNumber(void) const;
protected:
PRInt32 mAttributeCount;
PRUint32 mAttributeCount;
PRInt32 mLineNumber;
CToken* mToken;
CToken* mAttributes[eMaxAttr]; // XXX Ack! This needs to be dynamic!
CToken* mSkippedContent;
nsITokenRecycler* mRecycler;
// nsAutoString mName;
static const nsString* mEmptyString;
};
#endif

View File

@ -620,7 +620,7 @@ nsString& nsScanner::GetBuffer(void) {
void nsScanner::CopyUnusedData(nsString& aCopyBuffer) {
PRInt32 theLen=mBuffer.Length();
if(0<theLen) {
mBuffer.Right(aCopyBuffer,theLen-mOffset);
mBuffer.Right(aCopyBuffer,theLen-mMarkPos);
}
}

View File

@ -281,6 +281,16 @@ PRBool CValidDTD::Verify(nsString& aURLRef,nsIParser* aParser) {
void CValidDTD::SetVerification(PRBool aEnabled){
}
/**
*
*
* @update gess 4/01/99
* @param aTokenizer
* @return
*/
void CValidDTD::EmitMisplacedContent(nsITokenizer* aTokenizer){
}
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.

View File

@ -202,6 +202,8 @@ class CValidDTD : public nsIDTD {
*/
virtual void SetVerification(PRBool aEnable);
virtual void EmitMisplacedContent(nsITokenizer* aTokenizer);
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.

View File

@ -423,6 +423,16 @@ PRBool CViewSourceHTML::Verify(nsString& aURLRef,nsIParser* aParser) {
void CViewSourceHTML::SetVerification(PRBool aEnabled){
}
/**
*
*
* @update gess 4/01/99
* @param aTokenizer
* @return
*/
void CViewSourceHTML::EmitMisplacedContent(nsITokenizer* aTokenizer){
}
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.

View File

@ -200,6 +200,8 @@ class CViewSourceHTML: public nsIDTD {
*/
virtual void SetVerification(PRBool aEnable);
virtual void EmitMisplacedContent(nsITokenizer* aTokenizer);
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.

View File

@ -253,10 +253,11 @@ NS_IMETHODIMP CWellFormedDTD::BuildModel(nsIParser* aParser,nsITokenizer* aToken
CToken* theToken=mTokenizer->PopToken();
if(theToken) {
result=HandleToken(theToken,aParser);
if(NS_SUCCEEDED(result)) {
if(NS_SUCCEEDED(result) || (NS_ERROR_HTMLPARSER_BLOCK==result)) {
theRecycler->RecycleToken(theToken);
}
else if(NS_ERROR_HTMLPARSER_BLOCK!=result){
else {
// if(NS_ERROR_HTMLPARSER_BLOCK!=result){
mTokenizer->PushTokenFront(theToken);
}
// theRootDTD->Verify(kEmptyString,aParser);
@ -409,6 +410,16 @@ PRBool CWellFormedDTD::Verify(nsString& aURLRef,nsIParser* aParser) {
void CWellFormedDTD::SetVerification(PRBool aEnabled){
}
/**
*
*
* @update gess 4/01/99
* @param aTokenizer
* @return
*/
void CWellFormedDTD::EmitMisplacedContent(nsITokenizer* aTokenizer){
}
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.
@ -450,7 +461,7 @@ NS_IMETHODIMP CWellFormedDTD::HandleToken(CToken* aToken,nsIParser* aParser) {
mParser=(nsParser*)aParser;
mSink=aParser->GetContentSink();
nsCParserNode theNode(theToken,mLineNumber);
nsCParserNode theNode(theToken,mLineNumber,mTokenizer->GetTokenRecycler());
switch(theType) {
case eToken_newline:

View File

@ -188,6 +188,8 @@ class CWellFormedDTD : public nsIDTD {
*/
virtual void SetVerification(PRBool aEnable);
virtual void EmitMisplacedContent(nsITokenizer* aTokenizer);
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.

View File

@ -881,6 +881,16 @@ PRBool nsXIFDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
return result;
}
/**
*
*
* @update gess 4/01/99
* @param aTokenizer
* @return
*/
void nsXIFDTD::EmitMisplacedContent(nsITokenizer* aTokenizer){
}
/**
* This method gets called to determine whether a given
* tag can contain newlines. Most do not.

View File

@ -225,6 +225,8 @@ class nsXIFDTD : public nsIDTD {
*/
virtual void SetURLRef(char * aURLRef);
virtual void EmitMisplacedContent(nsITokenizer* aTokenizer);
/**
*
* @update jevering 6/18/98

View File

@ -198,21 +198,22 @@ nsresult nsXMLTokenizer::ConsumeComment(PRUnichar aChar,CToken*& aToken,nsScanne
result = ConsumeConditional(aScanner, CDATAString, isCDATA);
CTokenRecycler* theRecycler=(CTokenRecycler*)GetTokenRecycler();
if (NS_OK == result) {
nsAutoString theEmpty;
if (isCDATA) {
aToken=theRecycler->CreateTokenOfType(eToken_cdatasection,eHTMLTag_unknown,theEmpty);
if(theRecycler) {
if (NS_OK == result) {
nsAutoString theEmpty;
if (isCDATA) {
aToken=theRecycler->CreateTokenOfType(eToken_cdatasection,eHTMLTag_unknown,theEmpty);
}
else {
aToken=theRecycler->CreateTokenOfType(eToken_comment,eHTMLTag_comment,theEmpty);
}
}
else {
aToken=theRecycler->CreateTokenOfType(eToken_comment,eHTMLTag_comment,theEmpty);
}
}
if(aToken) {
result=aToken->Consume(aChar,aScanner);
AddToken(aToken,result,mTokenDeque);
if(aToken) {
result=aToken->Consume(aChar,aScanner);
AddToken(aToken,result,mTokenDeque,theRecycler);
}
}
return result;

View File

@ -331,7 +331,7 @@ void CNavDTD::DeleteTokenHandlers(void) {
* @param
* @return
*/
CNavDTD::CNavDTD() : nsIDTD(){
CNavDTD::CNavDTD() : nsIDTD(), mMisplacedContent(0) {
NS_INIT_REFCNT();
mSink = 0;
mParser=0;
@ -342,7 +342,6 @@ CNavDTD::CNavDTD() : nsIDTD(){
mHasOpenHead=0;
mHasOpenForm=PR_FALSE;
mHasOpenMap=PR_FALSE;
mAllowUnknownTags=PR_FALSE;
InitializeDefaultTokenHandlers();
mHeadContext=new nsDTDContext();
mBodyContext=new nsDTDContext();
@ -461,7 +460,7 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,PRBool aNotifySink,nsString
mHasOpenBody=PR_FALSE;
mHadBodyOrFrameset=PR_FALSE;
mLineNumber=1;
mIsPlaintext=aSourceType.Equals(kPlainTextContentType);
mHasOpenScript=PR_FALSE;
mSink=(nsIHTMLContentSink*)aSink;
if((aNotifySink) && (mSink)) {
@ -490,6 +489,8 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,PRBool aNotifySink,nsString
nsresult CNavDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsITokenObserver* anObserver,nsIContentSink* aSink) {
nsresult result=NS_OK;
nsString2 s2;
if(aTokenizer) {
nsITokenizer* oldTokenizer=mTokenizer;
mTokenizer=aTokenizer;
@ -500,13 +501,12 @@ nsresult CNavDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsIToke
CToken* theToken=mTokenizer->PopToken();
if(theToken) {
result=HandleToken(theToken,aParser);
if(NS_SUCCEEDED(result)) {
if(NS_SUCCEEDED(result) || (NS_ERROR_HTMLPARSER_BLOCK==result)) {
theRecycler->RecycleToken(theToken);
}
else if(NS_ERROR_HTMLPARSER_BLOCK!=result){
else if(NS_ERROR_HTMLPARSER_MISPLACED!=result)
mTokenizer->PushTokenFront(theToken);
}
// theRootDTD->Verify(kEmptyString,aParser);
else result=NS_OK;
}
else break;
}//while
@ -525,10 +525,16 @@ nsresult CNavDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsIToke
nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParser* aParser,nsIContentSink* aSink){
nsresult result= NS_OK;
/*
if((NS_OK==anErrorCode) && (!mHadBodyOrFrameset)) {
CStartToken theToken(eHTMLTag_body); //open the body container...
result=HandleStartToken(&theToken);
if(NS_SUCCEEDED(result)) {
result=BuildModel(aParser,mTokenizer,0,aSink);
}
}
*/
if(aParser){
mSink=(nsIHTMLContentSink*)aSink;
@ -597,13 +603,39 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){
if(aToken) {
CHTMLToken* theToken= (CHTMLToken*)(aToken);
eHTMLTokenTypes theType=eHTMLTokenTypes(theToken->GetTokenType());
CITokenHandler* theHandler=GetTokenHandler(theType);
eHTMLTags theTag=(eHTMLTags)theToken->GetTypeID();
if(theHandler) {
mParser=(nsParser*)aParser;
result=(*theHandler)(theToken,this);
if (mDTDDebug) {
//mDTDDebug->Verify(this, mParser, mBodyContext->GetCount(), mBodyContext->mTags, mFilename);
//Ok, now the real work begins.
//First, find out which section of the document the tag is supposed to go into.
//If that section is not open, push this tag (and it's attributes) onto the misplacedContent deque.
static eHTMLTags docElements[]=
{eHTMLTag_html,eHTMLTag_body,eHTMLTag_head,eHTMLTag_frameset,eHTMLTag_comment,eHTMLTag_newline,eHTMLTag_whitespace};
if(!mHadBodyOrFrameset){
PRBool isHeadChild=gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag);
if((!isHeadChild) && (mHasOpenScript || (!FindTagInSet(theTag,docElements,sizeof(docElements)/sizeof(eHTMLTag_unknown))))){
//really we want to push the token and all its skipped content and attributes...
if(0==mMisplacedContent.GetSize()){
CTokenRecycler* theRecycler=(CTokenRecycler*)mTokenizer->GetTokenRecycler();
CToken* theBodyToken=theRecycler->CreateTokenOfType(eToken_start,eHTMLTag_body);
mMisplacedContent.Push(theBodyToken);
}
mMisplacedContent.Push(theToken);
theToken=0; //force us to fall to bottom of this method...
result=NS_ERROR_HTMLPARSER_MISPLACED;
}
}
if(theToken){
CITokenHandler* theHandler=GetTokenHandler(theType);
if(theHandler) {
mParser=(nsParser*)aParser;
result=(*theHandler)(theToken,this);
if (mDTDDebug) {
//mDTDDebug->Verify(this, mParser, mBodyContext->GetCount(), mBodyContext->mTags, mFilename);
}
}
}
@ -809,18 +841,29 @@ PRInt32 GetIndexOfChildOrSynonym(nsTagStack& aTagStack,eHTMLTags aChildTag) {
* @return PR_TRUE if child agrees to be opened here.
*/
static
PRBool CanBeContained(eHTMLTags aChildTag,nsTagStack& aTagStack) {
PRBool CanBeContained(eHTMLTags aParentTag,eHTMLTags aChildTag,nsTagStack& aTagStack) {
PRBool result=PR_TRUE;
/* # Interesting test cases: Result:
* 1. <UL><LI>..<B>..<LI> inner <LI> closes outer <LI>
* 2. <CENTER><DL><DT><A><CENTER> allow nested <CENTER>
* 3. <TABLE><TR><TD><TABLE>... allow nested <TABLE>
*/
//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.
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);
if(theRootIndex<theChildIndex){
eHTMLTags thePrevTag=aTagStack.Last();
result=gHTMLElements[thePrevTag].CanContainType(gHTMLElements[aChildTag].mParentBits);
return result;
}
PRInt32 theBaseIndex=(theRootIndex<theChildIndex) ? theRootIndex : theChildIndex;
result=PRBool(theRootIndex>theChildIndex);
}
return result;
@ -851,16 +894,20 @@ 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;
CStartToken theToken(eHTMLTag_body); //open the body container...
result=HandleStartToken(&theToken);
result=CreateContextStackFor(aChildTag);
//CStartToken theToken(eHTMLTag_body); //open the body container...
//result=HandleStartToken(&theToken);
}
}//if
*/
/***********************************************************************
Subtlety alert:
@ -876,24 +923,24 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI
that the <HTML> tag is only *supposed* to contain certain tags --
no one would expect it to accept a rogue <LI> tag (for example).
After the parent decides it CAN accept a child (usually based on the class
of the tag, the child decides it if agrees. For example, consider this stack:
<HTML><BODY>
Here's an interested case we should not break:
<HTML>
<BODY>
<DL>
<DT>
<DD>
<LI>
<DT>
Technically, the <LI> *can* contain the <DT> tag, but the <DT> knows that
this isn't appropriate, since another <DT> is already open on the stack.
Therefore the child will refuse the placement.
The DT is not a child of the LI, so the LI closes. Then the DT also
closes the DD, and it's parent DT. At last, it reopens itself below DL.
***********************************************************************/
eHTMLTags theParentTag=mBodyContext->Last();
PRBool theCanContainResult=CanContain(theParentTag,aChildTag);
PRBool theChildAgrees=CanBeContained(aChildTag,mBodyContext->mTags);
PRBool theChildAgrees=(theCanContainResult) ? CanBeContained(theParentTag,aChildTag,mBodyContext->mTags) : PR_FALSE;
if(!(theCanContainResult && theChildAgrees)) {
eHTMLTags theTarget=FindAutoCloseTargetForStartTag(aChildTag,mBodyContext->mTags);
@ -904,7 +951,6 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI
}
}
if(PR_FALSE==theCanContainResult){
if(CanPropagate(theParentTag,aChildTag))
result=CreateContextStackFor(aChildTag);
@ -1014,13 +1060,16 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsCParserNode
result=gHTMLElements[aTag].HasSpecialProperty(kDiscardTag) ? 1 : NS_OK;
}
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(!gHTMLElements[eHTMLTag_head].IsChildOfHead(aTag)){
if(!isHeadChild){
CEndToken theToken(eHTMLTag_head);
nsCParserNode theNode(&theToken,mLineNumber);
result=CloseHead(theNode);
@ -1032,6 +1081,28 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsCParserNode
return result;
}
/**
* This method gets called when a start token has been encountered that the parent
* wants to omit.
*
* @update gess 3/25/98
* @param aToken -- next (start) token to be handled
* @param aChildTag -- id of the child in question
* @param aParent -- id of the parent in question
* @param aNode -- CParserNode representing this start token
* @return PR_TRUE if all went well; PR_FALSE if error occured
*/
nsresult CNavDTD::HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags aParent,nsIParserNode& aNode) {
nsresult result=NS_OK;
//The trick here is to see if the parent can contain the child, but prefers not to.
//Only if the parent CANNOT contain the child should we look to see if it's potentially a child
//of another section. If it is, the cache it for later.
// 1. Get the root node for the child. See if the ultimate node is the BODY, FRAMESET, HEAD or HTML
return result;
}
/**
* This method gets called when a start token has been
* encountered in the parse process. If the current container
@ -1058,8 +1129,31 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
if(NS_OK==result) {
if(NS_OK==WillHandleStartTag(aToken,theChildTag,attrNode)) {
PRBool theHeadIsParent=nsHTMLElement::IsChildOfHead(theChildTag);
if(nsHTMLElement::IsSectionTag(theChildTag)){
switch(theChildTag){
case eHTMLTag_head:
case eHTMLTag_body:
if(mHadBodyOrFrameset) {
result=HandleOmittedTag(aToken,theChildTag,theParent,attrNode);
return result;
}
break;
case eHTMLTag_frameset:
if(mHasOpenBody) {
result=HandleOmittedTag(aToken,theChildTag,theParent,attrNode);
return result;
}
break;
default:
if(HasOpenContainer(theChildTag)) {
result=HandleOmittedTag(aToken,theChildTag,theParent,attrNode);
return result;
}
}
}
PRBool theHeadIsParent=nsHTMLElement::IsChildOfHead(theChildTag);
switch(theChildTag) {
case eHTMLTag_area:
@ -1067,14 +1161,21 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
result=mSink->AddLeaf(attrNode);
break;
case eHTMLTag_comment:
case eHTMLTag_userdefined:
break; //drop them on the floor for now...
case eHTMLTag_script:
theHeadIsParent=(!mHasOpenBody); //intentionally fall through...
mHasOpenScript=PR_TRUE;
default:
if(theHeadIsParent)
result=AddHeadLeaf(attrNode);
else if(PR_FALSE==CanOmit(theParent,theChildTag)) {
result=HandleDefaultStartToken(aToken,theChildTag,attrNode);
{
if(theHeadIsParent)
result=AddHeadLeaf(attrNode);
else if(CanOmit(theParent,theChildTag))
result=HandleOmittedTag(aToken,theChildTag,theParent,attrNode);
else result=HandleDefaultStartToken(aToken,theChildTag,attrNode);
}
break;
} //switch
@ -1204,12 +1305,13 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) {
nsCParserNode theNode((CHTMLToken*)aToken,mLineNumber);
switch(theChildTag) {
case eHTMLTag_script:
mHasOpenScript=PR_FALSE;
case eHTMLTag_style:
case eHTMLTag_link:
case eHTMLTag_meta:
case eHTMLTag_textarea:
case eHTMLTag_title:
case eHTMLTag_script:
break;
case eHTMLTag_map:
@ -1452,6 +1554,19 @@ CITokenHandler* CNavDTD::GetTokenHandler(eHTMLTokenTypes aType) const {
return result;
}
/**
*
*
* @update gess 4/01/99
* @param aTokenizer
* @return
*/
void CNavDTD::EmitMisplacedContent(nsITokenizer* aTokenizer){
if(aTokenizer){
aTokenizer->PrependTokens(mMisplacedContent);
}
}
/**
* This method is called to determine whether or not a tag
* can contain an explict style tag (font, italic, bold, etc.)
@ -1530,8 +1645,7 @@ PRBool CNavDTD::CanPropagate(eHTMLTags aParentTag,eHTMLTags aChildTag) const {
}
else result=parentCanContain;
return result;
}
}
/**
* This method gets called to determine whether a given
@ -1542,169 +1656,30 @@ PRBool CNavDTD::CanPropagate(eHTMLTags aParentTag,eHTMLTags aChildTag) const {
* @return PR_TRUE if given tag can contain other tags
*/
PRBool CNavDTD::CanOmit(eHTMLTags aParent,eHTMLTags aChild) const {
PRBool result=PR_FALSE;
if((eHTMLTag_userdefined==aParent) && mAllowUnknownTags)
return result;
eHTMLTags theReqAncestor=gHTMLElements[aChild].mRequiredAncestor;
if(eHTMLTag_unknown!=theReqAncestor){
return !HasOpenContainer(theReqAncestor);
}
if(eHTMLTag_head==aChild) {
if(HasOpenContainer(eHTMLTag_body))
if(gHTMLElements[aParent].HasSpecialProperty(kOmitWS)) {
if(nsHTMLElement::IsTextTag(aChild)) {
return PR_TRUE;
}
}
static eHTMLTags canSkip[]={eHTMLTag_body,eHTMLTag_html,eHTMLTag_head};
if(FindTagInSet(aChild,canSkip,sizeof(canSkip)/sizeof(eHTMLTag_unknown))) {
if(HasOpenContainer(aChild))
//Now the obvious test: if the parent can contain the child, don't omit.
if(gHTMLElements[aParent].CanContain(aChild)){
return PR_FALSE;
}
if(nsHTMLElement::IsBlockElement(aParent)) {
if(nsHTMLElement::IsInlineElement(aChild)) { //feel free to drop inlines that a block doesn't contain.
return PR_TRUE;
}
}
//begin with some simple (and obvious) cases...
switch(aParent) {
case eHTMLTag_table:
case eHTMLTag_tbody:
if((eHTMLTag_form==aChild) || (eHTMLTag_table==aChild))
result=PR_FALSE;
else if(FindTagInSet(aChild,gFormElementTags,sizeof(gFormElementTags)/sizeof(eHTMLTag_unknown)))
result=!HasOpenContainer(eHTMLTag_form);
else result=!FindTagInSet(aChild,gTableChildTags,sizeof(gTableChildTags)/sizeof(eHTMLTag_unknown));
break;
case eHTMLTag_tr:
switch(aChild) {
case eHTMLTag_td:
case eHTMLTag_th:
case eHTMLTag_form:
case eHTMLTag_tr:
result=PR_FALSE;
break;
default:
if(FindTagInSet(aChild,gFormElementTags,sizeof(gFormElementTags)/sizeof(eHTMLTag_unknown)))
result=!HasOpenContainer(eHTMLTag_form);
else if(!gHTMLElements[aParent].CanContain(aChild)) {
result=PR_TRUE;
}
}
break;
case eHTMLTag_frameset:
result=!gFramesetKids.Contains(aChild);
break;
case eHTMLTag_unknown:
{
static eHTMLTags canSkip2[]={eHTMLTag_newline,eHTMLTag_whitespace};
if(FindTagInSet(aChild,canSkip2,sizeof(canSkip2)/sizeof(eHTMLTag_unknown))) {
result=PR_TRUE;
}
}
break;
case eHTMLTag_head:
if(eHTMLTag_body==aChild)
result=PR_FALSE;
else result=!nsHTMLElement::IsChildOfHead(aChild);
break;
default:
//ok, since no parent claimed it, test based on the child...
switch(aChild) {
case eHTMLTag_textarea:
break;
case eHTMLTag_userdefined:
case eHTMLTag_comment:
result=PR_TRUE;
break;
case eHTMLTag_body:
result=HasOpenContainer(eHTMLTag_frameset);
break;
// case eHTMLTag_input:
case eHTMLTag_fieldset: case eHTMLTag_isindex:
case eHTMLTag_label: case eHTMLTag_legend:
case eHTMLTag_select: //case eHTMLTag_textarea:
case eHTMLTag_option:
result=!HasOpenContainer(eHTMLTag_form);
break;
case eHTMLTag_newline:
case eHTMLTag_whitespace:
switch(aParent) {
case eHTMLTag_html: case eHTMLTag_head:
case eHTMLTag_title: case eHTMLTag_map:
case eHTMLTag_tr: case eHTMLTag_table:
case eHTMLTag_thead: case eHTMLTag_tfoot:
case eHTMLTag_tbody: case eHTMLTag_col:
case eHTMLTag_colgroup: case eHTMLTag_unknown:
case eHTMLTag_select: case eHTMLTag_fieldset:
case eHTMLTag_frameset: case eHTMLTag_dl:
result=PR_TRUE;
default:
break;
} //switch
break;
//this code prevents table container elements from
//opening unless a table is actually already opened.
case eHTMLTag_tr: case eHTMLTag_thead:
case eHTMLTag_tfoot: case eHTMLTag_tbody:
case eHTMLTag_td: case eHTMLTag_th:
case eHTMLTag_caption:
result=!HasOpenContainer(eHTMLTag_table);
break;
case eHTMLTag_entity:
switch(aParent) {
case eHTMLTag_tr: case eHTMLTag_table:
case eHTMLTag_thead: case eHTMLTag_tfoot:
case eHTMLTag_tbody:
result=PR_TRUE;
default:
break;
} //switch
break;
default:
static eHTMLTags kNonStylizedTabletags[]={eHTMLTag_table,eHTMLTag_tbody,eHTMLTag_tr};
if(nsHTMLElement::IsStyleTag(aChild)) {
if(FindTagInSet(aParent,kNonStylizedTabletags,sizeof(kNonStylizedTabletags)/sizeof(eHTMLTag_unknown)))
return PR_TRUE;
}
else {
//if you're here, then its time to try somthing really different.
//Let's go to the element table, and see who the parent tag of this child is.
//Make sure they're compatible.
CTagList* theRootTags=gHTMLElements[aChild].GetRootTags();
if(theRootTags && HasCloseablePeerAboveRoot(*theRootTags,mBodyContext->mTags,aChild,PR_FALSE)) {
return PR_FALSE;
}
CTagList* theCloseTags=gHTMLElements[aChild].GetAutoCloseStartTags();
if(theCloseTags) {
if(theCloseTags->Contains(aParent)) {
//we can't omit this tag; it will likely close the parent...
return PR_FALSE;
}
}
CTagList* theParents=gHTMLElements[aChild].GetSpecialParents();
if(theParents) {
PRInt32 theParentIndex=theParents->GetTopmostIndexOf(mBodyContext->mTags);
return PRBool(kNotFound==theParentIndex);
// result=!theParents->Contains(aParent); THE OLD WAY
}
}
if(!gHTMLElements[aParent].CanContain(aChild)){
return PR_TRUE;
}
break;
} //switch
break;
}
return result;
return PR_FALSE;
}
@ -2106,13 +2081,15 @@ nsresult CNavDTD::OpenBody(const nsIParserNode& aNode){
result=(mSink) ? mSink->OpenBody(aNode) : NS_OK;
mBodyContext->Push((eHTMLTags)aNode.GetNodeType());
//now THIS is a hack to support plaintext documents in this DTD...
/*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);
}
*/
}
mTokenizer->PrependTokens(mMisplacedContent);
return result;
}
@ -2266,11 +2243,14 @@ CNavDTD::OpenContainer(const nsIParserNode& aNode,PRBool aUpdateStyleStack){
break;
case eHTMLTag_body:
mHasOpenBody=PR_TRUE;
if(mHasOpenHead)
mHasOpenHead=1;
CloseHead(aNode); //do this just in case someone left it open...
result=OpenBody(aNode); break;
if(!mHasOpenBody){
mHasOpenBody=PR_TRUE;
if(mHasOpenHead)
mHasOpenHead=1;
CloseHead(aNode); //do this just in case someone left it open...
result=OpenBody(aNode);
}
break;
case eHTMLTag_style:
case eHTMLTag_title:

View File

@ -261,6 +261,8 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
*/
NS_IMETHOD WillInterruptParse(void);
virtual void EmitMisplacedContent(nsITokenizer* aTokenizer);
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.
@ -507,7 +509,7 @@ protected:
nsresult CollectSkippedContent(nsCParserNode& aNode,PRInt32& aCount);
nsresult WillHandleStartTag(CToken* aToken,eHTMLTags aChildTag,nsCParserNode& aNode);
nsresult DidHandleStartTag(nsCParserNode& aNode,eHTMLTags aChildTag);
nsresult HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags aParent,nsIParserNode& aNode);
nsIHTMLContentSink* mSink;
@ -517,7 +519,6 @@ protected:
nsDTDContext* mBodyContext;
nsDTDContext* mFormContext;
nsDTDContext* mMapContext;
PRBool mAllowUnknownTags;
PRBool mHasOpenForm;
PRBool mHasOpenMap;
PRInt32 mHasOpenHead;
@ -528,7 +529,8 @@ protected:
PRInt32 mLineNumber;
nsParser* mParser;
nsITokenizer* mTokenizer;
PRBool mIsPlaintext;
nsDeque mMisplacedContent;
PRBool mHasOpenScript;
PRUint32 mComputedCRC32;
PRUint32 mExpectedCRC32;

View File

@ -305,7 +305,7 @@ nsresult COtherDTD::HandleScriptToken(nsCParserNode& aNode) {
nsresult COtherDTD::HandleStyleToken(CToken* aToken){
return CNavDTD::HandleStyleToken(aToken);
}
/**
* This method is called to determine whether or not a tag

View File

@ -353,6 +353,16 @@ PRBool CRtfDTD::IsContainer(PRInt32 aTag) const{
return result;
}
/**
*
*
* @update gess 4/01/99
* @param aTokenizer
* @return
*/
void CRtfDTD::EmitMisplacedContent(nsITokenizer* aTokenizer){
}
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.

View File

@ -310,6 +310,8 @@ class CRtfDTD : public nsIDTD {
*/
virtual void SetVerification(PRBool aEnable);
virtual void EmitMisplacedContent(nsITokenizer* aTokenizer);
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.

View File

@ -265,7 +265,9 @@ CTokenRecycler::CTokenRecycler() : nsITokenRecycler() {
int i=0;
for(i=0;i<eToken_last-1;i++) {
mTokenCache[i]=new nsDeque(new CTokenDeallocator());
//mTotals[i]=0;
#ifdef NS_DEBUG
mTotals[i]=0;
#endif
}
}
@ -330,16 +332,18 @@ CToken* CTokenRecycler::CreateTokenOfType(eHTMLTokenTypes aType,eHTMLTags aTag,
result->Reinitialize(aTag,aString);
}
else {
//mTotals[aType-1]++;
#ifdef NS_DEBUG
mTotals[aType-1]++;
#endif
switch(aType){
case eToken_start: result=new CStartToken(aTag); break;
case eToken_end: result=new CEndToken(aTag); break;
case eToken_comment: result=new CCommentToken(); break;
case eToken_attribute: result=new CAttributeToken(); break;
case eToken_entity: result=new CEntityToken(); break;
case eToken_whitespace: result=new CWhitespaceToken(); break;
case eToken_newline: result=new CNewlineToken(); break;
case eToken_text: result=new CTextToken(aString); break;
case eToken_attribute: result=new CAttributeToken(); break;
case eToken_script: result=new CScriptToken(); break;
case eToken_style: result=new CStyleToken(); break;
case eToken_skippedcontent: result=new CSkippedContentToken(aString); break;
@ -367,7 +371,9 @@ CToken* CTokenRecycler::CreateTokenOfType(eHTMLTokenTypes aType,eHTMLTags aTag)
result->Reinitialize(aTag,theEmpty);
}
else {
//mTotals[aType-1]++;
#ifdef NS_DEBUG
mTotals[aType-1]++;
#endif
switch(aType){
case eToken_start: result=new CStartToken(aTag); break;
case eToken_end: result=new CEndToken(aTag); break;

View File

@ -148,7 +148,9 @@ public:
protected:
nsDeque* mTokenCache[eToken_last-1];
// int mTotals[eToken_last-1];
#ifdef NS_DEBUG
int mTotals[eToken_last-1];
#endif
};
/************************************************************************

View File

@ -75,37 +75,6 @@ PRInt32 CTagList::GetBottommostIndexOf(nsTagStack& aTagStack,PRInt32 aStartOffse
return kNotFound;
}
//*********************************************************************************************
// The following ints define the standard groups of HTML elements...
//*********************************************************************************************
static const int kNone= 0x0;
static const int kHTMLContent = 0x0001; // HEAD, (FRAMESET | BODY)
static const int kHeadContent = 0x0002; // TITLE, ISINDEX, BASE
static const int kHeadMisc = 0x0004; // SCRIPT, STYLE, META, LINK, OBJECT
static const int kSpecial = 0x0008; // A, IMG, APPLET, OBJECT, FONT, BASEFONT, BR, SCRIPT,
// MAP, Q, SUB, SUP, SPAN, BDO, IFRAME
static const int kFormControl = 0x0010; // INPUT SELECT TEXTAREA LABEL BUTTON
static const int kPreformatted = 0x0011; // PRE
static const int kPreExclusion = 0x0012; // IMG, OBJECT, APPLET, BIG, SMALL, SUB, SUP, FONT, BASEFONT
static const int kFontStyle = 0x0014; // TT, I, B, U, S, STRIKE, BIG, SMALL
static const int kPhrase = 0x0018; // EM, STRONG, DFN, CODE, SAMP, KBD, VAR, CITE, ABBR, ACRONYM
static const int kHeading = 0x0020; // H1..H6
static const int kBlockMisc = 0x0021; // P, DL, DIV, CENTER, NOSCRIPT, NOFRAMES, BLOCKQUOTE
// FORM, ISINDEX, HR, TABLE, FIELDSET, ADDRESS
static const int kList = 0x0024; // UL, OL, DIR, MENU
static const int kPCDATA = 0x0028; // just plain text...
static const int kSelf = 0x0040; // whatever THIS tag is...
static const int kInline = (kPCDATA|kFontStyle|kPhrase|kSpecial|kFormControl); // #PCDATA, %fontstyle, %phrase, %special, %formctrl
static const int kBlock = (kHeading|kList|kPreformatted|kBlockMisc); // %heading, %list, %preformatted, %blockmisc
static const int kFlow = (kBlock|kInline); // %block, %inline
static eHTMLTags gStyleTags[]={
eHTMLTag_a, eHTMLTag_acronym, eHTMLTag_b,
@ -113,7 +82,7 @@ static eHTMLTags gStyleTags[]={
eHTMLTag_center, eHTMLTag_cite, eHTMLTag_code,
eHTMLTag_del, eHTMLTag_dfn, eHTMLTag_em,
eHTMLTag_font, eHTMLTag_i, eHTMLTag_ins,
eHTMLTag_kbd, eHTMLTag_nobr, eHTMLTag_q,
eHTMLTag_kbd, eHTMLTag_q,
eHTMLTag_s, eHTMLTag_samp, eHTMLTag_small,
eHTMLTag_span, eHTMLTag_strike, eHTMLTag_strong,
eHTMLTag_sub, eHTMLTag_sup, eHTMLTag_tt,
@ -135,10 +104,10 @@ CTagList gInBody(1,0,eHTMLTag_body);
CTagList gInForm(1,0,eHTMLTag_form);
CTagList gInFieldset(1,0,eHTMLTag_fieldset);
CTagList gInTR(1,0,eHTMLTag_tr);
CTagList gInDL(1,0,eHTMLTag_dl);
CTagList gInDL(2,0,eHTMLTag_dl,eHTMLTag_body);
CTagList gInFrameset(1,0,eHTMLTag_frameset);
CTagList gInNoframes(1,0,eHTMLTag_noframes);
CTagList gInP(2,0,eHTMLTag_address,eHTMLTag_form);
CTagList gInP(3,0,eHTMLTag_address,eHTMLTag_form,eHTMLTag_table);
CTagList gOptgroupParents(2,0,eHTMLTag_optgroup,eHTMLTag_select);
CTagList gBodyParents(2,0,eHTMLTag_html,eHTMLTag_noframes);
CTagList gColParents(2,0,eHTMLTag_colgroup,eHTMLTag_table);
@ -239,20 +208,30 @@ CTagList gULCloseTags(1,0,eHTMLTag_li);
nsHTMLElement gHTMLElements[] = {
{ /*tag*/ eHTMLTag_unknown,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ 0,&gContainsHTML,eHTMLTag_unknown},
/*************************************************
Note: I changed A to contain flow elements
since it's such a popular (but illegal)
idiom.
*************************************************/
{ /*tag*/ eHTMLTag_a,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, kInline, kNone,
/*special properties*/ 0,
/*parent,incl,exclgroups*/ kSpecial, kFlow, kNone,
/*special properties*/ 0,
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_abbr,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPhrase, kInline, kNone,
@ -260,6 +239,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_acronym,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPhrase, (kInline|kSelf), kNone,
@ -267,6 +247,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_address,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, kInline, kNone,
@ -274,6 +255,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gAddressKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_applet,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, kFlow, kNone,
@ -281,6 +263,7 @@ nsHTMLElement gHTMLElements[] = {
/*special kids: <PARAM>*/ 0,&gContainsParam,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_area,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gAreaParent,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, kInline, kSelf,
@ -288,6 +271,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gAreaParent,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_b,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kFlow|kSelf), kNone,
@ -295,6 +279,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_base,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInHead, &gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -302,6 +287,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInHead,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_basefont,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, kNone, kNone,
@ -309,6 +295,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_bdo,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, (kSelf|kInline), kNone,
@ -316,6 +303,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_bgsound,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -323,6 +311,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_big,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kFlow|kSelf), kNone,
@ -330,6 +319,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_blink,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kFlow|kSelf), kNone,
@ -337,6 +327,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_blockquote,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -344,6 +335,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_body,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInHTML, &gInHTML,
/*autoclose starttags and endtags*/ &gBodyAutoClose,0,0,
/*parent,incl,exclgroups*/ kHTMLContent, kFlow, kNone,
@ -351,6 +343,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInNoframes,&gBodyKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_br,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, kNone, kNone,
@ -358,6 +351,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_button,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFormControl, kFlow, kFormControl,
@ -365,6 +359,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gButtonKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_caption,
/*requiredAncestor*/ eHTMLTag_table,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gCaptionAutoClose,0,0,
/*parent,incl,exclgroups*/ kNone, kInline, kSelf,
@ -372,6 +367,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInTable,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_center,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, (kInline|kSelf|kFlow), kNone,
@ -379,6 +375,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_cite,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPhrase, (kInline|kSelf), kNone,
@ -386,6 +383,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_code,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone,
@ -393,20 +391,23 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_col,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gColParents,&gColParents,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gColParents,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_colgroup,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gInTable,&gColgroupKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_dd,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInDL, &gInDL,
/*autoclose starttags and endtags*/ &gDTCloseTags,0,0,
/*parent,incl,exclgroups*/ kNone, kFlow, kNone,
@ -414,6 +415,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInDL,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_del,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, (kSelf|kFlow), kNone,
@ -421,6 +423,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInBody,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_dfn,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone,
@ -428,6 +431,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_dir,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, (kSelf|kFlow), kNone,
@ -435,6 +439,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gULKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_div,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gDivAutoClose,0,0,
/*parent,incl,exclgroups*/ kBlock, (kSelf|kFlow), kNone,
@ -442,13 +447,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_dl,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, (kSpecial|kFontStyle), kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ 0,&gDLKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_dt,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInDL,&gInDL,
/*autoclose starttags and endtags*/ &gDTCloseTags,0,0,
/*parent,incl,exclgroups*/ kNone, kInline, kNone,
@ -456,6 +463,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents, kids <DT>*/ &gInDL,&gDTKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_em,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone,
@ -463,20 +471,31 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_embed,
/*requiredAncestor*/ 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,&gContainsParam,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_endnote,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kFlow, kNone,
/*special properties*/ 0,
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_fieldset,
/*requiredAncestor*/ eHTMLTag_form,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ 0,&gFieldsetKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_font,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, (kSelf|kFlow), kNone,
@ -484,6 +503,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gFontKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_form,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -491,6 +511,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gFormKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_frame,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInFrameset,&gInFrameset,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -498,14 +519,16 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInFrameset,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_frameset,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInHTML,&gInHTML,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kSelf, kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gInHTML,&gFramesetKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_h1,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -513,6 +536,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_h2,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -520,6 +544,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_h3,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -527,6 +552,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_h4,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -534,6 +560,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_h5,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -541,6 +568,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_h6,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -548,13 +576,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_head,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInHTML, &gInHTML,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, (kHeadContent|kHeadMisc), kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gInHTML,&gHeadKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_hr,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gHRAutoClose,0,0,
/*parent,incl,exclgroups*/ kBlock, kNone, kNone,
@ -562,13 +592,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_html,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gHTMLRootTags, &gHTMLRootTags,
/*autoclose starttags and endtags*/ &gAutoClose,0,0,
/*parent,incl,exclgroups*/ kNone, kHTMLContent, kNone,
/*special properties*/ kOmitEndTag,
/*special properties*/ kOmitEndTag|kOmitWS,
/*special parents,kids,skip*/ 0,&gHtmlKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_i,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone,
@ -576,6 +608,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_iframe,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, kFlow, kNone,
@ -583,13 +616,23 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_ilayer,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
/*special properties*/ 0,
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_image,
/*requiredAncestor*/ 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_unknown},
{ /*tag*/ eHTMLTag_img,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -597,6 +640,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_input,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFormControl, kNone, kNone,
@ -604,6 +648,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_ins,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, (kSelf|kNone), kNone,
@ -611,6 +656,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_isindex,
/*requiredAncestor*/ eHTMLTag_form,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ (kBlock|kHeadContent), kFlow, kNone,
@ -618,6 +664,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInBody,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_kbd,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPhrase, (kSelf|kFlow), kNone,
@ -625,6 +672,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_keygen,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -632,6 +680,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_label,
/*requiredAncestor*/ eHTMLTag_form,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFormControl, kInline, kSelf,
@ -639,6 +688,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_layer,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, kFlow, kSelf,
@ -646,6 +696,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_legend,
/*requiredAncestor*/ eHTMLTag_form,
/*rootnodes,endrootnodes*/ &gInFieldset,&gInFieldset,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kInline, kNone,
@ -653,6 +704,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInFieldset,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_li,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gLIRootTags,&gLIRootTags,
/*autoclose starttags and endtags*/ &gLIAutoClose,0,0,
/*parent,incl,exclgroups*/ kList, kFlow, kSelf,
@ -660,6 +712,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gLIKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_link,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInHead,&gInHead,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kHeadMisc, kNone, kNone,
@ -667,6 +720,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInHead,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_listing,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -674,13 +728,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_map,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, kBlock, kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ 0,&gMapKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_menu,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kList, (kSelf|kFlow), kNone,
@ -688,6 +744,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gULKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_meta,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInHead, &gInHead,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kHeadMisc, kNone, kNone,
@ -695,6 +752,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInHead,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_multicol,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -702,13 +760,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_nobr,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, (kFlow|kSelf), kNone,
/*parent,incl,exclgroups*/ kFlow, (kFlow), kNone,
/*special properties*/ 0,
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_noembed,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -716,6 +776,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_noembed},
{ /*tag*/ eHTMLTag_noframes,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gNoframeRoot,&gNoframeRoot,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -723,6 +784,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gNoframeRoot,&gNoframesKids,eHTMLTag_noframes},
{ /*tag*/ eHTMLTag_nolayer,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -730,6 +792,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_nolayer},
{ /*tag*/ eHTMLTag_noscript,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
@ -737,13 +800,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_noscript},
{ /*tag*/ eHTMLTag_object,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ (kHeadMisc|kSpecial), kFlow, kNone,
/*parent,incl,exclgroups*/ (kHeadMisc|kSpecial), (kFlow|kSelf), kNone,
/*special properties*/ 0,
/*special parents,kids,skip*/ 0,&gContainsParam,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_ol,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gOLRootTags,&gOLRootTags,
/*autoclose starttags and endtags*/ &gOLAutoClose, &gULCloseTags, 0,
/*parent,incl,exclgroups*/ kBlock, (kFlow|kSelf), kNone,
@ -751,6 +816,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gULKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_optgroup,
/*requiredAncestor*/ eHTMLTag_select,
/*rootnodes,endrootnodes*/ &gOptgroupParents,&gOptgroupParents,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -758,6 +824,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gOptgroupParents,&gContainsOpts,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_option,
/*requiredAncestor*/ eHTMLTag_form,
/*rootnodes,endrootnodes*/ &gOptgroupParents,&gOptgroupParents,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kPCDATA, kNone,
@ -765,13 +832,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gOptgroupParents,&gContainsText,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_p,
/*requiredAncestor*/ 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, 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
/*special parents,kids,skip*/ 0,&gInP,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_param,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gParamParents, &gParamParents,
/*autoclose starttags and endtags*/ &gPAutoClose,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -779,6 +848,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gParamParents,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_parsererror,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gDivAutoClose,0,0,
/*parent,incl,exclgroups*/ kBlock, (kSelf|kFlow), kNone,
@ -786,6 +856,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_plaintext,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kFlow, kNone,
@ -793,6 +864,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_html},
{ /*tag*/ eHTMLTag_pre,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPreformatted, kInline, kNone,
@ -800,6 +872,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gPreKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_q,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, (kSelf|kInline), kNone,
@ -807,6 +880,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_s,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone,
@ -814,6 +888,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_samp,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone,
@ -821,6 +896,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_script,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ (kSpecial|kHeadMisc), kPCDATA, kNone,
@ -828,13 +904,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gContainsText,eHTMLTag_script},
{ /*tag*/ eHTMLTag_select,
/*requiredAncestor*/ eHTMLTag_form,
/*rootnodes,endrootnodes*/ &gInForm,&gInForm,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFormControl, kNone, kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gInForm,&gContainsOpts,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_server,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -842,6 +920,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_small,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone,
@ -849,6 +928,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_sound,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -856,6 +936,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_sourcetext,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ &gDivAutoClose,0,0,
/*parent,incl,exclgroups*/ kBlock, (kSelf|kFlow), kNone,
@ -863,6 +944,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_spacer,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -870,6 +952,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_span,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kSpecial, (kSelf|kInline), kNone,
@ -877,6 +960,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_strike,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone,
@ -884,6 +968,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_strong,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ (kPhrase|kFontStyle), (kSelf|kFlow), kNone,
@ -891,6 +976,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gContainsText,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_style,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInHead, &gInHead,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kHeadMisc, kPCDATA, kNone,
@ -898,6 +984,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInHead,0,eHTMLTag_style},
{ /*tag*/ eHTMLTag_sub,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone,
@ -905,6 +992,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_sup,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone,
@ -912,20 +1000,23 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_table,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gInBody,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kBlock, kNone, kSelf,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ 0,&gTableKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_tbody,
/*requiredAncestor*/ eHTMLTag_table,
/*rootnodes,endrootnodes*/ &gInTable, &gInTable,
/*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kSelf,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gInTable,&gTBodyKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_td,
/*requiredAncestor*/ eHTMLTag_table,
/*rootnodes,endrootnodes*/ &gTDRootTags,&gTDRootTags,
/*autoclose starttags and endtags*/ &gTDCloseTags,&gTDCloseTags,0,
/*parent,incl,exclgroups*/ kNone, kFlow, kSelf,
@ -933,6 +1024,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gTDRootTags,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_textarea,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInForm, &gInForm,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFormControl, kPCDATA, kNone,
@ -940,13 +1032,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gInForm,&gContainsText,eHTMLTag_textarea},
{ /*tag*/ eHTMLTag_tfoot,
/*requiredAncestor*/ eHTMLTag_table,
/*rootnodes,endrootnodes*/ &gInTable, &gInTable,
/*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kSelf,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gInTable,&gTableElemKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_th,
/*requiredAncestor*/ eHTMLTag_table,
/*rootnodes,endrootnodes*/ &gTDRootTags,&gTDRootTags,
/*autoclose starttags and endtags*/ &gTDCloseTags,&gTDCloseTags,0,
/*parent,incl,exclgroups*/ kNone, kFlow, kSelf,
@ -954,27 +1048,31 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ &gTDRootTags,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_thead,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInTable,&gInTable,
/*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kSelf,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gInTable,&gTableElemKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_title,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInHead,&gInHead,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, (kHeadMisc|kPCDATA), kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gInHead,&gContainsText,eHTMLTag_title},
{ /*tag*/ eHTMLTag_tr,
/*requiredAncestor*/ eHTMLTag_table,
/*rootnodes,endrootnodes*/ &gTRParents,&gTRParents,
/*autoclose starttags and endtags*/ &gTRCloseTags,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
/*special properties*/ 0,
/*special properties*/ kOmitWS,
/*special parents,kids,skip*/ &gTRParents,&gTRKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_tt,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone,
@ -982,6 +1080,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_u,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFontStyle, (kSelf|kFlow), kNone,
@ -989,6 +1088,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_ul,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gOLRootTags,&gOLRootTags,
/*autoclose starttags and endtags*/ &gOLAutoClose,&gULCloseTags,0,
/*parent,incl,exclgroups*/ kBlock, (kFlow|kSelf), kNone,
@ -996,6 +1096,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,&gULKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_var,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kPhrase, (kSelf|kInline), kNone,
@ -1003,6 +1104,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_wbr,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -1010,6 +1112,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_xmp,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -1017,13 +1120,15 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_xmp},
{ /*tag*/ eHTMLTag_text,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gTextRootTags,&gTextRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
/*special properties*/ 0,
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_whitespace,
{ /*tag*/ eHTMLTag_whitespace,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gTextRootTags,&gTextRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -1031,6 +1136,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_newline,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gTextRootTags,&gTextRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -1038,6 +1144,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_comment,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -1045,6 +1152,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_entity,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gTextRootTags,&gTextRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kFlow, kNone, kNone,
@ -1052,6 +1160,7 @@ nsHTMLElement gHTMLElements[] = {
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_userdefined,
/*requiredAncestor*/ eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,
/*parent,incl,exclgroups*/ kNone, kNone, kNone,
@ -1248,6 +1357,28 @@ PRBool nsHTMLElement::IsFlowParent(eHTMLTags aTag){
return result;
}
/**
* Tells us whether the given tag opens a section
* @update gess 01/04/99
* @param id of tag
* @return TRUE if opens section
*/
PRBool nsHTMLElement::IsSectionTag(eHTMLTags aTag){
PRBool result=PR_FALSE;
switch(aTag){
case eHTMLTag_html:
case eHTMLTag_frameset:
case eHTMLTag_body:
case eHTMLTag_head:
result=PR_TRUE;
break;
default:
result=PR_FALSE;
}
return result;
}
/**
*
* @update gess 01/04/99
@ -1339,6 +1470,18 @@ PRBool nsHTMLElement::IsMemberOf(PRInt32 aSet) const{
return result;
}
/**
*
* @update gess12/13/98
* @param
* @return
*/
PRBool nsHTMLElement::IsWhitespaceTag(eHTMLTags aChild) {
static eHTMLTags gWSTags[]={eHTMLTag_newline, eHTMLTag_whitespace};
PRBool result=FindTagInSet(aChild,gWSTags,sizeof(gWSTags)/sizeof(eHTMLTag_body));
return result;
}
/**
*
* @update gess12/13/98

View File

@ -84,6 +84,7 @@ struct nsHTMLElement {
static PRBool IsBlockParent(eHTMLTags aTag);
static PRBool IsInlineParent(eHTMLTags aTag);
static PRBool IsFlowParent(eHTMLTags aTag);
static PRBool IsSectionTag(eHTMLTags aTag);
CTagList* GetSpecialChildren(void) const {return mSpecialKids;}
CTagList* GetSpecialParents(void) const {return mSpecialParents;}
@ -104,8 +105,10 @@ struct nsHTMLElement {
static PRBool IsHeadingTag(eHTMLTags aTag) ;
static PRBool IsChildOfHead(eHTMLTags aTag) ;
static PRBool IsTextTag(eHTMLTags aTag);
static PRBool IsWhitespaceTag(eHTMLTags aTag);
eHTMLTags mTagID;
eHTMLTags mRequiredAncestor;
CTagList* mRootNodes; //These are the tags above which you many not autoclose a START tag
CTagList* mEndRootNodes; //These are the tags above which you many not autoclose an END tag
CTagList* mAutocloseStart; //these are the start tags that you can automatically close with this START tag
@ -125,9 +128,40 @@ extern CTagList gFramesetKids;
extern CTagList gHeadingTags;
//special property bits...
static const int kDiscardTag = 0x0001; //tells us to toss this tag
static const int kOmitEndTag = 0x0002; //safely ignore end tag
static const int kLegalOpen = 0x0004; //Lets BODY, TITLE, SCRIPT to reopen
static const int kDiscardTag = 0x0001; //tells us to toss this tag
static const int kOmitEndTag = 0x0002; //safely ignore end tag
static const int kLegalOpen = 0x0004; //Lets BODY, TITLE, SCRIPT to reopen
static const int kOmitWS = 0x0008; //If set, the tag can omit all ws and newlines
//*********************************************************************************************
// The following ints define the standard groups of HTML elements...
//*********************************************************************************************
static const int kNone= 0x0;
static const int kHTMLContent = 0x0001; // HEAD, (FRAMESET | BODY)
static const int kHeadContent = 0x0002; // TITLE, ISINDEX, BASE
static const int kHeadMisc = 0x0004; // SCRIPT, STYLE, META, LINK, OBJECT
static const int kSpecial = 0x0008; // A, IMG, APPLET, OBJECT, FONT, BASEFONT, BR, SCRIPT,
// MAP, Q, SUB, SUP, SPAN, BDO, IFRAME
static const int kFormControl = 0x0010; // INPUT SELECT TEXTAREA LABEL BUTTON
static const int kPreformatted = 0x0011; // PRE
static const int kPreExclusion = 0x0012; // IMG, OBJECT, APPLET, BIG, SMALL, SUB, SUP, FONT, BASEFONT
static const int kFontStyle = 0x0014; // TT, I, B, U, S, STRIKE, BIG, SMALL
static const int kPhrase = 0x0018; // EM, STRONG, DFN, CODE, SAMP, KBD, VAR, CITE, ABBR, ACRONYM
static const int kHeading = 0x0020; // H1..H6
static const int kBlockMisc = 0x0021; // P, DL, DIV, CENTER, NOSCRIPT, NOFRAMES, BLOCKQUOTE
// FORM, ISINDEX, HR, TABLE, FIELDSET, ADDRESS
static const int kList = 0x0024; // UL, OL, DIR, MENU
static const int kPCDATA = 0x0028; // just plain text...
static const int kSelf = 0x0040; // whatever THIS tag is...
static const int kInline = (kPCDATA|kFontStyle|kPhrase|kSpecial|kFormControl); // #PCDATA, %fontstyle, %phrase, %special, %formctrl
static const int kBlock = (kHeading|kList|kPreformatted|kBlockMisc); // %heading, %list, %preformatted, %blockmisc
static const int kFlow = (kBlock|kInline); // %block, %inline
#endif

View File

@ -367,6 +367,16 @@ PRBool nsExpatDTD::Verify(nsString& aURLRef,nsIParser* aParser) {
void nsExpatDTD::SetVerification(PRBool aEnabled){
}
/**
*
*
* @update gess 4/01/99
* @param aTokenizer
* @return
*/
void nsExpatDTD::EmitMisplacedContent(nsITokenizer* aTokenizer){
}
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.

View File

@ -203,6 +203,8 @@ class nsExpatDTD : public nsIDTD {
*/
virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild) const;
virtual void EmitMisplacedContent(nsITokenizer* aTokenizer);
/**
* This method gets called to determine whether a given
* tag is itself a container

View File

@ -133,6 +133,7 @@ void nsExpatTokenizer::SetupExpatCallbacks(void) {
nsExpatTokenizer::nsExpatTokenizer() : nsHTMLTokenizer() {
NS_INIT_REFCNT();
mExpatParser = XML_ParserCreate(NULL);
gTokenRecycler=(CTokenRecycler*)GetTokenRecycler();
if (mExpatParser) {
SetupExpatCallbacks();
}
@ -222,7 +223,7 @@ void nsExpatTokenizer::PushXMLErrorToken(const char *aBuffer, PRUint32 aLength)
token->SetError(error);
CToken* theToken = (CToken* )token;
AddToken(theToken, NS_OK, *gTokenDeque);
AddToken(theToken, NS_OK, *gTokenDeque,gTokenRecycler);
}
nsresult nsExpatTokenizer::ParseXMLBuffer(const char *aBuffer, PRUint32 aLength){
@ -264,7 +265,6 @@ nsresult nsExpatTokenizer::ConsumeToken(nsScanner& aScanner) {
if(0 < length) {
char* expatBuffer = theBuffer.ToNewCString();
if (expatBuffer) {
gTokenRecycler=(CTokenRecycler*)GetTokenRecycler();
gTokenDeque=&mTokenDeque;
gExpatParser = mExpatParser;
result = ParseXMLBuffer(expatBuffer, length);
@ -277,6 +277,16 @@ nsresult nsExpatTokenizer::ConsumeToken(nsScanner& aScanner) {
return result;
}
/**
*
* @update gess12/29/98
* @param
* @return
*/
void nsExpatTokenizer::FrontloadMisplacedContent(nsDeque& aDeque){
}
/***************************************/
/* Expat Callback Functions start here */
/***************************************/
@ -286,7 +296,7 @@ void nsExpatTokenizer::HandleStartElement(void *userData, const XML_Char *name,
if(theToken) {
nsString& theString=theToken->GetStringValueXXX();
theString.SetString(name);
AddToken(theToken,NS_OK,*gTokenDeque);
AddToken(theToken,NS_OK,*gTokenDeque,gTokenRecycler);
int theAttrCount=0;
while(*atts){
theAttrCount++;
@ -298,7 +308,7 @@ void nsExpatTokenizer::HandleStartElement(void *userData, const XML_Char *name,
theValue.SetString(*atts++);
}
CToken* theTok=(CToken*)theAttrToken;
AddToken(theTok,NS_OK,*gTokenDeque);
AddToken(theTok,NS_OK,*gTokenDeque,gTokenRecycler);
}
theToken->SetAttributeCount(theAttrCount);
}
@ -312,7 +322,7 @@ void nsExpatTokenizer::HandleEndElement(void *userData, const XML_Char *name) {
if(theToken) {
nsString& theString=theToken->GetStringValueXXX();
theString.SetString(name);
AddToken(theToken,NS_OK,*gTokenDeque);
AddToken(theToken,NS_OK,*gTokenDeque,gTokenRecycler);
}
else{
//THROW A HUGE ERROR IF WE CANT CREATE A TOKEN!
@ -336,7 +346,7 @@ void nsExpatTokenizer::HandleCharacterData(void *userData, const XML_Char *s, in
// We've reached the end of the current CDATA section. Push the current CDATA token
// onto the token queue and reset state to being outside a CDATA section.
CToken* tempCDATAToken = (CToken*) currentCDataToken;
AddToken(tempCDATAToken,NS_OK,*gTokenDeque);
AddToken(tempCDATAToken,NS_OK,*gTokenDeque,gTokenRecycler);
currentCDataToken = 0;
XML_SetUserData(gExpatParser, 0);
}
@ -364,7 +374,7 @@ void nsExpatTokenizer::HandleCharacterData(void *userData, const XML_Char *s, in
nsString& theString=newToken->GetStringValueXXX();
theString.Append(s,len);
}
AddToken(newToken,NS_OK,*gTokenDeque);
AddToken(newToken,NS_OK,*gTokenDeque,gTokenRecycler);
}
else {
//THROW A HUGE ERROR IF WE CANT CREATE A TOKEN!
@ -383,7 +393,7 @@ void nsExpatTokenizer::HandleProcessingInstruction(void *userData, const XML_Cha
theString.Append(data);
}
theString.Append("?>");
AddToken(theToken,NS_OK,*gTokenDeque);
AddToken(theToken,NS_OK,*gTokenDeque,gTokenRecycler);
}
else{
//THROW A HUGE ERROR IF WE CANT CREATE A TOKEN!

View File

@ -53,6 +53,9 @@ public:
/* nsITokenizer methods */
virtual nsresult ConsumeToken(nsScanner& aScanner);
virtual void FrontloadMisplacedContent(nsDeque& aDeque);
protected:
/**

View File

@ -25,16 +25,17 @@ static char* tagTable[] = {
"a", "abbr", "acronym", "address", "applet", "area", "b", "base",
"basefont", "bdo", "bgsound", "big", "blink", "blockquote", "body", "br",
"button", "caption", "center", "cite", "code", "col", "colgroup", "dd",
"del", "dfn", "dir", "div", "dl", "dt", "em", "embed", "fieldset", "font",
"form", "frame", "frameset", "h1", "h2", "h3", "h4", "h5", "h6", "head",
"hr", "html", "i", "iframe", "ilayer", "img", "input", "ins", "isindex",
"kbd", "keygen", "label", "layer", "legend", "li", "link", "listing",
"map", "menu", "meta", "multicol", "nobr", "noembed", "noframes",
"nolayer", "noscript", "object", "ol", "optgroup", "option", "p", "param",
"parsererror", "plaintext", "pre", "q", "s", "samp", "script", "select",
"server", "small", "sound", "sourcetext", "spacer", "span", "strike",
"strong", "style", "sub", "sup", "table", "tbody", "td", "textarea",
"tfoot", "th", "thead", "title", "tr", "tt", "u", "ul", "var", "wbr", "xmp"
"del", "dfn", "dir", "div", "dl", "dt", "em", "embed", "endnote",
"fieldset", "font", "form", "frame", "frameset", "h1", "h2", "h3", "h4",
"h5", "h6", "head", "hr", "html", "i", "iframe", "ilayer", "image", "img",
"input", "ins", "isindex", "kbd", "keygen", "label", "layer", "legend",
"li", "link", "listing", "map", "menu", "meta", "multicol", "nobr",
"noembed", "noframes", "nolayer", "noscript", "object", "ol", "optgroup",
"option", "p", "param", "parsererror", "plaintext", "pre", "q", "s",
"samp", "script", "select", "server", "small", "sound", "sourcetext",
"spacer", "span", "strike", "strong", "style", "sub", "sup", "table",
"tbody", "td", "textarea", "tfoot", "th", "thead", "title", "tr", "tt",
"u", "ul", "var", "wbr", "xmp"
};
nsHTMLTag NS_TagToEnum(const char* aTagName) {

View File

@ -34,37 +34,39 @@ enum nsHTMLTag {
eHTMLTag_center=19, eHTMLTag_cite=20, eHTMLTag_code=21, eHTMLTag_col=22,
eHTMLTag_colgroup=23, eHTMLTag_dd=24, eHTMLTag_del=25, eHTMLTag_dfn=26,
eHTMLTag_dir=27, eHTMLTag_div=28, eHTMLTag_dl=29, eHTMLTag_dt=30,
eHTMLTag_em=31, eHTMLTag_embed=32, eHTMLTag_fieldset=33, eHTMLTag_font=34,
eHTMLTag_form=35, eHTMLTag_frame=36, eHTMLTag_frameset=37, eHTMLTag_h1=38,
eHTMLTag_h2=39, eHTMLTag_h3=40, eHTMLTag_h4=41, eHTMLTag_h5=42,
eHTMLTag_h6=43, eHTMLTag_head=44, eHTMLTag_hr=45, eHTMLTag_html=46,
eHTMLTag_i=47, eHTMLTag_iframe=48, eHTMLTag_ilayer=49, eHTMLTag_img=50,
eHTMLTag_input=51, eHTMLTag_ins=52, eHTMLTag_isindex=53, eHTMLTag_kbd=54,
eHTMLTag_keygen=55, eHTMLTag_label=56, eHTMLTag_layer=57,
eHTMLTag_legend=58, eHTMLTag_li=59, eHTMLTag_link=60, eHTMLTag_listing=61,
eHTMLTag_map=62, eHTMLTag_menu=63, eHTMLTag_meta=64, eHTMLTag_multicol=65,
eHTMLTag_nobr=66, eHTMLTag_noembed=67, eHTMLTag_noframes=68,
eHTMLTag_nolayer=69, eHTMLTag_noscript=70, eHTMLTag_object=71,
eHTMLTag_ol=72, eHTMLTag_optgroup=73, eHTMLTag_option=74, eHTMLTag_p=75,
eHTMLTag_param=76, eHTMLTag_parsererror=77, eHTMLTag_plaintext=78,
eHTMLTag_pre=79, eHTMLTag_q=80, eHTMLTag_s=81, eHTMLTag_samp=82,
eHTMLTag_script=83, eHTMLTag_select=84, eHTMLTag_server=85,
eHTMLTag_small=86, eHTMLTag_sound=87, eHTMLTag_sourcetext=88,
eHTMLTag_spacer=89, eHTMLTag_span=90, eHTMLTag_strike=91,
eHTMLTag_strong=92, eHTMLTag_style=93, eHTMLTag_sub=94, eHTMLTag_sup=95,
eHTMLTag_table=96, eHTMLTag_tbody=97, eHTMLTag_td=98, eHTMLTag_textarea=99,
eHTMLTag_tfoot=100, eHTMLTag_th=101, eHTMLTag_thead=102,
eHTMLTag_title=103, eHTMLTag_tr=104, eHTMLTag_tt=105, eHTMLTag_u=106,
eHTMLTag_ul=107, eHTMLTag_var=108, eHTMLTag_wbr=109, eHTMLTag_xmp=110,
eHTMLTag_em=31, eHTMLTag_embed=32, eHTMLTag_endnote=33,
eHTMLTag_fieldset=34, eHTMLTag_font=35, eHTMLTag_form=36,
eHTMLTag_frame=37, eHTMLTag_frameset=38, eHTMLTag_h1=39, eHTMLTag_h2=40,
eHTMLTag_h3=41, eHTMLTag_h4=42, eHTMLTag_h5=43, eHTMLTag_h6=44,
eHTMLTag_head=45, eHTMLTag_hr=46, eHTMLTag_html=47, eHTMLTag_i=48,
eHTMLTag_iframe=49, eHTMLTag_ilayer=50, eHTMLTag_image=51, eHTMLTag_img=52,
eHTMLTag_input=53, eHTMLTag_ins=54, eHTMLTag_isindex=55, eHTMLTag_kbd=56,
eHTMLTag_keygen=57, eHTMLTag_label=58, eHTMLTag_layer=59,
eHTMLTag_legend=60, eHTMLTag_li=61, eHTMLTag_link=62, eHTMLTag_listing=63,
eHTMLTag_map=64, eHTMLTag_menu=65, eHTMLTag_meta=66, eHTMLTag_multicol=67,
eHTMLTag_nobr=68, eHTMLTag_noembed=69, eHTMLTag_noframes=70,
eHTMLTag_nolayer=71, eHTMLTag_noscript=72, eHTMLTag_object=73,
eHTMLTag_ol=74, eHTMLTag_optgroup=75, eHTMLTag_option=76, eHTMLTag_p=77,
eHTMLTag_param=78, eHTMLTag_parsererror=79, eHTMLTag_plaintext=80,
eHTMLTag_pre=81, eHTMLTag_q=82, eHTMLTag_s=83, eHTMLTag_samp=84,
eHTMLTag_script=85, eHTMLTag_select=86, eHTMLTag_server=87,
eHTMLTag_small=88, eHTMLTag_sound=89, eHTMLTag_sourcetext=90,
eHTMLTag_spacer=91, eHTMLTag_span=92, eHTMLTag_strike=93,
eHTMLTag_strong=94, eHTMLTag_style=95, eHTMLTag_sub=96, eHTMLTag_sup=97,
eHTMLTag_table=98, eHTMLTag_tbody=99, eHTMLTag_td=100,
eHTMLTag_textarea=101, eHTMLTag_tfoot=102, eHTMLTag_th=103,
eHTMLTag_thead=104, eHTMLTag_title=105, eHTMLTag_tr=106, eHTMLTag_tt=107,
eHTMLTag_u=108, eHTMLTag_ul=109, eHTMLTag_var=110, eHTMLTag_wbr=111,
eHTMLTag_xmp=112,
/* The remaining enums are not for tags */
eHTMLTag_text=111, eHTMLTag_whitespace=112, eHTMLTag_newline=113,
eHTMLTag_comment=114, eHTMLTag_entity=115, eHTMLTag_userdefined=116,
eHTMLTag_secret_h1style=117, eHTMLTag_secret_h2style=118,
eHTMLTag_secret_h3style=119, eHTMLTag_secret_h4style=120,
eHTMLTag_secret_h5style=121, eHTMLTag_secret_h6style=122
eHTMLTag_text=113, eHTMLTag_whitespace=114, eHTMLTag_newline=115,
eHTMLTag_comment=116, eHTMLTag_entity=117, eHTMLTag_userdefined=118,
eHTMLTag_secret_h1style=119, eHTMLTag_secret_h2style=120,
eHTMLTag_secret_h3style=121, eHTMLTag_secret_h4style=122,
eHTMLTag_secret_h5style=123, eHTMLTag_secret_h6style=124
};
#define NS_HTML_TAG_MAX 110
#define NS_HTML_TAG_MAX 112
extern NS_HTMLPARS nsHTMLTag NS_TagToEnum(const char* aTag);
extern NS_HTMLPARS const char* NS_EnumToTag(nsHTMLTag aEnum);

View File

@ -26,7 +26,6 @@
#include "nsHTMLTokenizer.h"
#include "nsParser.h"
#include "nsScanner.h"
#include "nsDTDUtils.h"
#include "nsElementTable.h"
#include "nsHTMLEntities.h"
@ -37,7 +36,6 @@
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kITokenizerIID, NS_ITOKENIZER_IID);
static NS_DEFINE_IID(kClassIID, NS_HTMLTOKENIZER_IID);
static CTokenRecycler* gTokenRecycler=0;
/**
* This method gets called as part of our COM-like interfaces.
@ -103,7 +101,7 @@ NS_IMPL_RELEASE(nsHTMLTokenizer)
* @param
* @return
*/
nsHTMLTokenizer::nsHTMLTokenizer() : nsITokenizer(), mTokenDeque(new CTokenDeallocator()) {
nsHTMLTokenizer::nsHTMLTokenizer() : nsITokenizer(), mTokenDeque(new CTokenDeallocator()){
NS_INIT_REFCNT();
mDoXMLEmptyTags=PR_FALSE;
}
@ -123,13 +121,16 @@ nsHTMLTokenizer::~nsHTMLTokenizer(){
Here begins the real working methods for the tokenizer.
*******************************************************************/
void nsHTMLTokenizer::AddToken(CToken*& aToken,nsresult aResult,nsDeque& aDeque) {
void nsHTMLTokenizer::AddToken(CToken*& aToken,nsresult aResult,nsDeque& aDeque,CTokenRecycler* aRecycler) {
if(aToken) {
if(NS_SUCCEEDED(aResult)) {
aDeque.Push(aToken);
}
else {
delete aToken;
if(aRecycler) {
aRecycler->RecycleToken(aToken);
}
else delete aToken;
aToken=0;
}
}
@ -141,10 +142,8 @@ void nsHTMLTokenizer::AddToken(CToken*& aToken,nsresult aResult,nsDeque& aDeque)
* @return ptr to recycler (or null)
*/
nsITokenRecycler* nsHTMLTokenizer::GetTokenRecycler(void) {
if (! gTokenRecycler) {
gTokenRecycler=new CTokenRecycler();
}
return gTokenRecycler;
static CTokenRecycler gTokenRecycler;
return (nsITokenRecycler*)&gTokenRecycler;
}
@ -202,10 +201,38 @@ PRInt32 nsHTMLTokenizer::GetCount(void) {
return mTokenDeque.GetSize();
}
/**
*
* @update gess12/29/98
* @param
* @return
*/
CToken* nsHTMLTokenizer::GetTokenAt(PRInt32 anIndex){
return (CToken*)mTokenDeque.ObjectAt(anIndex);
}
/**
*
* @update gess12/29/98
* @param
* @return
*/
void nsHTMLTokenizer::PrependTokens(nsDeque& aDeque){
PRInt32 aCount=aDeque.GetSize();
//last but not least, let's check the misplaced content list.
//if we find it, then we have to push it all into the body before continuing...
PRInt32 anIndex=0;
for(anIndex=0;anIndex<aCount;anIndex++){
CToken* theToken=(CToken*)aDeque.Pop();
PushTokenFront(theToken);
}
}
/**
* This method repeatedly called by the tokenizer.
* Each time, we determine the kind of token were about to
@ -353,13 +380,14 @@ nsresult nsHTMLTokenizer::ConsumeAttributes(PRUnichar aChar,CStartToken* aToken,
}
else {
theAttrCount++;
AddToken(theToken,result,mTokenDeque);
AddToken(theToken,result,mTokenDeque,theRecycler);
}
}
else { //if(NS_ERROR_HTMLPARSER_BADATTRIBUTE==result){
aToken->SetEmpty(PR_TRUE);
theRecycler->RecycleToken(theToken);
result=NS_OK;
if(NS_ERROR_HTMLPARSER_BADATTRIBUTE==result)
result=NS_OK;
}
}//if
@ -422,13 +450,13 @@ nsresult nsHTMLTokenizer::HandleSkippedContent(nsScanner& aScanner,CToken*& aTok
PRUnichar theChar=0;
result=ConsumeContentToEndTag(theChar,gHTMLElements[theTag].mSkipTarget,aScanner,skippedToken);
if((NS_OK==result) && skippedToken){
AddToken(skippedToken,result,mTokenDeque);
CTokenRecycler* theRecycler=(CTokenRecycler*)GetTokenRecycler();
AddToken(skippedToken,result,mTokenDeque,theRecycler);
if(NS_SUCCEEDED(result) && skippedToken){
//In the case that we just read a given tag, we should go and
//consume all the tag content itself (and throw it all away).
CTokenRecycler* theRecycler=(CTokenRecycler*)GetTokenRecycler();
nsString& theTagStr=skippedToken->GetStringValueXXX();
CToken* endtoken=theRecycler->CreateTokenOfType(eToken_end,theTag,theTagStr);
if(endtoken){
@ -436,7 +464,7 @@ nsresult nsHTMLTokenizer::HandleSkippedContent(nsScanner& aScanner,CToken*& aTok
theTagStr.Mid(temp,2,theTagStr.Length()-3);
//now strip the leading and trailing delimiters...
endtoken->Reinitialize(theTag,temp);
AddToken(endtoken,result,mTokenDeque);
AddToken(endtoken,result,mTokenDeque,theRecycler);
}
} //if
} //if
@ -460,7 +488,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan
result= aToken->Consume(aChar,aScanner); //tell new token to finish consuming text...
if(NS_SUCCEEDED(result)) {
AddToken(aToken,result,mTokenDeque);
AddToken(aToken,result,mTokenDeque,theRecycler);
eHTMLTags theTag=(eHTMLTags)aToken->GetTypeID();
if(((CStartToken*)aToken)->IsAttributed()) {
@ -505,7 +533,7 @@ nsresult nsHTMLTokenizer::ConsumeEndTag(PRUnichar aChar,CToken*& aToken,nsScanne
if(aToken) {
result= aToken->Consume(aChar,aScanner); //tell new token to finish consuming text...
AddToken(aToken,result,mTokenDeque);
AddToken(aToken,result,mTokenDeque,theRecycler);
} //if
return result;
}
@ -553,7 +581,7 @@ nsresult nsHTMLTokenizer::ConsumeEntity(PRUnichar aChar,CToken*& aToken,nsScanne
theRecycler->RecycleToken(aToken);
aToken=theToken;
}
AddToken(aToken,result,mTokenDeque);
AddToken(aToken,result,mTokenDeque,theRecycler);
}
}//if
return result;
@ -576,7 +604,7 @@ nsresult nsHTMLTokenizer::ConsumeWhitespace(PRUnichar aChar,CToken*& aToken,nsSc
nsresult result=NS_OK;
if(aToken) {
result=aToken->Consume(aChar,aScanner);
AddToken(aToken,result,mTokenDeque);
AddToken(aToken,result,mTokenDeque,theRecycler);
}
return result;
}
@ -597,7 +625,7 @@ nsresult nsHTMLTokenizer::ConsumeComment(PRUnichar aChar,CToken*& aToken,nsScann
nsresult result=NS_OK;
if(aToken) {
result=aToken->Consume(aChar,aScanner);
AddToken(aToken,result,mTokenDeque);
AddToken(aToken,result,mTokenDeque,theRecycler);
}
return result;
}
@ -619,15 +647,15 @@ nsresult nsHTMLTokenizer::ConsumeText(const nsString& aString,CToken*& aToken,ns
if(aToken) {
PRUnichar ch=0;
result=aToken->Consume(ch,aScanner);
if(result) {
if(!NS_SUCCEEDED(result)) {
nsString& temp=aToken->GetStringValueXXX();
if(0==temp.Length()){
delete aToken;
theRecycler->RecycleToken(aToken);
aToken = nsnull;
}
else result=NS_OK;
}
AddToken(aToken,result,mTokenDeque);
AddToken(aToken,result,mTokenDeque,theRecycler);
}
return result;
}
@ -647,7 +675,7 @@ nsresult nsHTMLTokenizer::ConsumeNewline(PRUnichar aChar,CToken*& aToken,nsScann
nsresult result=NS_OK;
if(aToken) {
result=aToken->Consume(aChar,aScanner);
AddToken(aToken,result,mTokenDeque);
AddToken(aToken,result,mTokenDeque,theRecycler);
}
return result;
}
@ -668,7 +696,7 @@ nsresult nsHTMLTokenizer::ConsumeProcessingInstruction(PRUnichar aChar,CToken*&
nsresult result=NS_OK;
if(aToken) {
result=aToken->Consume(aChar,aScanner);
AddToken(aToken,result,mTokenDeque);
AddToken(aToken,result,mTokenDeque,theRecycler);
}
return result;
}

View File

@ -33,6 +33,7 @@
#include "nsDeque.h"
#include "nsScanner.h"
#include "nsHTMLTokens.h"
#include "nsDTDUtils.h"
#define NS_HTMLTOKENIZER_IID \
{0xe4238ddd, 0x9eb6, 0x11d2, \
@ -64,6 +65,8 @@ public:
virtual CToken* GetTokenAt(PRInt32 anIndex);
virtual PRInt32 GetCount(void);
virtual void PrependTokens(nsDeque& aDeque);
protected:
virtual nsresult HandleSkippedContent(nsScanner& aScanner,CToken*& aToken);
@ -79,8 +82,7 @@ protected:
virtual nsresult ConsumeContentToEndTag(PRUnichar aChar,eHTMLTags aChildTag,nsScanner& aScanner,CToken*& aToken);
virtual nsresult ConsumeProcessingInstruction(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner);
protected:
static void AddToken(CToken*& aToken,nsresult aResult,nsDeque& aDeque);
static void AddToken(CToken*& aToken,nsresult aResult,nsDeque& aDeque,CTokenRecycler* aRecycler);
nsDeque mTokenDeque;
PRBool mDoXMLEmptyTags;

View File

@ -232,6 +232,10 @@ nsresult CStartToken::Consume(PRUnichar aChar, nsScanner& aScanner) {
mTextValue.ToCString(buffer,sizeof(buffer)-1);
mTypeID = NS_TagToEnum(buffer);
if(eHTMLTag_image==mTypeID){
mTypeID=eHTMLTag_img;
}
//Good. Now, let's skip whitespace after the identifier,
//and see if the next char is ">". If so, we have a complete
//tag without attributes.
@ -1564,7 +1568,7 @@ nsresult CSkippedContentToken::Consume(PRUnichar aChar,nsScanner& aScanner) {
static CCommentToken theComment;
result=theComment.Consume(aChar,aScanner);
if(NS_OK==result) {
result=aScanner.SkipWhitespace();
//result=aScanner.SkipWhitespace();
temp.Append(theComment.GetStringValueXXX());
}
} else {

View File

@ -189,9 +189,6 @@ class CEntityToken : public CHTMLToken {
// static PRBool VerifyEntityTable(void);
// static PRInt32 ReduceEntities(nsString& aString);
virtual void DebugDumpSource(ostream& out);
private:
static PRInt32 mEntityTokenCount;
};

View File

@ -135,6 +135,8 @@ class nsIDTD : public nsISupports {
virtual nsITokenRecycler* GetTokenRecycler(void)=0;
virtual void EmitMisplacedContent(nsITokenizer* aTokenizer)=0;
/**
* This method causes all tokens to be dispatched to the given tag handler.
*

View File

@ -48,7 +48,9 @@ public:
virtual void SetNotationDeclHandler(XML_NotationDeclHandler handler)=0;
virtual void SetExternalEntityRefHandler(XML_ExternalEntityRefHandler handler)=0;
virtual void SetUnknownEncodingHandler(XML_UnknownEncodingHandler handler, void *encodingHandlerData)=0;
virtual void FrontloadMisplacedContent(nsDeque& aDeque)=0;
};

View File

@ -126,6 +126,8 @@ class nsIParser : public nsISupports {
virtual nsresult Parse(fstream& aStream,PRBool aEnableVerify=PR_FALSE) = 0;
virtual nsresult Parse(nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify,PRBool aLastCall) = 0;
//virtual PRBool IsValid(nsString& aSourceBuffer,const nsString& aContentTypeaLastCall) = 0;
/**
* This method gets called when the tokens have been consumed, and it's time
* to build the model via the content sink.
@ -164,6 +166,8 @@ class nsIParser : public nsISupports {
#define NS_ERROR_HTMLPARSER_BADTOKENIZER NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1008)
#define NS_ERROR_HTMLPARSER_BADATTRIBUTE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1009)
#define NS_ERROR_HTMLPARSER_UNRESOLVEDDTD NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1010)
#define NS_ERROR_HTMLPARSER_MISPLACED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1011)
/**
* Return codes for parsing routines.

View File

@ -42,7 +42,7 @@
#include "nsString.h"
#include "nsDebug.h"
class CToken;
// class CToken;
// 6e59f160-2717-11d2-9246-00805f8a7ab6
#define NS_IPARSER_NODE_IID \
@ -110,7 +110,7 @@ class nsIParserNode : public nsISupports {
* @param anIndex is the index of the key you want
* @return string containing key.
*/
virtual const nsString& GetKeyAt(PRInt32 anIndex) const =0;
virtual const nsString& GetKeyAt(PRUint32 anIndex) const =0;
/**
* Retrieve the value (of key/value pair) at given index
@ -118,7 +118,7 @@ class nsIParserNode : public nsISupports {
* @param anIndex is the index of the value you want
* @return string containing value.
*/
virtual const nsString& GetValueAt(PRInt32 anIndex) const =0;
virtual const nsString& GetValueAt(PRUint32 anIndex) const =0;
/**
* NOTE: When the node is an entity, this will translate the entity

View File

@ -32,6 +32,7 @@
class CToken;
class nsScanner;
class nsDeque;
#define NS_ITOKENIZER_IID \
{0xe4238ddc, 0x9eb6, 0x11d2, {0xba, 0xa5, 0x0, 0x10, 0x4b, 0x98, 0x3f, 0xd4 }}
@ -65,13 +66,14 @@ public:
virtual nsresult ConsumeToken(nsScanner& aScanner)=0;
virtual nsITokenRecycler* GetTokenRecycler(void)=0;
virtual CToken* PushTokenFront(CToken* theToken)=0;
virtual CToken* PushToken(CToken* theToken)=0;
virtual CToken* PushTokenFront(CToken* aToken)=0;
virtual CToken* PushToken(CToken* aToken)=0;
virtual CToken* PopToken(void)=0;
virtual CToken* PeekToken(void)=0;
virtual PRInt32 GetCount(void)=0;
virtual CToken* GetTokenAt(PRInt32 anIndex)=0;
virtual void PrependTokens(nsDeque& aDeque)=0;
};

View File

@ -91,7 +91,7 @@ public:
nsIDTD* theDTD;
NS_NewWellFormed_DTD(&theDTD);
RegisterDTD(theDTD);
mDTDDeque.Push(theDTD);
NS_NewNavHTMLDTD(&theDTD); //do this as the default HTML DTD...
mDTDDeque.Push(theDTD);
@ -123,13 +123,18 @@ public:
nsDeque mDTDDeque;
};
static CSharedParserObjects* gSharedParserObjects=0;
//static CSharedParserObjects* gSharedParserObjects=0;
nsString nsParser::gHackMetaCharset = "";
nsString nsParser::gHackMetaCharsetURL = "";
//----------------------------------------
CSharedParserObjects& GetSharedObjects() {
static CSharedParserObjects gSharedParserObjects;
return gSharedParserObjects;
}
/**
* default constructor
*
@ -146,9 +151,6 @@ nsParser::nsParser(nsITokenObserver* anObserver) : mCommand(""), mUnusedInput(""
mTokenObserver=anObserver;
mStreamStatus=0;
mDTDVerification=PR_FALSE;
if(!gSharedParserObjects) {
gSharedParserObjects = new CSharedParserObjects();
}
}
@ -283,7 +285,8 @@ nsIContentSink* nsParser::GetContentSink(void){
* @return nothing.
*/
void nsParser::RegisterDTD(nsIDTD* aDTD){
gSharedParserObjects->RegisterDTD(aDTD);
CSharedParserObjects& theShare=GetSharedObjects();
theShare.RegisterDTD(aDTD);
}
/**
@ -328,8 +331,9 @@ PRBool FindSuitableDTD( CParserContext& aParserContext,nsString& aCommand,nsStri
if(aParserContext.mDTD->CanParse(aParserContext.mSourceType,aCommand,aBuffer,0))
return PR_TRUE;
nsDequeIterator b=gSharedParserObjects->mDTDDeque.Begin();
nsDequeIterator e=gSharedParserObjects->mDTDDeque.End();
CSharedParserObjects& gSharedObjects=GetSharedObjects();
nsDequeIterator b=gSharedObjects.mDTDDeque.Begin();
nsDequeIterator e=gSharedObjects.mDTDDeque.End();
aParserContext.mAutoDetectStatus=eUnknownDetect;
nsIDTD* theBestDTD=0;
@ -732,6 +736,27 @@ nsresult nsParser::Parse(nsString& aSourceBuffer,void* aKey,const nsString& aCon
return result;
}
/**
*
* @update gess 04/01/99
* @param
* @return
*/
PRBool nsParser::IsValidFragment(nsString& aSourceBuffer,nsTagStack& aStack,nsHTMLTag aTag,const nsString& aContentType){
PRBool result=PR_FALSE;
return result;
}
/**
*
* @update gess 04/01/99
* @param
* @return
*/
PRBool nsParser::ParseFragment(nsString& aSourceBuffer,void* aKey,nsTagStack& aStack,nsHTMLTag aTag,const nsString& aContentType){
PRBool result=PR_FALSE;
return result;
}
/**
* This routine is called to cause the parser to continue
@ -753,6 +778,10 @@ nsresult nsParser::ResumeParse(nsIDTD* aDefaultDTD) {
if(NS_OK==result) {
result=Tokenize();
if(eOnStop==mParserContext->mStreamListenerState){
nsITokenizer* theTokenizer=mParserContext->mDTD->GetTokenizer();
mParserContext->mDTD->EmitMisplacedContent(theTokenizer);
}
result=BuildModel();
if((!mParserContext->mMultipart) || ((eOnStop==mParserContext->mStreamListenerState) && (NS_OK==result))){
@ -973,7 +1002,7 @@ nsresult nsParser::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRUin
* This is called by the networking library once the last block of data
* has been collected from the net.
*
* @update vidur 12/11/98
* @update gess 04/01/99
* @param
* @return
*/
@ -1044,6 +1073,10 @@ nsresult nsParser::Tokenize(){
result=theTokenizer->ConsumeToken(*mParserContext->mScanner);
if(!NS_SUCCEEDED(result)) {
mParserContext->mScanner->RewindToMark();
if(kEOF==result){
result=NS_OK;
break;
}
}
}
DidTokenize();
@ -1053,7 +1086,7 @@ nsresult nsParser::Tokenize(){
/**
* This is the tail-end of the code sandwich for the
* tokenization process. It gets called once tokenziation
* has completed.
* has completed for each phase.
*
* @update gess 01/04/99
* @param

View File

@ -62,12 +62,15 @@
#include "CParserContext.h"
#include "nsParserCIID.h"
#include "nsITokenizer.h"
#include "nsHTMLTags.h"
class IContentSink;
class nsIHTMLContentSink;
class nsIDTD;
class nsScanner;
class nsIParserFilter;
class nsTagStack;
#include <fstream.h>
#ifndef XP_MAC
@ -168,6 +171,9 @@ friend class CTokenHandler;
*/
virtual nsresult Parse(nsString& aSourceBuffer,void* aKey,const nsString& aContentType,PRBool aEnableVerify=PR_FALSE,PRBool aLastCall=PR_FALSE);
virtual PRBool IsValidFragment(nsString& aSourceBuffer,nsTagStack& aStack,nsHTMLTag aTag,const nsString& aContentType);
virtual PRBool ParseFragment(nsString& aSourceBuffer,void* aKey,nsTagStack& aStack,nsHTMLTag aTag,const nsString& aContentType);
/**
* Call this when you want control whether or not the parser will parse

View File

@ -23,12 +23,16 @@
#include "nshtmlpars.h"
#include "nsITokenizer.h"
const nsString* nsCParserNode::mEmptyString=0;
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kClassIID, NS_PARSER_NODE_IID);
static NS_DEFINE_IID(kIParserNodeIID, NS_IPARSER_NODE_IID);
nsAutoString& GetEmptyString() {
static nsAutoString theEmptyString("");
return theEmptyString;
}
/**
* Default constructor
*
@ -38,9 +42,6 @@ static NS_DEFINE_IID(kIParserNodeIID, NS_IPARSER_NODE_IID);
*/
nsCParserNode::nsCParserNode(CToken* aToken,PRInt32 aLineNumber,nsITokenRecycler* aRecycler): nsIParserNode() {
NS_INIT_REFCNT();
if(!mEmptyString) {
mEmptyString=new nsString(""); //this is going to leak, but it's a singleton
}
mAttributeCount=0;
mLineNumber=aLineNumber;
mToken=aToken;
@ -60,7 +61,7 @@ nsCParserNode::nsCParserNode(CToken* aToken,PRInt32 aLineNumber,nsITokenRecycler
*/
nsCParserNode::~nsCParserNode() {
if(mRecycler) {
int index=0;
PRUint32 index=0;
for(index=0;index<mAttributeCount;index++){
mRecycler->RecycleToken(mAttributes[index]);
}
@ -140,7 +141,6 @@ void nsCParserNode::AddAttribute(CToken* aToken) {
}
}
/**
* This method gets called when the parser encounters
* skipped content after a start token.
@ -165,7 +165,7 @@ void nsCParserNode::SetSkippedContent(CToken* aToken){
* @return string ref containing node name
*/
const nsString& nsCParserNode::GetName() const {
return *mEmptyString;
return GetEmptyString();
// return mName;
}
@ -194,7 +194,7 @@ const nsString& nsCParserNode::GetSkippedContent() const {
if (nsnull != mSkippedContent) {
return ((CSkippedContentToken*)mSkippedContent)->GetKey();
}
return *mEmptyString;
return GetEmptyString();
}
/**
@ -244,12 +244,12 @@ PRInt32 nsCParserNode::GetAttributeCount(PRBool askToken) const{
* @param anIndex-- offset of attribute to retrieve
* @return string rep of given attribute text key
*/
const nsString& nsCParserNode::GetKeyAt(PRInt32 anIndex) const {
const nsString& nsCParserNode::GetKeyAt(PRUint32 anIndex) const {
if(anIndex<mAttributeCount) {
CAttributeToken* tkn=(CAttributeToken*)(mAttributes[anIndex]);
return tkn->GetKey();
}
return *mEmptyString;
return GetEmptyString();
}
@ -260,12 +260,12 @@ const nsString& nsCParserNode::GetKeyAt(PRInt32 anIndex) const {
* @param anIndex-- offset of attribute to retrieve
* @return string rep of given attribute text value
*/
const nsString& nsCParserNode::GetValueAt(PRInt32 anIndex) const {
const nsString& nsCParserNode::GetValueAt(PRUint32 anIndex) const {
NS_PRECONDITION(anIndex<mAttributeCount, "Bad attr index");
if(anIndex<mAttributeCount){
return (mAttributes[anIndex])->GetStringValueXXX();
}
return *mEmptyString;
return GetEmptyString();
}

View File

@ -121,7 +121,7 @@ class nsCParserNode : public nsIParserNode {
* @param anIndex is the index of the key you want
* @return string containing key.
*/
virtual const nsString& GetKeyAt(PRInt32 anIndex) const;
virtual const nsString& GetKeyAt(PRUint32 anIndex) const;
/**
* Retrieve the value (of key/value pair) at given index
@ -129,7 +129,7 @@ class nsCParserNode : public nsIParserNode {
* @param anIndex is the index of the value you want
* @return string containing value.
*/
virtual const nsString& GetValueAt(PRInt32 anIndex) const;
virtual const nsString& GetValueAt(PRUint32 anIndex) const;
/**
* NOTE: When the node is an entity, this will translate the entity
@ -165,17 +165,13 @@ class nsCParserNode : public nsIParserNode {
virtual PRInt32 GetSourceLineNumber(void) const;
protected:
PRInt32 mAttributeCount;
PRUint32 mAttributeCount;
PRInt32 mLineNumber;
CToken* mToken;
CToken* mAttributes[eMaxAttr]; // XXX Ack! This needs to be dynamic!
CToken* mSkippedContent;
nsITokenRecycler* mRecycler;
// nsAutoString mName;
static const nsString* mEmptyString;
};
#endif

View File

@ -620,7 +620,7 @@ nsString& nsScanner::GetBuffer(void) {
void nsScanner::CopyUnusedData(nsString& aCopyBuffer) {
PRInt32 theLen=mBuffer.Length();
if(0<theLen) {
mBuffer.Right(aCopyBuffer,theLen-mOffset);
mBuffer.Right(aCopyBuffer,theLen-mMarkPos);
}
}

View File

@ -281,6 +281,16 @@ PRBool CValidDTD::Verify(nsString& aURLRef,nsIParser* aParser) {
void CValidDTD::SetVerification(PRBool aEnabled){
}
/**
*
*
* @update gess 4/01/99
* @param aTokenizer
* @return
*/
void CValidDTD::EmitMisplacedContent(nsITokenizer* aTokenizer){
}
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.

View File

@ -202,6 +202,8 @@ class CValidDTD : public nsIDTD {
*/
virtual void SetVerification(PRBool aEnable);
virtual void EmitMisplacedContent(nsITokenizer* aTokenizer);
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.

View File

@ -423,6 +423,16 @@ PRBool CViewSourceHTML::Verify(nsString& aURLRef,nsIParser* aParser) {
void CViewSourceHTML::SetVerification(PRBool aEnabled){
}
/**
*
*
* @update gess 4/01/99
* @param aTokenizer
* @return
*/
void CViewSourceHTML::EmitMisplacedContent(nsITokenizer* aTokenizer){
}
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.

View File

@ -200,6 +200,8 @@ class CViewSourceHTML: public nsIDTD {
*/
virtual void SetVerification(PRBool aEnable);
virtual void EmitMisplacedContent(nsITokenizer* aTokenizer);
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.

View File

@ -253,10 +253,11 @@ NS_IMETHODIMP CWellFormedDTD::BuildModel(nsIParser* aParser,nsITokenizer* aToken
CToken* theToken=mTokenizer->PopToken();
if(theToken) {
result=HandleToken(theToken,aParser);
if(NS_SUCCEEDED(result)) {
if(NS_SUCCEEDED(result) || (NS_ERROR_HTMLPARSER_BLOCK==result)) {
theRecycler->RecycleToken(theToken);
}
else if(NS_ERROR_HTMLPARSER_BLOCK!=result){
else {
// if(NS_ERROR_HTMLPARSER_BLOCK!=result){
mTokenizer->PushTokenFront(theToken);
}
// theRootDTD->Verify(kEmptyString,aParser);
@ -409,6 +410,16 @@ PRBool CWellFormedDTD::Verify(nsString& aURLRef,nsIParser* aParser) {
void CWellFormedDTD::SetVerification(PRBool aEnabled){
}
/**
*
*
* @update gess 4/01/99
* @param aTokenizer
* @return
*/
void CWellFormedDTD::EmitMisplacedContent(nsITokenizer* aTokenizer){
}
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.
@ -450,7 +461,7 @@ NS_IMETHODIMP CWellFormedDTD::HandleToken(CToken* aToken,nsIParser* aParser) {
mParser=(nsParser*)aParser;
mSink=aParser->GetContentSink();
nsCParserNode theNode(theToken,mLineNumber);
nsCParserNode theNode(theToken,mLineNumber,mTokenizer->GetTokenRecycler());
switch(theType) {
case eToken_newline:

View File

@ -188,6 +188,8 @@ class CWellFormedDTD : public nsIDTD {
*/
virtual void SetVerification(PRBool aEnable);
virtual void EmitMisplacedContent(nsITokenizer* aTokenizer);
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.

View File

@ -881,6 +881,16 @@ PRBool nsXIFDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
return result;
}
/**
*
*
* @update gess 4/01/99
* @param aTokenizer
* @return
*/
void nsXIFDTD::EmitMisplacedContent(nsITokenizer* aTokenizer){
}
/**
* This method gets called to determine whether a given
* tag can contain newlines. Most do not.

View File

@ -225,6 +225,8 @@ class nsXIFDTD : public nsIDTD {
*/
virtual void SetURLRef(char * aURLRef);
virtual void EmitMisplacedContent(nsITokenizer* aTokenizer);
/**
*
* @update jevering 6/18/98

View File

@ -198,21 +198,22 @@ nsresult nsXMLTokenizer::ConsumeComment(PRUnichar aChar,CToken*& aToken,nsScanne
result = ConsumeConditional(aScanner, CDATAString, isCDATA);
CTokenRecycler* theRecycler=(CTokenRecycler*)GetTokenRecycler();
if (NS_OK == result) {
nsAutoString theEmpty;
if (isCDATA) {
aToken=theRecycler->CreateTokenOfType(eToken_cdatasection,eHTMLTag_unknown,theEmpty);
if(theRecycler) {
if (NS_OK == result) {
nsAutoString theEmpty;
if (isCDATA) {
aToken=theRecycler->CreateTokenOfType(eToken_cdatasection,eHTMLTag_unknown,theEmpty);
}
else {
aToken=theRecycler->CreateTokenOfType(eToken_comment,eHTMLTag_comment,theEmpty);
}
}
else {
aToken=theRecycler->CreateTokenOfType(eToken_comment,eHTMLTag_comment,theEmpty);
}
}
if(aToken) {
result=aToken->Consume(aChar,aScanner);
AddToken(aToken,result,mTokenDeque);
if(aToken) {
result=aToken->Consume(aChar,aScanner);
AddToken(aToken,result,mTokenDeque,theRecycler);
}
}
return result;