Fix for Bugs

24112 - Fixed the orderding of THEAD, TBODY, and TFOOT
24673 - Fixed the crash my not letting P to contain TABLE ( per spec. )
18308 - Ignoring newlines above BODY
18928 - Fixed by forcing a BODY to open, irrespective of FRAMESET document, if
 'text' is present in the document.
23791 - Made ; in entities optional.
24006 - Fixed by setting the alternate end-comment to be '>'.
24275 - Buffering newlines/whitespace only when it's absolutely necessary.
24462 - Fixed by making NOBR a block closure.
21917 - Being careful about ignoring newlines/whitespace for body content.

r=rickg

24204 - Fixed by opening up BODY for INPUT ( quirks )
Also did a minor change in CNavDTD::DidBuildModel();

r=pollmann


git-svn-id: svn://10.0.0.236/trunk@58870 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
harishd%netscape.com
2000-01-27 02:27:58 +00:00
parent 8a12f68241
commit d400676ed4
12 changed files with 62 additions and 76 deletions

View File

@@ -599,7 +599,6 @@ nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParse
CStartToken *theToken=(CStartToken*)mTokenRecycler->CreateTokenOfType(eToken_start,eHTMLTag_body,"body");
mTokenizer->PushTokenFront(theToken); //this token should get pushed on the context stack, don't recycle it
mTokenizer->PrependTokens(mMisplacedContent); //push misplaced content
result=BuildModel(aParser,mTokenizer,0,aSink);
}
@@ -761,7 +760,10 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){
case eHTMLTag_markupDecl:
case eHTMLTag_userdefined:
break; //simply pass these through to token handler without further ado...
case eHTMLTag_newline:
case eHTMLTag_whitespace:
if(mMisplacedContent.GetSize()<=0) // fix for bugs 17017,18308,23765, and 24275
break; // Push only when it's absolutely necessary.
default:
if(!gHTMLElements[eHTMLTag_html].SectionContains(theTag,PR_FALSE)) {
if((!mHadBody) && (!mHadFrameset)){
@@ -777,8 +779,13 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){
//If you're here then we found a child of the body that was out of place.
//We're going to move it to the body by storing it temporarily on the misplaced stack.
//However, in quirks mode, a few tags request, ambiguosly, for a BODY. - Bugs 18928, 24204.-
mMisplacedContent.Push(aToken);
aToken->mUseCount++;
if(mParseMode==eParseMode_quirks && (gHTMLElements[theTag].HasSpecialProperty(kRequiresBody))) {
CToken* theBodyToken=(CToken*)mTokenRecycler->CreateTokenOfType(eToken_start,eHTMLTag_body,"body");
result=HandleToken(theBodyToken,aParser);
}
return result;
}

View File

@@ -49,7 +49,7 @@ TagList gInTR={1,{eHTMLTag_tr}};
TagList gInDL={2,{eHTMLTag_dl,eHTMLTag_body}};
TagList gInFrameset={1,{eHTMLTag_frameset}};
TagList gInNoframes={1,{eHTMLTag_noframes}};
TagList gInP={4,{eHTMLTag_address,eHTMLTag_span,eHTMLTag_table,eHTMLTag_form}}; // P containing TABLE - Ref: Bug# 11229
TagList gInP={3,{eHTMLTag_address,eHTMLTag_span,eHTMLTag_form}}; // P used to contain TABLE - Ref: Bug# 11229 - Removed TABLE to solve Bug# 24673
TagList gOptgroupParents={2,{eHTMLTag_select,eHTMLTag_optgroup}};
TagList gBodyParents={2,{eHTMLTag_html,eHTMLTag_noframes}};
TagList gColParents={2,{eHTMLTag_table,eHTMLTag_colgroup}};
@@ -117,7 +117,7 @@ TagList gNoframeRoot={2,{eHTMLTag_body,eHTMLTag_frameset}};
//*********************************************************************************************
TagList gBodyAutoClose={1,{eHTMLTag_head}};
TagList gTBodyAutoClose={3,{eHTMLTag_thead,eHTMLTag_tfoot,eHTMLTag_tbody}};
TagList gTBodyAutoClose={5,{eHTMLTag_thead,eHTMLTag_tfoot,eHTMLTag_tbody,eHTMLTag_td,eHTMLTag_th}}; // TD|TH inclusion - Bug# 24112
TagList gCaptionAutoClose={1,{eHTMLTag_tbody}};
TagList gLIAutoClose={2,{eHTMLTag_p,eHTMLTag_li}};
TagList gPAutoClose={2,{eHTMLTag_p,eHTMLTag_li}};
@@ -685,7 +685,7 @@ void InitializeElementTable(void) {
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,0,
/*parent,incl,exclgroups*/ kFormControl, kNone, kNone,
/*special props, prop-range*/ kNonContainer,kDefaultPropRange,
/*special props, prop-range*/ kNonContainer|kRequiresBody,kDefaultPropRange,
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown);
Initialize(
@@ -1232,7 +1232,7 @@ void InitializeElementTable(void) {
/*rootnodes,endrootnodes*/ &gInBody,&gInBody,
/*autoclose starttags and endtags*/ 0,0,0,0,
/*parent,incl,exclgroups*/ kFlowEntity, kNone, kNone,
/*special props, prop-range*/ kNonContainer,kNoPropRange,
/*special props, prop-range*/ kNonContainer|kRequiresBody,kNoPropRange,
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown);
Initialize(
@@ -1386,10 +1386,10 @@ PRBool nsHTMLElement::IsBlockCloser(eHTMLTags aTag){
gHTMLElements[aTag].IsBlockEntity() ||
(kHeading==gHTMLElements[aTag].mParentBits));
if(!result) {
// NOBR is a block closure - Ref. Bug# 24462
static eHTMLTags gClosers[]={ eHTMLTag_table,eHTMLTag_tbody,eHTMLTag_caption,eHTMLTag_dd,eHTMLTag_dt,
/* eHTMLTag_td,eHTMLTag_tfoot,eHTMLTag_th,eHTMLTag_thead,eHTMLTag_tr, */
eHTMLTag_optgroup,eHTMLTag_ol,eHTMLTag_ul};
eHTMLTag_nobr,eHTMLTag_optgroup,eHTMLTag_ol,eHTMLTag_ul};
result=FindTagInSet(aTag,gClosers,sizeof(gClosers)/sizeof(eHTMLTag_body));
}
}

View File

@@ -222,6 +222,7 @@ static const int kMustCloseSelf = 0x0100;
static const int kSaveMisplaced = 0x0200; //If set, then children this tag can't contain are pushed onto the misplaced stack
static const int kNonContainer = 0x0400; //If set, then this tag is not a container.
static const int kHandleStrayTag = 0x0800; //If set, we automatically open a start tag
static const int kRequiresBody = 0x1000; //If set, then in case of no BODY one will be opened up immediately.
#endif

View File

@@ -807,11 +807,9 @@ nsresult ConsumeComment(PRUnichar aChar, nsScanner& aScanner,nsString& aString)
result=aScanner.GetChar(aChar);
if(NS_OK==result) {
if(kMinus==aChar) {
//in this case, we're reading a long-form comment <-- xxx -->
nsAutoString gDfltEndComment("-->");
//in this case, we're reading a long-form comment <-- xxx -->
aString+=aChar;
PRInt32 findpos=kNotFound;
while((kNotFound==findpos) && (NS_OK==result)) {
result=aScanner.ReadUntil(aString,kGreaterThan,PR_TRUE);
@@ -822,31 +820,17 @@ nsresult ConsumeComment(PRUnichar aChar, nsScanner& aScanner,nsString& aString)
if(kMinus==aChar) return result; // We have found the dflt end comment delimiter ("-->")
}
if(kNotFound==theBestAltPos) {
const PRUnichar* theBuf=aString.GetUnicode();
findpos=aString.Length()-3;
theBuf=(PRUnichar*)&theBuf[findpos];
if(!gDfltEndComment.Equals(theBuf,PR_FALSE,3)) {
//we didn't find the dflt end comment delimiter, so look for alternatives...
findpos=kNotFound;
theRightChars.Truncate(0);
aString.Right(theRightChars,15);
theRightChars.StripChars(" ");
int rclen=theRightChars.Length();
aChar=theRightChars[rclen-2];
if(('!'==aChar) || ('-'==aChar)) {
theBestAltPos=aString.Length();
theStartOffset=aScanner.GetOffset();
}
}
// If we did not find the dflt then assume that '>' is the end comment
// until we find '-->'. Nav. Compatibility -- Ref: Bug# 24006
theBestAltPos=aString.Length();
theStartOffset=aScanner.GetOffset();
}
}
} //while
if((kNotFound==findpos) && (!aScanner.IsIncremental())) {
//if you're here, then we're in a special state.
//The problem at hand is that we've hit the end of the document without finding the normal endcomment delimiter "-->".
//In this case, the first thing we try is to see if we found one of the alternate endcomment delimiters "->" or "!>".
//In this case, the first thing we try is to see if we found one of the alternate endcomment delimiter ">".
//If so, rewind just pass than, and use everything up to that point as your comment.
//If not, the document has no end comment and should be treated as one big comment.
if(kNotFound<theBestAltPos) {
@@ -1514,7 +1498,7 @@ PRInt32 CEntityToken::ConsumeEntity(PRUnichar aChar,nsString& aString,nsScanner&
result=aScanner.ReadNumber(aString);
}
}
else result=aScanner.ReadIdentifier(aString);
else result=aScanner.ReadIdentifier(aString,PR_TRUE); // Ref. Bug# 23791 - For setting aIgnore to PR_TRUE.
if(NS_OK==result) {
result=aScanner.Peek(theChar);
if(NS_OK==result) {

View File

@@ -648,14 +648,14 @@ nsresult nsScanner::SkipPast(nsString& aValidSet){
/**
* Consume characters until you find the terminal char
* Consume characters until you did not find the terminal char
*
* @update gess 3/25/98
* @param aString receives new data from stream
* @param addTerminal tells us whether to append terminal to aString
* @param aString - receives new data from stream
* @param aIgnore - If set ignores ':','-','_'
* @return error code
*/
nsresult nsScanner::ReadIdentifier(nsString& aString) {
nsresult nsScanner::ReadIdentifier(nsString& aString,PRBool aIgnore) {
PRUnichar theChar=0;
nsresult result=Peek(theChar);
@@ -672,7 +672,8 @@ nsresult nsScanner::ReadIdentifier(nsString& aString) {
case ':':
case '_':
case '-':
found=PR_TRUE;
if(!aIgnore)
found=PR_TRUE;
break;
default:
if(('a'<=theChar) && (theChar<='z'))

View File

@@ -175,7 +175,7 @@ class nsScanner {
* @param addTerminal tells us whether to append terminal to aString
* @return error code
*/
nsresult ReadIdentifier(nsString& aString);
nsresult ReadIdentifier(nsString& aString,PRBool aIgnore=PR_FALSE);
nsresult ReadNumber(nsString& aString);
nsresult ReadWhitespace(nsString& aString);