minor fixes to parser; fixed DoCopy
git-svn-id: svn://10.0.0.236/trunk@24668 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
017dac3409
commit
b91799a999
@ -61,11 +61,6 @@ static eHTMLTags gFormElementTags[]= {
|
||||
eHTMLTag_option, eHTMLTag_optgroup, eHTMLTag_select,
|
||||
eHTMLTag_textarea};
|
||||
|
||||
static eHTMLTags gHeadingTags[]={
|
||||
eHTMLTag_h1, eHTMLTag_h2, eHTMLTag_h3,
|
||||
eHTMLTag_h4, eHTMLTag_h5, eHTMLTag_h6};
|
||||
|
||||
|
||||
static eHTMLTags gTableChildTags[]={
|
||||
eHTMLTag_caption, eHTMLTag_col, eHTMLTag_colgroup,
|
||||
eHTMLTag_tbody, eHTMLTag_tfoot, eHTMLTag_tr,
|
||||
@ -782,6 +777,27 @@ eHTMLTags FindAutoCloseTargetForStartTag(eHTMLTags aCurrentTag,nsTagStack& aTagS
|
||||
return eHTMLTag_unknown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this to find the index of a given child, or (if not found)
|
||||
* the index of its nearest synonym.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aTagStack -- list of open tags
|
||||
* @param aTag -- tag to test for containership
|
||||
* @return index of kNotFound
|
||||
*/
|
||||
static
|
||||
PRInt32 GetIndexOfChildOrSynonym(nsTagStack& aTagStack,eHTMLTags aChildTag) {
|
||||
PRInt32 theChildIndex=aTagStack.GetTopmostIndexOf(aChildTag);
|
||||
if(kNotFound==theChildIndex) {
|
||||
CTagList* theSynTags=gHTMLElements[aChildTag].GetSynonymousTags(); //get the list of tags that THIS tag can close
|
||||
if(theSynTags) {
|
||||
theChildIndex=theSynTags->GetTopmostIndexOf(aTagStack);
|
||||
}
|
||||
}
|
||||
return theChildIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not the child
|
||||
* tag is happy being OPENED in the context of the current
|
||||
@ -799,13 +815,7 @@ PRBool CanBeContained(eHTMLTags aChildTag,nsTagStack& aTagStack) {
|
||||
CTagList* theRootTags=gHTMLElements[aChildTag].GetRootTags();
|
||||
if(theRootTags) {
|
||||
PRInt32 theRootIndex=theRootTags->GetTopmostIndexOf(aTagStack);
|
||||
PRInt32 theChildIndex=aTagStack.GetTopmostIndexOf(aChildTag);
|
||||
if(kNotFound==theChildIndex) {
|
||||
CTagList* theSynTags=gHTMLElements[aChildTag].GetSynonymousTags(); //get the list of tags that THIS tag can close
|
||||
if(theSynTags) {
|
||||
theChildIndex=theSynTags->GetTopmostIndexOf(aTagStack);
|
||||
}
|
||||
}
|
||||
PRInt32 theChildIndex=GetIndexOfChildOrSynonym(aTagStack,aChildTag);
|
||||
if(theRootIndex<theChildIndex){
|
||||
eHTMLTags thePrevTag=aTagStack.Last();
|
||||
result=gHTMLElements[thePrevTag].CanContainType(gHTMLElements[aChildTag].mParentBits);
|
||||
@ -816,6 +826,7 @@ PRBool CanBeContained(eHTMLTags aChildTag,nsTagStack& aTagStack) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method gets called when a start token has been
|
||||
* encountered in the parse process. If the current container
|
||||
@ -915,7 +926,7 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI
|
||||
|
||||
}//if(!rickGSkip)...
|
||||
|
||||
if(IsContainer(aChildTag)){
|
||||
if(nsHTMLElement::IsContainer(aChildTag)){
|
||||
//first, let's see if it's a style element...
|
||||
if(!nsHTMLElement::IsStyleTag(aChildTag)) {
|
||||
//it wasn't a style container, so open the element container...
|
||||
@ -1104,27 +1115,6 @@ PRBool HasCloseablePeerAboveRoot(CTagList& aRootTagList,nsTagStack& aTagStack,eH
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call this to find the index of a given child, or (if not found)
|
||||
* the index of its nearest synonym.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aTagStack -- list of open tags
|
||||
* @param aTag -- tag to test for containership
|
||||
* @return index of kNotFound
|
||||
*/
|
||||
static
|
||||
PRInt32 GetIndexOfChildOrSynonym(nsTagStack& aTagStack,eHTMLTags aChildTag) {
|
||||
PRInt32 theChildIndex=aTagStack.GetTopmostIndexOf(aChildTag);
|
||||
if(kNotFound==theChildIndex) {
|
||||
CTagList* theSynTags=gHTMLElements[aChildTag].GetSynonymousTags(); //get the list of tags that THIS tag can close
|
||||
if(theSynTags) {
|
||||
theChildIndex=theSynTags->GetTopmostIndexOf(aTagStack);
|
||||
}
|
||||
}
|
||||
return theChildIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not an END tag
|
||||
* can be autoclosed. This means that based on the current
|
||||
@ -1522,7 +1512,7 @@ PRBool CNavDTD::CanPropagate(eHTMLTags aParentTag,eHTMLTags aChildTag) const {
|
||||
PRBool result=PR_FALSE;
|
||||
PRBool parentCanContain=CanContain(aParentTag,aChildTag);
|
||||
|
||||
if(IsContainer(aChildTag)){
|
||||
if(nsHTMLElement::IsContainer(aChildTag)){
|
||||
if(nsHTMLElement::IsBlockParent(aParentTag) || (gHTMLElements[aParentTag].GetSpecialChildren())) {
|
||||
while(eHTMLTag_unknown!=aChildTag) {
|
||||
if(parentCanContain){
|
||||
@ -1596,6 +1586,10 @@ PRBool CNavDTD::CanOmit(eHTMLTags aParent,eHTMLTags aChild) const {
|
||||
}
|
||||
break;
|
||||
|
||||
case eHTMLTag_frameset:
|
||||
result=!gFramesetKids.Contains(aChild);
|
||||
break;
|
||||
|
||||
case eHTMLTag_unknown:
|
||||
{
|
||||
static eHTMLTags canSkip2[]={eHTMLTag_newline,eHTMLTag_whitespace};
|
||||
@ -1709,29 +1703,6 @@ PRBool CNavDTD::CanOmit(eHTMLTags aParent,eHTMLTags aChild) const {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is called when you want to determine if one tag is
|
||||
* synonymous with another. Cases where this are true include style
|
||||
* tags (where <i> is allowed to close <b> for example). Another
|
||||
* is <H?>, where any open heading tag can be closed by any close heading tag.
|
||||
* @update gess6/16/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static
|
||||
PRBool IsCompatibleTag(eHTMLTags aTag1,eHTMLTags aTag2) {
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
if(nsHTMLElement::IsStyleTag(aTag1)) {
|
||||
result=nsHTMLElement::IsStyleTag(aTag2);
|
||||
}
|
||||
if(FindTagInSet(aTag1,gHeadingTags,sizeof(gHeadingTags)/sizeof(eHTMLTag_unknown))) {
|
||||
result=FindTagInSet(aTag2,gHeadingTags,sizeof(gHeadingTags)/sizeof(eHTMLTag_unknown));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -1749,13 +1720,7 @@ PRBool CNavDTD::CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild) const {
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRInt32 theChildIndex=GetTopmostIndexOf(aChild);
|
||||
if(kNotFound==theChildIndex) {
|
||||
CTagList* theSynTags=gHTMLElements[aChild].GetSynonymousTags(); //get the list of tags that THIS tag can close
|
||||
if(theSynTags) {
|
||||
theChildIndex=theSynTags->GetTopmostIndexOf(mBodyContext->mTags);
|
||||
}
|
||||
}
|
||||
PRInt32 theChildIndex=GetIndexOfChildOrSynonym(mBodyContext->mTags,aChild);
|
||||
result=PRBool(kNotFound==theChildIndex);
|
||||
|
||||
return result;
|
||||
@ -1770,8 +1735,7 @@ PRBool CNavDTD::CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild) const {
|
||||
* @return PR_TRUE if given tag can contain other tags
|
||||
*/
|
||||
PRBool CNavDTD::IsContainer(PRInt32 aTag) const {
|
||||
PRBool result=nsHTMLElement::IsContainer((eHTMLTags)aTag);
|
||||
return result;
|
||||
return nsHTMLElement::IsContainer((eHTMLTags)aTag);
|
||||
}
|
||||
|
||||
|
||||
@ -2457,9 +2421,15 @@ nsresult CNavDTD::CloseContainersTo(eHTMLTags aTag,PRBool aUpdateStyles){
|
||||
}
|
||||
|
||||
eHTMLTags theTopTag=mBodyContext->Last();
|
||||
if(IsCompatibleTag(aTag,theTopTag)) {
|
||||
//if you're here, it's because we're trying to close one style tag,
|
||||
//but a different one is actually open. Because this is NAV4x
|
||||
|
||||
PRBool theTagIsSynonymous=((nsHTMLElement::IsStyleTag(aTag)) && (nsHTMLElement::IsStyleTag(theTopTag)));
|
||||
if(!theTagIsSynonymous){
|
||||
theTagIsSynonymous=((nsHTMLElement::IsHeadingTag(aTag)) && (nsHTMLElement::IsHeadingTag(theTopTag)));
|
||||
}
|
||||
|
||||
if(theTagIsSynonymous) {
|
||||
//if you're here, it's because we're trying to close one tag,
|
||||
//but a different (synonymous) one is actually open. Because this is NAV4x
|
||||
//compatibililty mode, we must close the one that's really open.
|
||||
aTag=theTopTag;
|
||||
pos=GetTopmostIndexOf(aTag);
|
||||
|
||||
@ -223,7 +223,7 @@ CTagList gOLAutoClose(3,0,eHTMLTag_p,eHTMLTag_ol,eHTMLTag_ul);
|
||||
CTagList gDivAutoClose(1,0,eHTMLTag_p);
|
||||
|
||||
static eHTMLTags gHxList[]={eHTMLTag_h1,eHTMLTag_h2,eHTMLTag_h3,eHTMLTag_h4,eHTMLTag_h5,eHTMLTag_h6};
|
||||
CTagList gHxAutoClose(sizeof(gHxList)/sizeof(eHTMLTag_unknown),gHxList);
|
||||
CTagList gHeadingTags(sizeof(gHxList)/sizeof(eHTMLTag_unknown),gHxList);
|
||||
|
||||
CTagList gTRCloseTags(3,0,eHTMLTag_tr,eHTMLTag_td,eHTMLTag_th);
|
||||
CTagList gTDCloseTags(2,0,eHTMLTag_td,eHTMLTag_th);
|
||||
@ -507,42 +507,42 @@ nsHTMLElement gHTMLElements[] = {
|
||||
|
||||
{ /*tag*/ eHTMLTag_h1,
|
||||
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
|
||||
/*autoclose starttags and endtags*/ &gHxAutoClose, &gHxAutoClose, &gHxAutoClose,
|
||||
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
|
||||
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
|
||||
/*special properties*/ 0,
|
||||
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
|
||||
|
||||
{ /*tag*/ eHTMLTag_h2,
|
||||
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
|
||||
/*autoclose starttags and endtags*/ &gHxAutoClose, &gHxAutoClose, &gHxAutoClose,
|
||||
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
|
||||
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
|
||||
/*special properties*/ 0,
|
||||
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
|
||||
|
||||
{ /*tag*/ eHTMLTag_h3,
|
||||
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
|
||||
/*autoclose starttags and endtags*/ &gHxAutoClose, &gHxAutoClose, &gHxAutoClose,
|
||||
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
|
||||
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
|
||||
/*special properties*/ 0,
|
||||
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
|
||||
|
||||
{ /*tag*/ eHTMLTag_h4,
|
||||
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
|
||||
/*autoclose starttags and endtags*/ &gHxAutoClose, &gHxAutoClose, &gHxAutoClose,
|
||||
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
|
||||
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
|
||||
/*special properties*/ 0,
|
||||
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
|
||||
|
||||
{ /*tag*/ eHTMLTag_h5,
|
||||
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
|
||||
/*autoclose starttags and endtags*/ &gHxAutoClose, &gHxAutoClose, &gHxAutoClose,
|
||||
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
|
||||
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
|
||||
/*special properties*/ 0,
|
||||
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
|
||||
|
||||
{ /*tag*/ eHTMLTag_h6,
|
||||
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
|
||||
/*autoclose starttags and endtags*/ &gHxAutoClose, &gHxAutoClose, &gHxAutoClose,
|
||||
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
|
||||
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
|
||||
/*special properties*/ 0,
|
||||
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
|
||||
@ -1306,6 +1306,16 @@ PRBool nsHTMLElement::IsStyleTag(eHTMLTags aChild) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/13/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRBool nsHTMLElement::IsHeadingTag(eHTMLTags aChild) {
|
||||
return gHeadingTags.Contains(aChild);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@ -101,6 +101,7 @@ struct nsHTMLElement {
|
||||
static PRBool CanContain(eHTMLTags aParent,eHTMLTags aChild);
|
||||
static PRBool IsContainer(eHTMLTags aTag) ;
|
||||
static PRBool IsStyleTag(eHTMLTags aTag) ;
|
||||
static PRBool IsHeadingTag(eHTMLTags aTag) ;
|
||||
static PRBool IsChildOfHead(eHTMLTags aTag) ;
|
||||
static PRBool IsTextTag(eHTMLTags aTag);
|
||||
|
||||
@ -120,7 +121,8 @@ struct nsHTMLElement {
|
||||
};
|
||||
|
||||
extern nsHTMLElement gHTMLElements[];
|
||||
|
||||
extern CTagList gFramesetKids;
|
||||
extern CTagList gHeadingTags;
|
||||
|
||||
//special property bits...
|
||||
static const int kDiscardTag = 0x0001; //tells us to toss this tag
|
||||
|
||||
@ -44,7 +44,6 @@
|
||||
|
||||
class nsIDTDDebug;
|
||||
class nsIParserNode;
|
||||
class CITokenHandler;
|
||||
class nsParser;
|
||||
|
||||
|
||||
|
||||
@ -311,7 +311,7 @@ nsresult CEndToken::Consume(PRUnichar aChar, nsScanner& aScanner) {
|
||||
//Instead, we only look at the first word.
|
||||
int theBufPos=-1;
|
||||
while(buffer[++theBufPos]){
|
||||
if(kSpace==buffer[theBufPos]){
|
||||
if(' '==buffer[theBufPos]){
|
||||
buffer[theBufPos]=0;
|
||||
break;
|
||||
}
|
||||
@ -693,6 +693,8 @@ nsresult ConsumeComment(PRUnichar aChar, nsScanner& aScanner,nsString& aString)
|
||||
*********************************************************/
|
||||
|
||||
aString="<!";
|
||||
nsAutoString theRightChars;
|
||||
|
||||
result=aScanner.GetChar(aChar);
|
||||
if(NS_OK==result) {
|
||||
aString+=aChar;
|
||||
@ -706,8 +708,7 @@ nsresult ConsumeComment(PRUnichar aChar, nsScanner& aScanner,nsString& aString)
|
||||
PRInt32 findpos=kNotFound;
|
||||
result=aScanner.ReadWhile(aString,gMinus,PR_TRUE,PR_TRUE); //get all available '---'
|
||||
findpos=aString.RFind("-->");
|
||||
//nsAutoString temp("");
|
||||
//nsAutoString ws("");
|
||||
|
||||
while((kNotFound==findpos) && (NS_OK==result)) {
|
||||
result=aScanner.ReadUntil(aString,kMinus,PR_TRUE);
|
||||
|
||||
@ -721,10 +722,14 @@ nsresult ConsumeComment(PRUnichar aChar, nsScanner& aScanner,nsString& aString)
|
||||
result=aScanner.GetChar(aChar);
|
||||
aString+=aChar;
|
||||
}
|
||||
|
||||
findpos=aString.RFind("-->");
|
||||
|
||||
theRightChars.Truncate(0);
|
||||
aString.Right(theRightChars,5);
|
||||
theRightChars.StripChars(" ");
|
||||
|
||||
findpos=theRightChars.RFind("-->");
|
||||
if(kNotFound==findpos)
|
||||
findpos=aString.RFind("!>");
|
||||
findpos=theRightChars.RFind("!>");
|
||||
} //while
|
||||
return result;
|
||||
} //if
|
||||
|
||||
@ -51,7 +51,7 @@ class nsParserFactory : public nsIFactory
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
nsParserFactory(const nsCID &aClass);
|
||||
~nsParserFactory();
|
||||
virtual ~nsParserFactory();
|
||||
|
||||
private:
|
||||
nsrefcnt mRefCnt;
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
#include "prtypes.h"
|
||||
#include "nsString.h"
|
||||
#include <iostream.h>
|
||||
#include "nsError.h"
|
||||
|
||||
class nsScanner;
|
||||
|
||||
|
||||
@ -42,7 +42,6 @@
|
||||
class nsIHTMLContentSink;
|
||||
class nsIDTDDebug;
|
||||
class nsIParserNode;
|
||||
class CITokenHandler;
|
||||
class nsParser;
|
||||
class nsITokenizer;
|
||||
|
||||
|
||||
@ -231,7 +231,7 @@ eAutoDetectResult CViewSourceHTML::CanParse(nsString& aContentType, nsString& aC
|
||||
aContentType.Equals(kHTMLTextContentType) ||
|
||||
aContentType.Equals(kPlainTextContentType) ||
|
||||
aContentType.Equals(kXULTextContentType)) {
|
||||
result=eValidDetect;
|
||||
result=ePrimaryDetect;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@ -40,7 +40,6 @@
|
||||
|
||||
class nsIDTDDebug;
|
||||
class nsIParserNode;
|
||||
class CITokenHandler;
|
||||
class nsParser;
|
||||
class nsITokenizer;
|
||||
|
||||
|
||||
@ -40,7 +40,6 @@
|
||||
|
||||
class nsIDTDDebug;
|
||||
class nsIParserNode;
|
||||
class CITokenHandler;
|
||||
class nsParser;
|
||||
class nsHTMLTokenizer;
|
||||
|
||||
|
||||
@ -417,8 +417,9 @@ eAutoDetectResult nsXIFDTD::CanParse(nsString& aContentType, nsString& aCommand,
|
||||
nsresult nsXIFDTD::WillBuildModel(nsString& aFileName,PRBool aNotifySink,nsString& aSourceType,nsIContentSink* aSink){
|
||||
nsresult result=NS_OK;
|
||||
|
||||
mSink=(nsIHTMLContentSink*)aSink;
|
||||
if(mSink) {
|
||||
(nsIHTMLContentSink*)mSink->WillBuildModel();
|
||||
mSink->WillBuildModel();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#define nshtmlpars_h___
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsError.h"
|
||||
|
||||
#ifdef _IMPL_NS_HTMLPARS
|
||||
#define NS_HTMLPARS NS_EXPORT
|
||||
|
||||
@ -61,11 +61,6 @@ static eHTMLTags gFormElementTags[]= {
|
||||
eHTMLTag_option, eHTMLTag_optgroup, eHTMLTag_select,
|
||||
eHTMLTag_textarea};
|
||||
|
||||
static eHTMLTags gHeadingTags[]={
|
||||
eHTMLTag_h1, eHTMLTag_h2, eHTMLTag_h3,
|
||||
eHTMLTag_h4, eHTMLTag_h5, eHTMLTag_h6};
|
||||
|
||||
|
||||
static eHTMLTags gTableChildTags[]={
|
||||
eHTMLTag_caption, eHTMLTag_col, eHTMLTag_colgroup,
|
||||
eHTMLTag_tbody, eHTMLTag_tfoot, eHTMLTag_tr,
|
||||
@ -782,6 +777,27 @@ eHTMLTags FindAutoCloseTargetForStartTag(eHTMLTags aCurrentTag,nsTagStack& aTagS
|
||||
return eHTMLTag_unknown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this to find the index of a given child, or (if not found)
|
||||
* the index of its nearest synonym.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aTagStack -- list of open tags
|
||||
* @param aTag -- tag to test for containership
|
||||
* @return index of kNotFound
|
||||
*/
|
||||
static
|
||||
PRInt32 GetIndexOfChildOrSynonym(nsTagStack& aTagStack,eHTMLTags aChildTag) {
|
||||
PRInt32 theChildIndex=aTagStack.GetTopmostIndexOf(aChildTag);
|
||||
if(kNotFound==theChildIndex) {
|
||||
CTagList* theSynTags=gHTMLElements[aChildTag].GetSynonymousTags(); //get the list of tags that THIS tag can close
|
||||
if(theSynTags) {
|
||||
theChildIndex=theSynTags->GetTopmostIndexOf(aTagStack);
|
||||
}
|
||||
}
|
||||
return theChildIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not the child
|
||||
* tag is happy being OPENED in the context of the current
|
||||
@ -799,13 +815,7 @@ PRBool CanBeContained(eHTMLTags aChildTag,nsTagStack& aTagStack) {
|
||||
CTagList* theRootTags=gHTMLElements[aChildTag].GetRootTags();
|
||||
if(theRootTags) {
|
||||
PRInt32 theRootIndex=theRootTags->GetTopmostIndexOf(aTagStack);
|
||||
PRInt32 theChildIndex=aTagStack.GetTopmostIndexOf(aChildTag);
|
||||
if(kNotFound==theChildIndex) {
|
||||
CTagList* theSynTags=gHTMLElements[aChildTag].GetSynonymousTags(); //get the list of tags that THIS tag can close
|
||||
if(theSynTags) {
|
||||
theChildIndex=theSynTags->GetTopmostIndexOf(aTagStack);
|
||||
}
|
||||
}
|
||||
PRInt32 theChildIndex=GetIndexOfChildOrSynonym(aTagStack,aChildTag);
|
||||
if(theRootIndex<theChildIndex){
|
||||
eHTMLTags thePrevTag=aTagStack.Last();
|
||||
result=gHTMLElements[thePrevTag].CanContainType(gHTMLElements[aChildTag].mParentBits);
|
||||
@ -816,6 +826,7 @@ PRBool CanBeContained(eHTMLTags aChildTag,nsTagStack& aTagStack) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method gets called when a start token has been
|
||||
* encountered in the parse process. If the current container
|
||||
@ -915,7 +926,7 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI
|
||||
|
||||
}//if(!rickGSkip)...
|
||||
|
||||
if(IsContainer(aChildTag)){
|
||||
if(nsHTMLElement::IsContainer(aChildTag)){
|
||||
//first, let's see if it's a style element...
|
||||
if(!nsHTMLElement::IsStyleTag(aChildTag)) {
|
||||
//it wasn't a style container, so open the element container...
|
||||
@ -1104,27 +1115,6 @@ PRBool HasCloseablePeerAboveRoot(CTagList& aRootTagList,nsTagStack& aTagStack,eH
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call this to find the index of a given child, or (if not found)
|
||||
* the index of its nearest synonym.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aTagStack -- list of open tags
|
||||
* @param aTag -- tag to test for containership
|
||||
* @return index of kNotFound
|
||||
*/
|
||||
static
|
||||
PRInt32 GetIndexOfChildOrSynonym(nsTagStack& aTagStack,eHTMLTags aChildTag) {
|
||||
PRInt32 theChildIndex=aTagStack.GetTopmostIndexOf(aChildTag);
|
||||
if(kNotFound==theChildIndex) {
|
||||
CTagList* theSynTags=gHTMLElements[aChildTag].GetSynonymousTags(); //get the list of tags that THIS tag can close
|
||||
if(theSynTags) {
|
||||
theChildIndex=theSynTags->GetTopmostIndexOf(aTagStack);
|
||||
}
|
||||
}
|
||||
return theChildIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not an END tag
|
||||
* can be autoclosed. This means that based on the current
|
||||
@ -1522,7 +1512,7 @@ PRBool CNavDTD::CanPropagate(eHTMLTags aParentTag,eHTMLTags aChildTag) const {
|
||||
PRBool result=PR_FALSE;
|
||||
PRBool parentCanContain=CanContain(aParentTag,aChildTag);
|
||||
|
||||
if(IsContainer(aChildTag)){
|
||||
if(nsHTMLElement::IsContainer(aChildTag)){
|
||||
if(nsHTMLElement::IsBlockParent(aParentTag) || (gHTMLElements[aParentTag].GetSpecialChildren())) {
|
||||
while(eHTMLTag_unknown!=aChildTag) {
|
||||
if(parentCanContain){
|
||||
@ -1596,6 +1586,10 @@ PRBool CNavDTD::CanOmit(eHTMLTags aParent,eHTMLTags aChild) const {
|
||||
}
|
||||
break;
|
||||
|
||||
case eHTMLTag_frameset:
|
||||
result=!gFramesetKids.Contains(aChild);
|
||||
break;
|
||||
|
||||
case eHTMLTag_unknown:
|
||||
{
|
||||
static eHTMLTags canSkip2[]={eHTMLTag_newline,eHTMLTag_whitespace};
|
||||
@ -1709,29 +1703,6 @@ PRBool CNavDTD::CanOmit(eHTMLTags aParent,eHTMLTags aChild) const {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is called when you want to determine if one tag is
|
||||
* synonymous with another. Cases where this are true include style
|
||||
* tags (where <i> is allowed to close <b> for example). Another
|
||||
* is <H?>, where any open heading tag can be closed by any close heading tag.
|
||||
* @update gess6/16/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
static
|
||||
PRBool IsCompatibleTag(eHTMLTags aTag1,eHTMLTags aTag2) {
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
if(nsHTMLElement::IsStyleTag(aTag1)) {
|
||||
result=nsHTMLElement::IsStyleTag(aTag2);
|
||||
}
|
||||
if(FindTagInSet(aTag1,gHeadingTags,sizeof(gHeadingTags)/sizeof(eHTMLTag_unknown))) {
|
||||
result=FindTagInSet(aTag2,gHeadingTags,sizeof(gHeadingTags)/sizeof(eHTMLTag_unknown));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -1749,13 +1720,7 @@ PRBool CNavDTD::CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild) const {
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRInt32 theChildIndex=GetTopmostIndexOf(aChild);
|
||||
if(kNotFound==theChildIndex) {
|
||||
CTagList* theSynTags=gHTMLElements[aChild].GetSynonymousTags(); //get the list of tags that THIS tag can close
|
||||
if(theSynTags) {
|
||||
theChildIndex=theSynTags->GetTopmostIndexOf(mBodyContext->mTags);
|
||||
}
|
||||
}
|
||||
PRInt32 theChildIndex=GetIndexOfChildOrSynonym(mBodyContext->mTags,aChild);
|
||||
result=PRBool(kNotFound==theChildIndex);
|
||||
|
||||
return result;
|
||||
@ -1770,8 +1735,7 @@ PRBool CNavDTD::CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild) const {
|
||||
* @return PR_TRUE if given tag can contain other tags
|
||||
*/
|
||||
PRBool CNavDTD::IsContainer(PRInt32 aTag) const {
|
||||
PRBool result=nsHTMLElement::IsContainer((eHTMLTags)aTag);
|
||||
return result;
|
||||
return nsHTMLElement::IsContainer((eHTMLTags)aTag);
|
||||
}
|
||||
|
||||
|
||||
@ -2457,9 +2421,15 @@ nsresult CNavDTD::CloseContainersTo(eHTMLTags aTag,PRBool aUpdateStyles){
|
||||
}
|
||||
|
||||
eHTMLTags theTopTag=mBodyContext->Last();
|
||||
if(IsCompatibleTag(aTag,theTopTag)) {
|
||||
//if you're here, it's because we're trying to close one style tag,
|
||||
//but a different one is actually open. Because this is NAV4x
|
||||
|
||||
PRBool theTagIsSynonymous=((nsHTMLElement::IsStyleTag(aTag)) && (nsHTMLElement::IsStyleTag(theTopTag)));
|
||||
if(!theTagIsSynonymous){
|
||||
theTagIsSynonymous=((nsHTMLElement::IsHeadingTag(aTag)) && (nsHTMLElement::IsHeadingTag(theTopTag)));
|
||||
}
|
||||
|
||||
if(theTagIsSynonymous) {
|
||||
//if you're here, it's because we're trying to close one tag,
|
||||
//but a different (synonymous) one is actually open. Because this is NAV4x
|
||||
//compatibililty mode, we must close the one that's really open.
|
||||
aTag=theTopTag;
|
||||
pos=GetTopmostIndexOf(aTag);
|
||||
|
||||
@ -223,7 +223,7 @@ CTagList gOLAutoClose(3,0,eHTMLTag_p,eHTMLTag_ol,eHTMLTag_ul);
|
||||
CTagList gDivAutoClose(1,0,eHTMLTag_p);
|
||||
|
||||
static eHTMLTags gHxList[]={eHTMLTag_h1,eHTMLTag_h2,eHTMLTag_h3,eHTMLTag_h4,eHTMLTag_h5,eHTMLTag_h6};
|
||||
CTagList gHxAutoClose(sizeof(gHxList)/sizeof(eHTMLTag_unknown),gHxList);
|
||||
CTagList gHeadingTags(sizeof(gHxList)/sizeof(eHTMLTag_unknown),gHxList);
|
||||
|
||||
CTagList gTRCloseTags(3,0,eHTMLTag_tr,eHTMLTag_td,eHTMLTag_th);
|
||||
CTagList gTDCloseTags(2,0,eHTMLTag_td,eHTMLTag_th);
|
||||
@ -507,42 +507,42 @@ nsHTMLElement gHTMLElements[] = {
|
||||
|
||||
{ /*tag*/ eHTMLTag_h1,
|
||||
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
|
||||
/*autoclose starttags and endtags*/ &gHxAutoClose, &gHxAutoClose, &gHxAutoClose,
|
||||
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
|
||||
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
|
||||
/*special properties*/ 0,
|
||||
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
|
||||
|
||||
{ /*tag*/ eHTMLTag_h2,
|
||||
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
|
||||
/*autoclose starttags and endtags*/ &gHxAutoClose, &gHxAutoClose, &gHxAutoClose,
|
||||
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
|
||||
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
|
||||
/*special properties*/ 0,
|
||||
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
|
||||
|
||||
{ /*tag*/ eHTMLTag_h3,
|
||||
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
|
||||
/*autoclose starttags and endtags*/ &gHxAutoClose, &gHxAutoClose, &gHxAutoClose,
|
||||
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
|
||||
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
|
||||
/*special properties*/ 0,
|
||||
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
|
||||
|
||||
{ /*tag*/ eHTMLTag_h4,
|
||||
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
|
||||
/*autoclose starttags and endtags*/ &gHxAutoClose, &gHxAutoClose, &gHxAutoClose,
|
||||
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
|
||||
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
|
||||
/*special properties*/ 0,
|
||||
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
|
||||
|
||||
{ /*tag*/ eHTMLTag_h5,
|
||||
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
|
||||
/*autoclose starttags and endtags*/ &gHxAutoClose, &gHxAutoClose, &gHxAutoClose,
|
||||
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
|
||||
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
|
||||
/*special properties*/ 0,
|
||||
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
|
||||
|
||||
{ /*tag*/ eHTMLTag_h6,
|
||||
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
|
||||
/*autoclose starttags and endtags*/ &gHxAutoClose, &gHxAutoClose, &gHxAutoClose,
|
||||
/*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,
|
||||
/*parent,incl,exclgroups*/ kBlock, kFlow, kNone,
|
||||
/*special properties*/ 0,
|
||||
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown},
|
||||
@ -1306,6 +1306,16 @@ PRBool nsHTMLElement::IsStyleTag(eHTMLTags aChild) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/13/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRBool nsHTMLElement::IsHeadingTag(eHTMLTags aChild) {
|
||||
return gHeadingTags.Contains(aChild);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@ -101,6 +101,7 @@ struct nsHTMLElement {
|
||||
static PRBool CanContain(eHTMLTags aParent,eHTMLTags aChild);
|
||||
static PRBool IsContainer(eHTMLTags aTag) ;
|
||||
static PRBool IsStyleTag(eHTMLTags aTag) ;
|
||||
static PRBool IsHeadingTag(eHTMLTags aTag) ;
|
||||
static PRBool IsChildOfHead(eHTMLTags aTag) ;
|
||||
static PRBool IsTextTag(eHTMLTags aTag);
|
||||
|
||||
@ -120,7 +121,8 @@ struct nsHTMLElement {
|
||||
};
|
||||
|
||||
extern nsHTMLElement gHTMLElements[];
|
||||
|
||||
extern CTagList gFramesetKids;
|
||||
extern CTagList gHeadingTags;
|
||||
|
||||
//special property bits...
|
||||
static const int kDiscardTag = 0x0001; //tells us to toss this tag
|
||||
|
||||
@ -44,7 +44,6 @@
|
||||
|
||||
class nsIDTDDebug;
|
||||
class nsIParserNode;
|
||||
class CITokenHandler;
|
||||
class nsParser;
|
||||
|
||||
|
||||
|
||||
@ -311,7 +311,7 @@ nsresult CEndToken::Consume(PRUnichar aChar, nsScanner& aScanner) {
|
||||
//Instead, we only look at the first word.
|
||||
int theBufPos=-1;
|
||||
while(buffer[++theBufPos]){
|
||||
if(kSpace==buffer[theBufPos]){
|
||||
if(' '==buffer[theBufPos]){
|
||||
buffer[theBufPos]=0;
|
||||
break;
|
||||
}
|
||||
@ -693,6 +693,8 @@ nsresult ConsumeComment(PRUnichar aChar, nsScanner& aScanner,nsString& aString)
|
||||
*********************************************************/
|
||||
|
||||
aString="<!";
|
||||
nsAutoString theRightChars;
|
||||
|
||||
result=aScanner.GetChar(aChar);
|
||||
if(NS_OK==result) {
|
||||
aString+=aChar;
|
||||
@ -706,8 +708,7 @@ nsresult ConsumeComment(PRUnichar aChar, nsScanner& aScanner,nsString& aString)
|
||||
PRInt32 findpos=kNotFound;
|
||||
result=aScanner.ReadWhile(aString,gMinus,PR_TRUE,PR_TRUE); //get all available '---'
|
||||
findpos=aString.RFind("-->");
|
||||
//nsAutoString temp("");
|
||||
//nsAutoString ws("");
|
||||
|
||||
while((kNotFound==findpos) && (NS_OK==result)) {
|
||||
result=aScanner.ReadUntil(aString,kMinus,PR_TRUE);
|
||||
|
||||
@ -721,10 +722,14 @@ nsresult ConsumeComment(PRUnichar aChar, nsScanner& aScanner,nsString& aString)
|
||||
result=aScanner.GetChar(aChar);
|
||||
aString+=aChar;
|
||||
}
|
||||
|
||||
findpos=aString.RFind("-->");
|
||||
|
||||
theRightChars.Truncate(0);
|
||||
aString.Right(theRightChars,5);
|
||||
theRightChars.StripChars(" ");
|
||||
|
||||
findpos=theRightChars.RFind("-->");
|
||||
if(kNotFound==findpos)
|
||||
findpos=aString.RFind("!>");
|
||||
findpos=theRightChars.RFind("!>");
|
||||
} //while
|
||||
return result;
|
||||
} //if
|
||||
|
||||
@ -51,7 +51,7 @@ class nsParserFactory : public nsIFactory
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
nsParserFactory(const nsCID &aClass);
|
||||
~nsParserFactory();
|
||||
virtual ~nsParserFactory();
|
||||
|
||||
private:
|
||||
nsrefcnt mRefCnt;
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
#include "prtypes.h"
|
||||
#include "nsString.h"
|
||||
#include <iostream.h>
|
||||
#include "nsError.h"
|
||||
|
||||
class nsScanner;
|
||||
|
||||
|
||||
@ -42,7 +42,6 @@
|
||||
class nsIHTMLContentSink;
|
||||
class nsIDTDDebug;
|
||||
class nsIParserNode;
|
||||
class CITokenHandler;
|
||||
class nsParser;
|
||||
class nsITokenizer;
|
||||
|
||||
|
||||
@ -231,7 +231,7 @@ eAutoDetectResult CViewSourceHTML::CanParse(nsString& aContentType, nsString& aC
|
||||
aContentType.Equals(kHTMLTextContentType) ||
|
||||
aContentType.Equals(kPlainTextContentType) ||
|
||||
aContentType.Equals(kXULTextContentType)) {
|
||||
result=eValidDetect;
|
||||
result=ePrimaryDetect;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@ -40,7 +40,6 @@
|
||||
|
||||
class nsIDTDDebug;
|
||||
class nsIParserNode;
|
||||
class CITokenHandler;
|
||||
class nsParser;
|
||||
class nsITokenizer;
|
||||
|
||||
|
||||
@ -40,7 +40,6 @@
|
||||
|
||||
class nsIDTDDebug;
|
||||
class nsIParserNode;
|
||||
class CITokenHandler;
|
||||
class nsParser;
|
||||
class nsHTMLTokenizer;
|
||||
|
||||
|
||||
@ -417,8 +417,9 @@ eAutoDetectResult nsXIFDTD::CanParse(nsString& aContentType, nsString& aCommand,
|
||||
nsresult nsXIFDTD::WillBuildModel(nsString& aFileName,PRBool aNotifySink,nsString& aSourceType,nsIContentSink* aSink){
|
||||
nsresult result=NS_OK;
|
||||
|
||||
mSink=(nsIHTMLContentSink*)aSink;
|
||||
if(mSink) {
|
||||
(nsIHTMLContentSink*)mSink->WillBuildModel();
|
||||
mSink->WillBuildModel();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#define nshtmlpars_h___
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsError.h"
|
||||
|
||||
#ifdef _IMPL_NS_HTMLPARS
|
||||
#define NS_HTMLPARS NS_EXPORT
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user