[A] chofmann [R] nisheeth
This commit is contained in:
harishd%netscape.com 1999-09-23 21:26:40 +00:00
Родитель 06c534cac5
Коммит 1d249a91fa
6 изменённых файлов: 32 добавлений и 54 удалений

Просмотреть файл

@ -1042,16 +1042,14 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI
if(!(theCanContainResult && theChildAgrees)) {
if (!CanPropagate(theParentTag,aChildTag)) {
if(nsHTMLElement::IsContainer(aChildTag)){
if(gHTMLElements[aChildTag].HasSpecialProperty(kDiscardMisplaced)) {
if(!gHTMLElements[aChildTag].CanAutoCloseTag(theParentTag)) {
// Closing the tags above might cause non-compatible results.
// Ex. <TABLE><TR><TD><TBODY>Text</TD></TR></TABLE>.
// In the example above <TBODY> is badly misplaced. To be backwards
// compatible we should not attempt to close the tags above it, for
// the contents inside the table might get thrown out of the table.
// The safest thing to do is to discard this tag.
if(!gHTMLElements[aChildTag].CanAutoCloseTag(theParentTag,eToken_start)) {
return result;
}
// The safest thing to do is to discard this tag.
return result;
}
CloseContainersTo(theIndex,theParentTag,PR_TRUE);
}//if
@ -1518,7 +1516,7 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) {
}
else {
if((kNotFound==GetIndexOfChildOrSynonym(mBodyContext->mStack,theChildTag)) ||
(!gHTMLElements[theChildTag].CanAutoCloseTag(mBodyContext->Last(),eToken_end))) {
(!gHTMLElements[theChildTag].CanAutoCloseTag(mBodyContext->Last()))) {
UpdateStyleStackForCloseTag(theChildTag,theChildTag);
if(gHTMLElements[theChildTag].IsMemberOf(kBlockEntity)) {
// Oh boy!! we found a "stray" block entity. Nav4.x and IE introduce line break in
@ -1595,6 +1593,7 @@ nsresult CNavDTD::HandleSavedTokensAbove(eHTMLTags aTag)
for(PRInt32 j=0;j<attrCount; j++){
CToken* theAttrToken = mBodyContext->RestoreTokenFrom(theBadContentIndex);
if(theAttrToken) {
theAttrToken->mRecycle=PR_TRUE;
mTokenizer->PushTokenFront(theAttrToken);
}
theBadTokenCount--;

Просмотреть файл

@ -204,8 +204,6 @@ CTagList gNoframeRoot(2,0,eHTMLTag_body,eHTMLTag_frameset);
CTagList gAutoClose(2,0,eHTMLTag_body,eHTMLTag_td);
CTagList gBodyAutoClose(1,0,eHTMLTag_head);
CTagList gTBodyAutoClose(3,0,eHTMLTag_thead,eHTMLTag_tfoot,eHTMLTag_tbody);
CTagList gTHeadAutoClose(2,0,eHTMLTag_thead,eHTMLTag_colgroup);
CTagList gTFootAutoClose(2,0,eHTMLTag_tfoot,eHTMLTag_colgroup);
CTagList gCaptionAutoClose(1,0,eHTMLTag_tbody);
CTagList gLIAutoClose(2,0,eHTMLTag_p,eHTMLTag_li);
CTagList gPAutoClose(2,0,eHTMLTag_p,eHTMLTag_li);
@ -1044,9 +1042,9 @@ nsHTMLElement gHTMLElements[] = {
{ /*tag*/ eHTMLTag_tbody,
/*requiredAncestor*/ eHTMLTag_table, eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInTable, &gInTable,
/*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0,0,
/*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0,&gDontAutoClose,
/*parent,incl,exclgroups*/ kNone, kNone, (kSelf|kInlineEntity),
/*special props, prop-range*/ (kNoPropagate|kOmitWS|kBadContentWatch|kNoStyleLeaksIn|kDiscardMisplaced), kDefaultPropRange,
/*special props, prop-range*/ (kNoPropagate|kOmitWS|kBadContentWatch|kNoStyleLeaksIn), kDefaultPropRange,
/*special parents,kids,skip*/ &gInTable,&gTBodyKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_td,
@ -1068,9 +1066,9 @@ nsHTMLElement gHTMLElements[] = {
{ /*tag*/ eHTMLTag_tfoot,
/*requiredAncestor*/ eHTMLTag_table, eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInTable, &gInTable,
/*autoclose starttags and endtags*/ &gTFootAutoClose,0,0,0,
/*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0,&gDontAutoClose,
/*parent,incl,exclgroups*/ kNone, kNone, kSelf,
/*special props, prop-range*/ (kNoPropagate|kOmitWS|kBadContentWatch|kNoStyleLeaksIn|kDiscardMisplaced), kNoPropRange,
/*special props, prop-range*/ (kNoPropagate|kOmitWS|kBadContentWatch|kNoStyleLeaksIn), kNoPropRange,
/*special parents,kids,skip*/ &gInTable,&gTableElemKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_th,
@ -1084,9 +1082,9 @@ nsHTMLElement gHTMLElements[] = {
{ /*tag*/ eHTMLTag_thead,
/*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInTable,&gInTable,
/*autoclose starttags and endtags*/ &gTHeadAutoClose,0,0,0,
/*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0,&gDontAutoClose,
/*parent,incl,exclgroups*/ kNone, kNone, kSelf,
/*special props, prop-range*/ (kNoPropagate|kOmitWS|kBadContentWatch|kNoStyleLeaksIn|kDiscardMisplaced), kNoPropRange,
/*special props, prop-range*/ (kNoPropagate|kOmitWS|kBadContentWatch|kNoStyleLeaksIn), kNoPropRange,
/*special parents,kids,skip*/ &gInTable,&gTableElemKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_title,
@ -1624,18 +1622,11 @@ PRBool nsHTMLElement::CanContainSelf(void) const {
* @param
* @return
*/
PRBool nsHTMLElement::CanAutoCloseTag(eHTMLTags aTag, eHTMLTokenTypes aType) const{
PRBool nsHTMLElement::CanAutoCloseTag(eHTMLTags aTag) const{
PRBool result=PR_TRUE;
if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_userdefined)){
CTagList* theTagList=nsnull;
if(aType==eToken_start) {
theTagList=gHTMLElements[mTagID].GetAutoCloseStartTags();
if(theTagList) return theTagList->Contains(aTag);
}
else {
theTagList=gHTMLElements[mTagID].GetNonAutoCloseEndTags();
if(theTagList) return !theTagList->Contains(aTag);
}
if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_userdefined)) {
CTagList* theTagList=gHTMLElements[mTagID].GetNonAutoCloseEndTags();
if(theTagList) return !theTagList->Contains(aTag);
}
return result;
}

Просмотреть файл

@ -99,7 +99,7 @@ struct nsHTMLElement {
PRBool CanOmitStartTag(eHTMLTags aChild) const;
PRBool CanOmitEndTag(void) const;
PRBool CanContainSelf(void) const;
PRBool CanAutoCloseTag(eHTMLTags aTag, eHTMLTokenTypes aType) const;
PRBool CanAutoCloseTag(eHTMLTags aTag) const;
PRBool HasSpecialProperty(PRInt32 aProperty) const;
PRBool SectionContains(eHTMLTags aTag,PRBool allowDepthSearch);
@ -150,7 +150,6 @@ static const int kNoStyleLeaksIn = 0x0040;
static const int kNoStyleLeaksOut = 0x0080;
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 kDiscardMisplaced = 0x0400; //If set, then the tag, if misplaced, will be ignored.
//*********************************************************************************************
// The following ints define the standard groups of HTML elements...

Просмотреть файл

@ -1042,16 +1042,14 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI
if(!(theCanContainResult && theChildAgrees)) {
if (!CanPropagate(theParentTag,aChildTag)) {
if(nsHTMLElement::IsContainer(aChildTag)){
if(gHTMLElements[aChildTag].HasSpecialProperty(kDiscardMisplaced)) {
if(!gHTMLElements[aChildTag].CanAutoCloseTag(theParentTag)) {
// Closing the tags above might cause non-compatible results.
// Ex. <TABLE><TR><TD><TBODY>Text</TD></TR></TABLE>.
// In the example above <TBODY> is badly misplaced. To be backwards
// compatible we should not attempt to close the tags above it, for
// the contents inside the table might get thrown out of the table.
// The safest thing to do is to discard this tag.
if(!gHTMLElements[aChildTag].CanAutoCloseTag(theParentTag,eToken_start)) {
return result;
}
// The safest thing to do is to discard this tag.
return result;
}
CloseContainersTo(theIndex,theParentTag,PR_TRUE);
}//if
@ -1518,7 +1516,7 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) {
}
else {
if((kNotFound==GetIndexOfChildOrSynonym(mBodyContext->mStack,theChildTag)) ||
(!gHTMLElements[theChildTag].CanAutoCloseTag(mBodyContext->Last(),eToken_end))) {
(!gHTMLElements[theChildTag].CanAutoCloseTag(mBodyContext->Last()))) {
UpdateStyleStackForCloseTag(theChildTag,theChildTag);
if(gHTMLElements[theChildTag].IsMemberOf(kBlockEntity)) {
// Oh boy!! we found a "stray" block entity. Nav4.x and IE introduce line break in
@ -1595,6 +1593,7 @@ nsresult CNavDTD::HandleSavedTokensAbove(eHTMLTags aTag)
for(PRInt32 j=0;j<attrCount; j++){
CToken* theAttrToken = mBodyContext->RestoreTokenFrom(theBadContentIndex);
if(theAttrToken) {
theAttrToken->mRecycle=PR_TRUE;
mTokenizer->PushTokenFront(theAttrToken);
}
theBadTokenCount--;

Просмотреть файл

@ -204,8 +204,6 @@ CTagList gNoframeRoot(2,0,eHTMLTag_body,eHTMLTag_frameset);
CTagList gAutoClose(2,0,eHTMLTag_body,eHTMLTag_td);
CTagList gBodyAutoClose(1,0,eHTMLTag_head);
CTagList gTBodyAutoClose(3,0,eHTMLTag_thead,eHTMLTag_tfoot,eHTMLTag_tbody);
CTagList gTHeadAutoClose(2,0,eHTMLTag_thead,eHTMLTag_colgroup);
CTagList gTFootAutoClose(2,0,eHTMLTag_tfoot,eHTMLTag_colgroup);
CTagList gCaptionAutoClose(1,0,eHTMLTag_tbody);
CTagList gLIAutoClose(2,0,eHTMLTag_p,eHTMLTag_li);
CTagList gPAutoClose(2,0,eHTMLTag_p,eHTMLTag_li);
@ -1044,9 +1042,9 @@ nsHTMLElement gHTMLElements[] = {
{ /*tag*/ eHTMLTag_tbody,
/*requiredAncestor*/ eHTMLTag_table, eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInTable, &gInTable,
/*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0,0,
/*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0,&gDontAutoClose,
/*parent,incl,exclgroups*/ kNone, kNone, (kSelf|kInlineEntity),
/*special props, prop-range*/ (kNoPropagate|kOmitWS|kBadContentWatch|kNoStyleLeaksIn|kDiscardMisplaced), kDefaultPropRange,
/*special props, prop-range*/ (kNoPropagate|kOmitWS|kBadContentWatch|kNoStyleLeaksIn), kDefaultPropRange,
/*special parents,kids,skip*/ &gInTable,&gTBodyKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_td,
@ -1068,9 +1066,9 @@ nsHTMLElement gHTMLElements[] = {
{ /*tag*/ eHTMLTag_tfoot,
/*requiredAncestor*/ eHTMLTag_table, eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInTable, &gInTable,
/*autoclose starttags and endtags*/ &gTFootAutoClose,0,0,0,
/*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0,&gDontAutoClose,
/*parent,incl,exclgroups*/ kNone, kNone, kSelf,
/*special props, prop-range*/ (kNoPropagate|kOmitWS|kBadContentWatch|kNoStyleLeaksIn|kDiscardMisplaced), kNoPropRange,
/*special props, prop-range*/ (kNoPropagate|kOmitWS|kBadContentWatch|kNoStyleLeaksIn), kNoPropRange,
/*special parents,kids,skip*/ &gInTable,&gTableElemKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_th,
@ -1084,9 +1082,9 @@ nsHTMLElement gHTMLElements[] = {
{ /*tag*/ eHTMLTag_thead,
/*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInTable,&gInTable,
/*autoclose starttags and endtags*/ &gTHeadAutoClose,0,0,0,
/*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0,&gDontAutoClose,
/*parent,incl,exclgroups*/ kNone, kNone, kSelf,
/*special props, prop-range*/ (kNoPropagate|kOmitWS|kBadContentWatch|kNoStyleLeaksIn|kDiscardMisplaced), kNoPropRange,
/*special props, prop-range*/ (kNoPropagate|kOmitWS|kBadContentWatch|kNoStyleLeaksIn), kNoPropRange,
/*special parents,kids,skip*/ &gInTable,&gTableElemKids,eHTMLTag_unknown},
{ /*tag*/ eHTMLTag_title,
@ -1624,18 +1622,11 @@ PRBool nsHTMLElement::CanContainSelf(void) const {
* @param
* @return
*/
PRBool nsHTMLElement::CanAutoCloseTag(eHTMLTags aTag, eHTMLTokenTypes aType) const{
PRBool nsHTMLElement::CanAutoCloseTag(eHTMLTags aTag) const{
PRBool result=PR_TRUE;
if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_userdefined)){
CTagList* theTagList=nsnull;
if(aType==eToken_start) {
theTagList=gHTMLElements[mTagID].GetAutoCloseStartTags();
if(theTagList) return theTagList->Contains(aTag);
}
else {
theTagList=gHTMLElements[mTagID].GetNonAutoCloseEndTags();
if(theTagList) return !theTagList->Contains(aTag);
}
if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_userdefined)) {
CTagList* theTagList=gHTMLElements[mTagID].GetNonAutoCloseEndTags();
if(theTagList) return !theTagList->Contains(aTag);
}
return result;
}

Просмотреть файл

@ -99,7 +99,7 @@ struct nsHTMLElement {
PRBool CanOmitStartTag(eHTMLTags aChild) const;
PRBool CanOmitEndTag(void) const;
PRBool CanContainSelf(void) const;
PRBool CanAutoCloseTag(eHTMLTags aTag, eHTMLTokenTypes aType) const;
PRBool CanAutoCloseTag(eHTMLTags aTag) const;
PRBool HasSpecialProperty(PRInt32 aProperty) const;
PRBool SectionContains(eHTMLTags aTag,PRBool allowDepthSearch);
@ -150,7 +150,6 @@ static const int kNoStyleLeaksIn = 0x0040;
static const int kNoStyleLeaksOut = 0x0080;
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 kDiscardMisplaced = 0x0400; //If set, then the tag, if misplaced, will be ignored.
//*********************************************************************************************
// The following ints define the standard groups of HTML elements...