зеркало из https://github.com/mozilla/pjs.git
fixed pdt bugs 28208 and 3944; r=harishd, a=jar
This commit is contained in:
Родитель
5f1afe8d16
Коммит
97565dc60c
|
@ -710,7 +710,8 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){
|
|||
//If the child belongs in the head, then handle it (which may open the head);
|
||||
//otherwise, push it onto the misplaced stack.
|
||||
|
||||
PRBool theChildBelongsInHead=gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag);
|
||||
PRBool theExclusive=PR_FALSE;
|
||||
PRBool theChildBelongsInHead=gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag,theExclusive);
|
||||
if(!theChildBelongsInHead) {
|
||||
|
||||
//If you're here then we found a child of the body that was out of place.
|
||||
|
@ -742,7 +743,8 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){
|
|||
// placed. This would avoid unnecessary node creation and
|
||||
// extra string append. BTW, watch out in handling the head
|
||||
// children ( especially the TITLE tag).
|
||||
if(!gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag)) {
|
||||
PRBool theExclusive=PR_FALSE;
|
||||
if(!gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag,theExclusive)) {
|
||||
eHTMLTags theParentTag = mBodyContext->Last();
|
||||
PRBool theParentContains = -1;
|
||||
if(CanOmit(theParentTag,theTag,theParentContains)) {
|
||||
|
@ -1161,15 +1163,14 @@ 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(!isHeadChild){
|
||||
PRBool theExclusive=PR_FALSE;
|
||||
if(!gHTMLElements[eHTMLTag_head].IsChildOfHead(aTag,theExclusive)){
|
||||
|
||||
//because this code calls CloseHead() directly, stack-based token/nodes are ok.
|
||||
CEndToken theToken(eHTMLTag_head);
|
||||
|
@ -1345,7 +1346,8 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
|
|||
}
|
||||
|
||||
mLineNumber += aToken->mNewlineCount;
|
||||
theHeadIsParent=nsHTMLElement::IsChildOfHead(theChildTag);
|
||||
PRBool theExclusive=PR_FALSE;
|
||||
theHeadIsParent=nsHTMLElement::IsChildOfHead(theChildTag,theExclusive);
|
||||
|
||||
switch(theChildTag) {
|
||||
case eHTMLTag_newline:
|
||||
|
@ -1383,6 +1385,17 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
|
|||
break;
|
||||
}//switch
|
||||
|
||||
#if 0
|
||||
//we'll move to this approach after beta...
|
||||
if(!isTokenHandled) {
|
||||
|
||||
if(theHeadIsParent && (theExclusive || mHasOpenHead)) {
|
||||
result=AddHeadLeaf(theNode);
|
||||
}
|
||||
else result=HandleDefaultStartToken(aToken,theChildTag,theNode);
|
||||
}
|
||||
#else
|
||||
//the old way...
|
||||
if(!isTokenHandled) {
|
||||
if(theHeadIsParent ||
|
||||
(mHasOpenHead && ((eHTMLTag_newline==theChildTag) || (eHTMLTag_whitespace==theChildTag)))) {
|
||||
|
@ -1390,6 +1403,7 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
|
|||
}
|
||||
else result=HandleDefaultStartToken(aToken,theChildTag,theNode);
|
||||
}
|
||||
#endif
|
||||
//now do any post processing necessary on the tag...
|
||||
if(NS_OK==result)
|
||||
DidHandleStartTag(*theNode,theChildTag);
|
||||
|
@ -3095,6 +3109,9 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aC
|
|||
theChildStyleStack->PushFront(theNode);
|
||||
}
|
||||
}
|
||||
else if(1==theNode->mUseCount) {
|
||||
theNode->mUseCount--; //cause it to get popped from style stack.
|
||||
}
|
||||
mBodyContext->PushStyles(theChildStyleStack);
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -802,7 +802,8 @@ nsresult COtherDTD::HandleToken(CToken* aToken,nsIParser* aParser){
|
|||
//If the child belongs in the head, then handle it (which may open the head);
|
||||
//otherwise, push it onto the misplaced stack.
|
||||
|
||||
PRBool theChildBelongsInHead=gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag);
|
||||
PRBool theExclusive=PR_FALSE;
|
||||
PRBool theChildBelongsInHead=gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag,theExclusive);
|
||||
if(!theChildBelongsInHead) {
|
||||
|
||||
//If you're here then we found a child of the body that was out of place.
|
||||
|
@ -829,7 +830,9 @@ nsresult COtherDTD::HandleToken(CToken* aToken,nsIParser* aParser){
|
|||
// placed. This would avoid unnecessary node creation and
|
||||
// extra string append. BTW, watch out in handling the head
|
||||
// children ( especially the TITLE tag).
|
||||
if(!gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag)) {
|
||||
|
||||
PRBool theExclusive=PR_FALSE;
|
||||
if(!gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag,theExclusive)) {
|
||||
eHTMLTags theParentTag = mBodyContext->Last();
|
||||
PRBool theParentContains = -1;
|
||||
if(CanOmit(theParentTag,theTag,theParentContains)) {
|
||||
|
@ -1242,7 +1245,8 @@ nsresult COtherDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsCParserNo
|
|||
result=gHTMLElements[aTag].HasSpecialProperty(kDiscardTag) ? 1 : NS_OK;
|
||||
}
|
||||
|
||||
PRBool isHeadChild=gHTMLElements[eHTMLTag_head].IsChildOfHead(aTag);
|
||||
PRBool theExclusive=PR_FALSE;
|
||||
PRBool isHeadChild=gHTMLElements[eHTMLTag_head].IsChildOfHead(aTag,theExclusive);
|
||||
|
||||
//this code is here to make sure the head is closed before we deal
|
||||
//with any tags that don't belong in the head.
|
||||
|
@ -1425,7 +1429,8 @@ nsresult COtherDTD::HandleStartToken(CToken* aToken) {
|
|||
}
|
||||
|
||||
mLineNumber += aToken->mNewlineCount;
|
||||
theHeadIsParent=nsHTMLElement::IsChildOfHead(theChildTag);
|
||||
PRBool theExclusive=PR_FALSE;
|
||||
theHeadIsParent=nsHTMLElement::IsChildOfHead(theChildTag,theExclusive);
|
||||
|
||||
switch(theChildTag) {
|
||||
case eHTMLTag_newline:
|
||||
|
@ -1465,7 +1470,7 @@ nsresult COtherDTD::HandleStartToken(CToken* aToken) {
|
|||
}//switch
|
||||
|
||||
if(!isTokenHandled) {
|
||||
if(theHeadIsParent ||
|
||||
if((theHeadIsParent && theExclusive) ||
|
||||
(mHasOpenHead && ((eHTMLTag_newline==theChildTag) || (eHTMLTag_whitespace==theChildTag)))) {
|
||||
result=AddHeadLeaf(theNode);
|
||||
}
|
||||
|
|
|
@ -309,9 +309,9 @@ void InitializeElementTable(void) {
|
|||
/*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
|
||||
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
|
||||
/*autoclose starttags and endtags*/ 0,0,0,0,
|
||||
/*parent,incl,exclgroups*/ kExtensions, kNone, kNone,
|
||||
/*parent,incl,exclgroups*/ kBlock, kNone, kNone,
|
||||
/*special props, prop-range*/ 0,kNoPropRange,
|
||||
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown);
|
||||
/*special parents,kids,skip*/ &gInHead,0,eHTMLTag_unknown);
|
||||
|
||||
Initialize(
|
||||
/*tag*/ eHTMLTag_big,
|
||||
|
@ -1579,12 +1579,44 @@ PRBool nsHTMLElement::CanOmitStartTag(eHTMLTags aChild) const{
|
|||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRBool nsHTMLElement::IsChildOfHead(eHTMLTags aChild) {
|
||||
PRBool result=FindTagInSet(aChild,gHeadKids.mTags,gHeadKids.mCount);
|
||||
PRBool nsHTMLElement::IsChildOfHead(eHTMLTags aChild,PRBool& aExclusively) {
|
||||
#if 0
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
aExclusively=PR_FALSE;
|
||||
|
||||
switch(aChild) {
|
||||
|
||||
case eHTMLTag_base:
|
||||
case eHTMLTag_link:
|
||||
case eHTMLTag_meta:
|
||||
case eHTMLTag_title:
|
||||
case eHTMLTag_style:
|
||||
aExclusively=result=PR_TRUE;
|
||||
break;
|
||||
|
||||
case eHTMLTag_bgsound:
|
||||
case eHTMLTag_script:
|
||||
case eHTMLTag_noembed:
|
||||
case eHTMLTag_noscript:
|
||||
case eHTMLTag_whitespace:
|
||||
case eHTMLTag_newline:
|
||||
case eHTMLTag_comment:
|
||||
result=PR_TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
#else
|
||||
aExclusively=PR_TRUE;
|
||||
return FindTagInSet(aChild,gHeadKids.mTags,gHeadKids.mCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/13/98
|
||||
|
|
|
@ -184,7 +184,7 @@ struct nsHTMLElement {
|
|||
static PRBool IsInlineParent(eHTMLTags aTag);
|
||||
static PRBool IsFlowParent(eHTMLTags aTag);
|
||||
static PRBool IsSectionTag(eHTMLTags aTag);
|
||||
static PRBool IsChildOfHead(eHTMLTags aTag) ;
|
||||
static PRBool IsChildOfHead(eHTMLTags aTag,PRBool& aExclusively) ;
|
||||
|
||||
eHTMLTags mTagID;
|
||||
eHTMLTags mRequiredAncestor;
|
||||
|
|
|
@ -710,7 +710,8 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){
|
|||
//If the child belongs in the head, then handle it (which may open the head);
|
||||
//otherwise, push it onto the misplaced stack.
|
||||
|
||||
PRBool theChildBelongsInHead=gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag);
|
||||
PRBool theExclusive=PR_FALSE;
|
||||
PRBool theChildBelongsInHead=gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag,theExclusive);
|
||||
if(!theChildBelongsInHead) {
|
||||
|
||||
//If you're here then we found a child of the body that was out of place.
|
||||
|
@ -742,7 +743,8 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){
|
|||
// placed. This would avoid unnecessary node creation and
|
||||
// extra string append. BTW, watch out in handling the head
|
||||
// children ( especially the TITLE tag).
|
||||
if(!gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag)) {
|
||||
PRBool theExclusive=PR_FALSE;
|
||||
if(!gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag,theExclusive)) {
|
||||
eHTMLTags theParentTag = mBodyContext->Last();
|
||||
PRBool theParentContains = -1;
|
||||
if(CanOmit(theParentTag,theTag,theParentContains)) {
|
||||
|
@ -1161,15 +1163,14 @@ 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(!isHeadChild){
|
||||
PRBool theExclusive=PR_FALSE;
|
||||
if(!gHTMLElements[eHTMLTag_head].IsChildOfHead(aTag,theExclusive)){
|
||||
|
||||
//because this code calls CloseHead() directly, stack-based token/nodes are ok.
|
||||
CEndToken theToken(eHTMLTag_head);
|
||||
|
@ -1345,7 +1346,8 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
|
|||
}
|
||||
|
||||
mLineNumber += aToken->mNewlineCount;
|
||||
theHeadIsParent=nsHTMLElement::IsChildOfHead(theChildTag);
|
||||
PRBool theExclusive=PR_FALSE;
|
||||
theHeadIsParent=nsHTMLElement::IsChildOfHead(theChildTag,theExclusive);
|
||||
|
||||
switch(theChildTag) {
|
||||
case eHTMLTag_newline:
|
||||
|
@ -1383,6 +1385,17 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
|
|||
break;
|
||||
}//switch
|
||||
|
||||
#if 0
|
||||
//we'll move to this approach after beta...
|
||||
if(!isTokenHandled) {
|
||||
|
||||
if(theHeadIsParent && (theExclusive || mHasOpenHead)) {
|
||||
result=AddHeadLeaf(theNode);
|
||||
}
|
||||
else result=HandleDefaultStartToken(aToken,theChildTag,theNode);
|
||||
}
|
||||
#else
|
||||
//the old way...
|
||||
if(!isTokenHandled) {
|
||||
if(theHeadIsParent ||
|
||||
(mHasOpenHead && ((eHTMLTag_newline==theChildTag) || (eHTMLTag_whitespace==theChildTag)))) {
|
||||
|
@ -1390,6 +1403,7 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
|
|||
}
|
||||
else result=HandleDefaultStartToken(aToken,theChildTag,theNode);
|
||||
}
|
||||
#endif
|
||||
//now do any post processing necessary on the tag...
|
||||
if(NS_OK==result)
|
||||
DidHandleStartTag(*theNode,theChildTag);
|
||||
|
@ -3095,6 +3109,9 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aC
|
|||
theChildStyleStack->PushFront(theNode);
|
||||
}
|
||||
}
|
||||
else if(1==theNode->mUseCount) {
|
||||
theNode->mUseCount--; //cause it to get popped from style stack.
|
||||
}
|
||||
mBodyContext->PushStyles(theChildStyleStack);
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -802,7 +802,8 @@ nsresult COtherDTD::HandleToken(CToken* aToken,nsIParser* aParser){
|
|||
//If the child belongs in the head, then handle it (which may open the head);
|
||||
//otherwise, push it onto the misplaced stack.
|
||||
|
||||
PRBool theChildBelongsInHead=gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag);
|
||||
PRBool theExclusive=PR_FALSE;
|
||||
PRBool theChildBelongsInHead=gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag,theExclusive);
|
||||
if(!theChildBelongsInHead) {
|
||||
|
||||
//If you're here then we found a child of the body that was out of place.
|
||||
|
@ -829,7 +830,9 @@ nsresult COtherDTD::HandleToken(CToken* aToken,nsIParser* aParser){
|
|||
// placed. This would avoid unnecessary node creation and
|
||||
// extra string append. BTW, watch out in handling the head
|
||||
// children ( especially the TITLE tag).
|
||||
if(!gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag)) {
|
||||
|
||||
PRBool theExclusive=PR_FALSE;
|
||||
if(!gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag,theExclusive)) {
|
||||
eHTMLTags theParentTag = mBodyContext->Last();
|
||||
PRBool theParentContains = -1;
|
||||
if(CanOmit(theParentTag,theTag,theParentContains)) {
|
||||
|
@ -1242,7 +1245,8 @@ nsresult COtherDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsCParserNo
|
|||
result=gHTMLElements[aTag].HasSpecialProperty(kDiscardTag) ? 1 : NS_OK;
|
||||
}
|
||||
|
||||
PRBool isHeadChild=gHTMLElements[eHTMLTag_head].IsChildOfHead(aTag);
|
||||
PRBool theExclusive=PR_FALSE;
|
||||
PRBool isHeadChild=gHTMLElements[eHTMLTag_head].IsChildOfHead(aTag,theExclusive);
|
||||
|
||||
//this code is here to make sure the head is closed before we deal
|
||||
//with any tags that don't belong in the head.
|
||||
|
@ -1425,7 +1429,8 @@ nsresult COtherDTD::HandleStartToken(CToken* aToken) {
|
|||
}
|
||||
|
||||
mLineNumber += aToken->mNewlineCount;
|
||||
theHeadIsParent=nsHTMLElement::IsChildOfHead(theChildTag);
|
||||
PRBool theExclusive=PR_FALSE;
|
||||
theHeadIsParent=nsHTMLElement::IsChildOfHead(theChildTag,theExclusive);
|
||||
|
||||
switch(theChildTag) {
|
||||
case eHTMLTag_newline:
|
||||
|
@ -1465,7 +1470,7 @@ nsresult COtherDTD::HandleStartToken(CToken* aToken) {
|
|||
}//switch
|
||||
|
||||
if(!isTokenHandled) {
|
||||
if(theHeadIsParent ||
|
||||
if((theHeadIsParent && theExclusive) ||
|
||||
(mHasOpenHead && ((eHTMLTag_newline==theChildTag) || (eHTMLTag_whitespace==theChildTag)))) {
|
||||
result=AddHeadLeaf(theNode);
|
||||
}
|
||||
|
|
|
@ -309,9 +309,9 @@ void InitializeElementTable(void) {
|
|||
/*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
|
||||
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
|
||||
/*autoclose starttags and endtags*/ 0,0,0,0,
|
||||
/*parent,incl,exclgroups*/ kExtensions, kNone, kNone,
|
||||
/*parent,incl,exclgroups*/ kBlock, kNone, kNone,
|
||||
/*special props, prop-range*/ 0,kNoPropRange,
|
||||
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown);
|
||||
/*special parents,kids,skip*/ &gInHead,0,eHTMLTag_unknown);
|
||||
|
||||
Initialize(
|
||||
/*tag*/ eHTMLTag_big,
|
||||
|
@ -1579,12 +1579,44 @@ PRBool nsHTMLElement::CanOmitStartTag(eHTMLTags aChild) const{
|
|||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRBool nsHTMLElement::IsChildOfHead(eHTMLTags aChild) {
|
||||
PRBool result=FindTagInSet(aChild,gHeadKids.mTags,gHeadKids.mCount);
|
||||
PRBool nsHTMLElement::IsChildOfHead(eHTMLTags aChild,PRBool& aExclusively) {
|
||||
#if 0
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
aExclusively=PR_FALSE;
|
||||
|
||||
switch(aChild) {
|
||||
|
||||
case eHTMLTag_base:
|
||||
case eHTMLTag_link:
|
||||
case eHTMLTag_meta:
|
||||
case eHTMLTag_title:
|
||||
case eHTMLTag_style:
|
||||
aExclusively=result=PR_TRUE;
|
||||
break;
|
||||
|
||||
case eHTMLTag_bgsound:
|
||||
case eHTMLTag_script:
|
||||
case eHTMLTag_noembed:
|
||||
case eHTMLTag_noscript:
|
||||
case eHTMLTag_whitespace:
|
||||
case eHTMLTag_newline:
|
||||
case eHTMLTag_comment:
|
||||
result=PR_TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
#else
|
||||
aExclusively=PR_TRUE;
|
||||
return FindTagInSet(aChild,gHeadKids.mTags,gHeadKids.mCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess12/13/98
|
||||
|
|
|
@ -184,7 +184,7 @@ struct nsHTMLElement {
|
|||
static PRBool IsInlineParent(eHTMLTags aTag);
|
||||
static PRBool IsFlowParent(eHTMLTags aTag);
|
||||
static PRBool IsSectionTag(eHTMLTags aTag);
|
||||
static PRBool IsChildOfHead(eHTMLTags aTag) ;
|
||||
static PRBool IsChildOfHead(eHTMLTags aTag,PRBool& aExclusively) ;
|
||||
|
||||
eHTMLTags mTagID;
|
||||
eHTMLTags mRequiredAncestor;
|
||||
|
|
Загрузка…
Ссылка в новой задаче