26583,2946, 22636 (partial),32782
33570,27136,24184,35125,
35806,36063,29456
r=rickg,waqar
34311 - Patch provided by Patrick ( Fix for MLK ).
r=me.
This commit is contained in:
harishd%netscape.com 2000-04-21 21:22:03 +00:00
parent bb86f0f2f9
commit 3bbedd8709
16 changed files with 248 additions and 140 deletions

View File

@ -957,33 +957,37 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI
}
if(theChildAgrees && theChildIsContainer) {
if (!nsHTMLElement::IsResidualStyleTag(aChildTag)) {
if(theParentTag!=aChildTag) {
//trying is blockcloser to widen the set of elements that this effects, re: bug 27865...
if(nsHTMLElement::IsBlockCloser(theParentTag)) {
PRInt32 theChildIndex=GetIndexOfChildOrSynonym(*mBodyContext,aChildTag);
if((kNotFound<theChildIndex) && (theChildIndex<theIndex)) {
/*-------------------------------------------------------------------------------------
1. Here's a tricky case from bug 22596: <h5><li><h5>
How do we know that the 2nd <h5> should close the <LI> rather than nest inside the <LI>?
(Afterall, the <h5> is a legal child of the <LI>).
The way you know is that there is no root between the two, so the <h5> binds more
tightly to the 1st <h5> than to the <LI>.
2. Also, bug 6148 shows this case: <SPAN><DIV><SPAN>
From this case we learned not to execute this logic if the parent is a block.
-------------------------------------------------------------------------------------*/
theChildAgrees=CanBeContained(aChildTag,*mBodyContext);
} //if
}//if
}
if(theParentTag!=aChildTag) {
// Double check the power structure a
// Note: The bit is currently set on <A> and <LI>.
if(gHTMLElements[theParentTag].ShouldVerifyHierarchy(aChildTag)){
PRInt32 theChildIndex=GetIndexOfChildOrSynonym(*mBodyContext,aChildTag);
if((kNotFound<theChildIndex) && (theChildIndex<theIndex)) {
/*-------------------------------------------------------------------------------------
1 Here's a tricky case from bug 22596: <h5><li><h5>
How do we know that the 2nd <h5> should close the <LI> rather than nest inside the <LI>?
(Afterall, the <h5> is a legal child of the <LI>).
The way you know is that there is no root between the two, so the <h5> binds more
tightly to the 1st <h5> than to the <LI>.
2. Also, bug 6148 shows this case: <SPAN><DIV><SPAN>
From this case we learned not to execute this logic if the parent is a block.
3. Fix for 26583
Ex. <A href=foo.html><B>foo<A href-bar.html>bar</A></B></A> <-- A legal HTML
In the above example clicking on "foo" or "bar" should link to
foo.html or bar.html respectively. That is, the inner <A> should be informed
about the presence of an open <A> above <B>..so that the inner <A> can close out
the outer <A>. The following code does it for us.
4. Fix for 27865 [ similer to 22596 ]. Ex: <DL><DD><LI>one<DD><LI>two
-------------------------------------------------------------------------------------*/
theChildAgrees=CanBeContained(aChildTag,*mBodyContext);
} //if
}//if
} //if
} //if
} //if parentcontains
@ -1549,9 +1553,9 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) {
//This is special NAV-QUIRKS code that allows users
//to use </BR>, even though that isn't a legitimate tag.
if(eParseMode_quirks==mParseMode) {
CStartToken theToken(theChildTag); //leave this on the stack; no recycling necessary.
theToken.mUseCount=1;
result=HandleStartToken(&theToken);
// Use recycler and pass the token thro' HandleToken() to fix bugs like 32782.
CHTMLToken* theToken = (CHTMLToken*)mTokenRecycler->CreateTokenOfType(eToken_start,theChildTag);
result=HandleToken(theToken,mParser);
}
}
break;

View File

@ -1180,7 +1180,7 @@ void CObserverService::RegisterObservers(const nsString& aTopic) {
nsServiceManager::ReleaseService(NS_OBSERVERSERVICE_PROGID, theObserverService);
if(result == NS_OK) {
nsIElementObserver *theElementObserver = nsnull;
nsCOMPtr<nsIElementObserver> theElementObserver;
nsISupports *inst = nsnull;
nsObserverTopic *theTopic=0;
@ -1188,7 +1188,7 @@ void CObserverService::RegisterObservers(const nsString& aTopic) {
for (theEnum->First(); theEnum->IsDone() != NS_OK; theEnum->Next()) {
result = theEnum->CurrentItem(&inst);
if (NS_SUCCEEDED(result)) {
result = inst->QueryInterface(NS_GET_IID(nsIElementObserver), (void**)&theElementObserver);
theElementObserver = do_QueryInterface(inst, &result);
NS_RELEASE(inst);
}
if (result == NS_OK) {

View File

@ -219,7 +219,7 @@ void InitializeElementTable(void) {
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,0,
/*parent,incl,exclgroups*/ kSpecial, kInlineEntity, kNone,
/*special props, prop-range*/ 0,kDefaultPropRange,
/*special props, prop-range*/ kVerifyHierarchy,kDefaultPropRange,
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown);
Initialize(
@ -760,7 +760,7 @@ void InitializeElementTable(void) {
/*rootnodes,endrootnodes*/ &gLIRootTags,&gLIRootTags,
/*autoclose starttags and endtags*/ &gLIAutoClose,0,0,0,
/*parent,incl,exclgroups*/ kBlock, kFlowEntity, kSelf, //changed this from blockentity to block during RS cleanup
/*special props, prop-range*/ kNoPropagate, kDefaultPropRange,
/*special props, prop-range*/ kNoPropagate|kVerifyHierarchy, kDefaultPropRange,
/*special parents,kids,skip*/ 0,&gLIKids,eHTMLTag_unknown);
Initialize(
@ -891,11 +891,11 @@ void InitializeElementTable(void) {
Initialize(
/*tag*/ eHTMLTag_option,
/*requiredAncestor*/ eHTMLTag_unknown,eHTMLTag_unknown,
/*requiredAncestor*/ eHTMLTag_select,eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gOptgroupParents,&gOptgroupParents,
/*autoclose starttags and endtags*/ 0,0,0,0,
/*parent,incl,exclgroups*/ kNone, kPCDATA, kFlowEntity,
/*special props, prop-range*/ kNoStyleLeaksIn, kDefaultPropRange,
/*special props, prop-range*/ kNoStyleLeaksIn|kNoPropagate, kDefaultPropRange,
/*special parents,kids,skip*/ &gOptgroupParents,&gContainsText,eHTMLTag_unknown);
Initialize(
@ -1678,6 +1678,32 @@ PRBool nsHTMLElement::SectionContains(eHTMLTags aChild,PRBool allowDepthSearch)
return result;
}
/**
* This method should be called to determine if the a tags
* hierarchy needs to be validated.
*
* @update harishd 04/19/00
* @param
* @return
*/
PRBool nsHTMLElement::ShouldVerifyHierarchy(eHTMLTags aChildTag) {
PRBool result=PR_FALSE;
// If the tag cannot contain itself then we need to make sure that
// anywhere in the hierarchy we don't nest accidently.
// Ex: <H1><LI><H1><LI>. Inner LI has the potential of getting nested
// inside outer LI.If the tag can contain self, Ex: <A><B><A>,
// ( B can contain self )then ask the child (<A>) if it requires a containment check.
if(aChildTag!=eHTMLTag_userdefined) {
if(CanContainSelf()) {
result=gHTMLElements[aChildTag].HasSpecialProperty(kVerifyHierarchy);
}
else result=PR_TRUE;
}
return result;
}
/**
*
* @update gess12/13/98

View File

@ -173,6 +173,7 @@ struct nsHTMLElement {
PRBool IsSpecialParent(eHTMLTags aTag) const;
PRBool IsExcludableParent(eHTMLTags aParent) const;
PRBool SectionContains(eHTMLTags aTag,PRBool allowDepthSearch);
PRBool ShouldVerifyHierarchy(eHTMLTags achildTag);
static PRBool CanContain(eHTMLTags aParent,eHTMLTags aChild);
static PRBool IsContainer(eHTMLTags aTag) ;
@ -224,6 +225,6 @@ static const int kSaveMisplaced = 0x0200; //If set, then children this tag ca
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.
static const int kVerifyHierarchy = 0x2000; //If set, check to see if the tag is a child or a sibling..
#endif

View File

@ -551,7 +551,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan
nsAutoString endTag(nsHTMLTags::GetStringValue(theTag));
endTag.InsertWithConversion("</",0,2);
CToken* textToken=theRecycler->CreateTokenOfType(eToken_text,theTag);
result=((CTextToken*)textToken)->ConsumeUntil(0,PR_FALSE,aScanner,endTag,mParseMode,aFlushTokens); //tell new token to finish consuming text...
result=((CTextToken*)textToken)->ConsumeUntil(0,PRBool(theTag!=eHTMLTag_script),aScanner,endTag,mParseMode,aFlushTokens); //tell new token to finish consuming text...
//endTag.Append(">");
CToken* endToken=theRecycler->CreateTokenOfType(eToken_end,theTag,endTag);
AddToken(textToken,result,&mTokenDeque,theRecycler);

View File

@ -614,20 +614,22 @@ nsresult CTextToken::ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScann
}
//theTermStrPos=theBuffer.Find(aTerminalString,PR_TRUE,theCurrOffset);
if(theTermStrPos>kNotFound) {
if(aMode!=eParseMode_noquirks && !theLastIteration && !aIgnoreComments) {
theCurrOffset=theBuffer.Find("<!--",PR_TRUE,theCurrOffset,5);
if(theStartCommentPos==kNotFound && theCurrOffset>kNotFound) {
theStartCommentPos=theCurrOffset;
}
if(theStartCommentPos>kNotFound) {
// Search for --> between <!-- and </TERMINALSTRING>.
theCurrOffset=theBuffer.RFind("-->",PR_TRUE,theTermStrPos,theTermStrPos-theStartCommentPos);
if(theCurrOffset==kNotFound) {
// If you're here it means that we have a bogus terminal string.
theAltTermStrPos=(theAltTermStrPos>-1)? theAltTermStrPos:theTermStrPos; // This could be helpful in case we hit the rock bottom.
theCurrOffset=theTermStrPos+termStrLen; // We did not find '-->' so keep searching for terminal string.
continue;
}
if(aMode!=eParseMode_noquirks && !theLastIteration) {
if(!aIgnoreComments) {
theCurrOffset=theBuffer.Find("<!--",PR_TRUE,theCurrOffset,5);
if(theStartCommentPos==kNotFound && theCurrOffset>kNotFound) {
theStartCommentPos=theCurrOffset;
}
if(theStartCommentPos>kNotFound) {
// Search for --> between <!-- and </TERMINALSTRING>.
theCurrOffset=theBuffer.RFind("-->",PR_TRUE,theTermStrPos,theTermStrPos-theStartCommentPos);
if(theCurrOffset==kNotFound) {
// If you're here it means that we have a bogus terminal string.
theAltTermStrPos=(theAltTermStrPos>-1)? theAltTermStrPos:theTermStrPos; // This could be helpful in case we hit the rock bottom.
theCurrOffset=theTermStrPos+termStrLen; // We did not find '-->' so keep searching for terminal string.
continue;
}
}
}
PRInt32 thePos=theBuffer.FindChar(kGreaterThan,PR_TRUE,theTermStrPos,20);
@ -1248,6 +1250,8 @@ void CAttributeToken::AppendSource(nsString& anOutputString){
*/
nsresult ConsumeQuotedString(PRUnichar aChar,nsString& aString,nsScanner& aScanner){
nsresult result=NS_OK;
PRInt32 theOffset=aScanner.GetOffset();
switch(aChar) {
case kQuote:
result=aScanner.ReadUntil(aString,kQuote,PR_TRUE);
@ -1262,9 +1266,21 @@ nsresult ConsumeQuotedString(PRUnichar aChar,nsString& aString,nsScanner& aScann
default:
break;
}
// Ref: Bug 35806
// A back up measure when disaster strikes...
// Ex <table> <tr d="><td>hello</td></tr></table>
PRUnichar ch=aString.Last();
if(ch!=aChar)
aString+=aChar;
if(ch!=aChar) {
if(!aScanner.IsIncremental() && result==kEOF) {
aScanner.Mark(theOffset);
aString=aChar;
result=kBadStringLiteral;
}
else {
aString+=aChar;
}
}
return result;
}
@ -1359,6 +1375,9 @@ nsresult CAttributeToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 a
if((kQuote==aChar) || (kApostrophe==aChar)) {
mTextValue.Append(aChar);
result=ConsumeQuotedString(aChar,mTextValue,aScanner);
if(result==kBadStringLiteral) {
result=ConsumeAttributeValueText(aChar,mTextValue,aScanner);
}
if(!aRetainWhitespace)
mTextValue.StripChars("\r\n"); //per the HTML spec, ignore linefeeds...
}

View File

@ -226,22 +226,23 @@ class nsIParser : public nsISupports {
#include "prtypes.h"
#include "nsError.h"
#define NS_ERROR_HTMLPARSER_EOF NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1000)
#define NS_ERROR_HTMLPARSER_UNKNOWN NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1001)
#define NS_ERROR_HTMLPARSER_CANTPROPAGATE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1002)
#define NS_ERROR_HTMLPARSER_CONTEXTMISMATCH NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1003)
#define NS_ERROR_HTMLPARSER_BADFILENAME NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1004)
#define NS_ERROR_HTMLPARSER_BADURL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1005)
#define NS_ERROR_HTMLPARSER_INVALIDPARSERCONTEXT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1006)
#define NS_ERROR_HTMLPARSER_INTERRUPTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1007)
#define NS_ERROR_HTMLPARSER_BLOCK NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1008)
#define NS_ERROR_HTMLPARSER_BADTOKENIZER NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1009)
#define NS_ERROR_HTMLPARSER_BADATTRIBUTE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1010)
#define NS_ERROR_HTMLPARSER_UNRESOLVEDDTD NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1011)
#define NS_ERROR_HTMLPARSER_MISPLACED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1012)
#define NS_ERROR_HTMLPARSER_BADDTD NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1013)
#define NS_ERROR_HTMLPARSER_BADCONTEXT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1014)
#define NS_ERROR_HTMLPARSER_STOPPARSING NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1015)
#define NS_ERROR_HTMLPARSER_EOF NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1000)
#define NS_ERROR_HTMLPARSER_UNKNOWN NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1001)
#define NS_ERROR_HTMLPARSER_CANTPROPAGATE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1002)
#define NS_ERROR_HTMLPARSER_CONTEXTMISMATCH NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1003)
#define NS_ERROR_HTMLPARSER_BADFILENAME NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1004)
#define NS_ERROR_HTMLPARSER_BADURL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1005)
#define NS_ERROR_HTMLPARSER_INVALIDPARSERCONTEXT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1006)
#define NS_ERROR_HTMLPARSER_INTERRUPTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1007)
#define NS_ERROR_HTMLPARSER_BLOCK NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1008)
#define NS_ERROR_HTMLPARSER_BADTOKENIZER NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1009)
#define NS_ERROR_HTMLPARSER_BADATTRIBUTE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1010)
#define NS_ERROR_HTMLPARSER_UNRESOLVEDDTD NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1011)
#define NS_ERROR_HTMLPARSER_MISPLACED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1012)
#define NS_ERROR_HTMLPARSER_BADDTD NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1013)
#define NS_ERROR_HTMLPARSER_BADCONTEXT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1014)
#define NS_ERROR_HTMLPARSER_STOPPARSING NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1015)
#define NS_ERROR_HTMLPARSER_UNTERMINATEDSTRINGLITERAL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1016)
#define NS_ERROR_HTMLPARSER_CONTINUE NS_OK
@ -254,6 +255,7 @@ const PRUint32 kBadFilename = NS_ERROR_HTMLPARSER_BADFILENAME;
const PRUint32 kBadURL = NS_ERROR_HTMLPARSER_BADURL;
const PRUint32 kInvalidParserContext = NS_ERROR_HTMLPARSER_INVALIDPARSERCONTEXT;
const PRUint32 kBlocked = NS_ERROR_HTMLPARSER_BLOCK;
const PRUint32 kBadStringLiteral = NS_ERROR_HTMLPARSER_UNTERMINATEDSTRINGLITERAL;
const PRUnichar kNewLine = '\n';
const PRUnichar kCR = '\r';

View File

@ -898,6 +898,8 @@ aMimeType,PRBool aVerifyEnabled,PRBool aLastCall,eParseMode aMode){
if(pc && theScanner) {
PushContext(*pc);
if(theDTD) theDTD->WillBuildModel(*pc,nsnull); // Fixing UMR - Bug 33570
pc->mMultipart=!aLastCall; //by default
if (pc->mPrevContext) {
pc->mMultipart |= pc->mPrevContext->mMultipart; //if available

View File

@ -957,33 +957,37 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI
}
if(theChildAgrees && theChildIsContainer) {
if (!nsHTMLElement::IsResidualStyleTag(aChildTag)) {
if(theParentTag!=aChildTag) {
//trying is blockcloser to widen the set of elements that this effects, re: bug 27865...
if(nsHTMLElement::IsBlockCloser(theParentTag)) {
PRInt32 theChildIndex=GetIndexOfChildOrSynonym(*mBodyContext,aChildTag);
if((kNotFound<theChildIndex) && (theChildIndex<theIndex)) {
/*-------------------------------------------------------------------------------------
1. Here's a tricky case from bug 22596: <h5><li><h5>
How do we know that the 2nd <h5> should close the <LI> rather than nest inside the <LI>?
(Afterall, the <h5> is a legal child of the <LI>).
The way you know is that there is no root between the two, so the <h5> binds more
tightly to the 1st <h5> than to the <LI>.
2. Also, bug 6148 shows this case: <SPAN><DIV><SPAN>
From this case we learned not to execute this logic if the parent is a block.
-------------------------------------------------------------------------------------*/
theChildAgrees=CanBeContained(aChildTag,*mBodyContext);
} //if
}//if
}
if(theParentTag!=aChildTag) {
// Double check the power structure a
// Note: The bit is currently set on <A> and <LI>.
if(gHTMLElements[theParentTag].ShouldVerifyHierarchy(aChildTag)){
PRInt32 theChildIndex=GetIndexOfChildOrSynonym(*mBodyContext,aChildTag);
if((kNotFound<theChildIndex) && (theChildIndex<theIndex)) {
/*-------------------------------------------------------------------------------------
1 Here's a tricky case from bug 22596: <h5><li><h5>
How do we know that the 2nd <h5> should close the <LI> rather than nest inside the <LI>?
(Afterall, the <h5> is a legal child of the <LI>).
The way you know is that there is no root between the two, so the <h5> binds more
tightly to the 1st <h5> than to the <LI>.
2. Also, bug 6148 shows this case: <SPAN><DIV><SPAN>
From this case we learned not to execute this logic if the parent is a block.
3. Fix for 26583
Ex. <A href=foo.html><B>foo<A href-bar.html>bar</A></B></A> <-- A legal HTML
In the above example clicking on "foo" or "bar" should link to
foo.html or bar.html respectively. That is, the inner <A> should be informed
about the presence of an open <A> above <B>..so that the inner <A> can close out
the outer <A>. The following code does it for us.
4. Fix for 27865 [ similer to 22596 ]. Ex: <DL><DD><LI>one<DD><LI>two
-------------------------------------------------------------------------------------*/
theChildAgrees=CanBeContained(aChildTag,*mBodyContext);
} //if
}//if
} //if
} //if
} //if parentcontains
@ -1549,9 +1553,9 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) {
//This is special NAV-QUIRKS code that allows users
//to use </BR>, even though that isn't a legitimate tag.
if(eParseMode_quirks==mParseMode) {
CStartToken theToken(theChildTag); //leave this on the stack; no recycling necessary.
theToken.mUseCount=1;
result=HandleStartToken(&theToken);
// Use recycler and pass the token thro' HandleToken() to fix bugs like 32782.
CHTMLToken* theToken = (CHTMLToken*)mTokenRecycler->CreateTokenOfType(eToken_start,theChildTag);
result=HandleToken(theToken,mParser);
}
}
break;

View File

@ -1180,7 +1180,7 @@ void CObserverService::RegisterObservers(const nsString& aTopic) {
nsServiceManager::ReleaseService(NS_OBSERVERSERVICE_PROGID, theObserverService);
if(result == NS_OK) {
nsIElementObserver *theElementObserver = nsnull;
nsCOMPtr<nsIElementObserver> theElementObserver;
nsISupports *inst = nsnull;
nsObserverTopic *theTopic=0;
@ -1188,7 +1188,7 @@ void CObserverService::RegisterObservers(const nsString& aTopic) {
for (theEnum->First(); theEnum->IsDone() != NS_OK; theEnum->Next()) {
result = theEnum->CurrentItem(&inst);
if (NS_SUCCEEDED(result)) {
result = inst->QueryInterface(NS_GET_IID(nsIElementObserver), (void**)&theElementObserver);
theElementObserver = do_QueryInterface(inst, &result);
NS_RELEASE(inst);
}
if (result == NS_OK) {

View File

@ -219,7 +219,7 @@ void InitializeElementTable(void) {
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,0,
/*parent,incl,exclgroups*/ kSpecial, kInlineEntity, kNone,
/*special props, prop-range*/ 0,kDefaultPropRange,
/*special props, prop-range*/ kVerifyHierarchy,kDefaultPropRange,
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown);
Initialize(
@ -760,7 +760,7 @@ void InitializeElementTable(void) {
/*rootnodes,endrootnodes*/ &gLIRootTags,&gLIRootTags,
/*autoclose starttags and endtags*/ &gLIAutoClose,0,0,0,
/*parent,incl,exclgroups*/ kBlock, kFlowEntity, kSelf, //changed this from blockentity to block during RS cleanup
/*special props, prop-range*/ kNoPropagate, kDefaultPropRange,
/*special props, prop-range*/ kNoPropagate|kVerifyHierarchy, kDefaultPropRange,
/*special parents,kids,skip*/ 0,&gLIKids,eHTMLTag_unknown);
Initialize(
@ -891,11 +891,11 @@ void InitializeElementTable(void) {
Initialize(
/*tag*/ eHTMLTag_option,
/*requiredAncestor*/ eHTMLTag_unknown,eHTMLTag_unknown,
/*requiredAncestor*/ eHTMLTag_select,eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gOptgroupParents,&gOptgroupParents,
/*autoclose starttags and endtags*/ 0,0,0,0,
/*parent,incl,exclgroups*/ kNone, kPCDATA, kFlowEntity,
/*special props, prop-range*/ kNoStyleLeaksIn, kDefaultPropRange,
/*special props, prop-range*/ kNoStyleLeaksIn|kNoPropagate, kDefaultPropRange,
/*special parents,kids,skip*/ &gOptgroupParents,&gContainsText,eHTMLTag_unknown);
Initialize(
@ -1678,6 +1678,32 @@ PRBool nsHTMLElement::SectionContains(eHTMLTags aChild,PRBool allowDepthSearch)
return result;
}
/**
* This method should be called to determine if the a tags
* hierarchy needs to be validated.
*
* @update harishd 04/19/00
* @param
* @return
*/
PRBool nsHTMLElement::ShouldVerifyHierarchy(eHTMLTags aChildTag) {
PRBool result=PR_FALSE;
// If the tag cannot contain itself then we need to make sure that
// anywhere in the hierarchy we don't nest accidently.
// Ex: <H1><LI><H1><LI>. Inner LI has the potential of getting nested
// inside outer LI.If the tag can contain self, Ex: <A><B><A>,
// ( B can contain self )then ask the child (<A>) if it requires a containment check.
if(aChildTag!=eHTMLTag_userdefined) {
if(CanContainSelf()) {
result=gHTMLElements[aChildTag].HasSpecialProperty(kVerifyHierarchy);
}
else result=PR_TRUE;
}
return result;
}
/**
*
* @update gess12/13/98

View File

@ -173,6 +173,7 @@ struct nsHTMLElement {
PRBool IsSpecialParent(eHTMLTags aTag) const;
PRBool IsExcludableParent(eHTMLTags aParent) const;
PRBool SectionContains(eHTMLTags aTag,PRBool allowDepthSearch);
PRBool ShouldVerifyHierarchy(eHTMLTags achildTag);
static PRBool CanContain(eHTMLTags aParent,eHTMLTags aChild);
static PRBool IsContainer(eHTMLTags aTag) ;
@ -224,6 +225,6 @@ static const int kSaveMisplaced = 0x0200; //If set, then children this tag ca
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.
static const int kVerifyHierarchy = 0x2000; //If set, check to see if the tag is a child or a sibling..
#endif

View File

@ -551,7 +551,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan
nsAutoString endTag(nsHTMLTags::GetStringValue(theTag));
endTag.InsertWithConversion("</",0,2);
CToken* textToken=theRecycler->CreateTokenOfType(eToken_text,theTag);
result=((CTextToken*)textToken)->ConsumeUntil(0,PR_FALSE,aScanner,endTag,mParseMode,aFlushTokens); //tell new token to finish consuming text...
result=((CTextToken*)textToken)->ConsumeUntil(0,PRBool(theTag!=eHTMLTag_script),aScanner,endTag,mParseMode,aFlushTokens); //tell new token to finish consuming text...
//endTag.Append(">");
CToken* endToken=theRecycler->CreateTokenOfType(eToken_end,theTag,endTag);
AddToken(textToken,result,&mTokenDeque,theRecycler);

View File

@ -614,20 +614,22 @@ nsresult CTextToken::ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScann
}
//theTermStrPos=theBuffer.Find(aTerminalString,PR_TRUE,theCurrOffset);
if(theTermStrPos>kNotFound) {
if(aMode!=eParseMode_noquirks && !theLastIteration && !aIgnoreComments) {
theCurrOffset=theBuffer.Find("<!--",PR_TRUE,theCurrOffset,5);
if(theStartCommentPos==kNotFound && theCurrOffset>kNotFound) {
theStartCommentPos=theCurrOffset;
}
if(theStartCommentPos>kNotFound) {
// Search for --> between <!-- and </TERMINALSTRING>.
theCurrOffset=theBuffer.RFind("-->",PR_TRUE,theTermStrPos,theTermStrPos-theStartCommentPos);
if(theCurrOffset==kNotFound) {
// If you're here it means that we have a bogus terminal string.
theAltTermStrPos=(theAltTermStrPos>-1)? theAltTermStrPos:theTermStrPos; // This could be helpful in case we hit the rock bottom.
theCurrOffset=theTermStrPos+termStrLen; // We did not find '-->' so keep searching for terminal string.
continue;
}
if(aMode!=eParseMode_noquirks && !theLastIteration) {
if(!aIgnoreComments) {
theCurrOffset=theBuffer.Find("<!--",PR_TRUE,theCurrOffset,5);
if(theStartCommentPos==kNotFound && theCurrOffset>kNotFound) {
theStartCommentPos=theCurrOffset;
}
if(theStartCommentPos>kNotFound) {
// Search for --> between <!-- and </TERMINALSTRING>.
theCurrOffset=theBuffer.RFind("-->",PR_TRUE,theTermStrPos,theTermStrPos-theStartCommentPos);
if(theCurrOffset==kNotFound) {
// If you're here it means that we have a bogus terminal string.
theAltTermStrPos=(theAltTermStrPos>-1)? theAltTermStrPos:theTermStrPos; // This could be helpful in case we hit the rock bottom.
theCurrOffset=theTermStrPos+termStrLen; // We did not find '-->' so keep searching for terminal string.
continue;
}
}
}
PRInt32 thePos=theBuffer.FindChar(kGreaterThan,PR_TRUE,theTermStrPos,20);
@ -1248,6 +1250,8 @@ void CAttributeToken::AppendSource(nsString& anOutputString){
*/
nsresult ConsumeQuotedString(PRUnichar aChar,nsString& aString,nsScanner& aScanner){
nsresult result=NS_OK;
PRInt32 theOffset=aScanner.GetOffset();
switch(aChar) {
case kQuote:
result=aScanner.ReadUntil(aString,kQuote,PR_TRUE);
@ -1262,9 +1266,21 @@ nsresult ConsumeQuotedString(PRUnichar aChar,nsString& aString,nsScanner& aScann
default:
break;
}
// Ref: Bug 35806
// A back up measure when disaster strikes...
// Ex <table> <tr d="><td>hello</td></tr></table>
PRUnichar ch=aString.Last();
if(ch!=aChar)
aString+=aChar;
if(ch!=aChar) {
if(!aScanner.IsIncremental() && result==kEOF) {
aScanner.Mark(theOffset);
aString=aChar;
result=kBadStringLiteral;
}
else {
aString+=aChar;
}
}
return result;
}
@ -1359,6 +1375,9 @@ nsresult CAttributeToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 a
if((kQuote==aChar) || (kApostrophe==aChar)) {
mTextValue.Append(aChar);
result=ConsumeQuotedString(aChar,mTextValue,aScanner);
if(result==kBadStringLiteral) {
result=ConsumeAttributeValueText(aChar,mTextValue,aScanner);
}
if(!aRetainWhitespace)
mTextValue.StripChars("\r\n"); //per the HTML spec, ignore linefeeds...
}

View File

@ -226,22 +226,23 @@ class nsIParser : public nsISupports {
#include "prtypes.h"
#include "nsError.h"
#define NS_ERROR_HTMLPARSER_EOF NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1000)
#define NS_ERROR_HTMLPARSER_UNKNOWN NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1001)
#define NS_ERROR_HTMLPARSER_CANTPROPAGATE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1002)
#define NS_ERROR_HTMLPARSER_CONTEXTMISMATCH NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1003)
#define NS_ERROR_HTMLPARSER_BADFILENAME NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1004)
#define NS_ERROR_HTMLPARSER_BADURL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1005)
#define NS_ERROR_HTMLPARSER_INVALIDPARSERCONTEXT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1006)
#define NS_ERROR_HTMLPARSER_INTERRUPTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1007)
#define NS_ERROR_HTMLPARSER_BLOCK NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1008)
#define NS_ERROR_HTMLPARSER_BADTOKENIZER NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1009)
#define NS_ERROR_HTMLPARSER_BADATTRIBUTE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1010)
#define NS_ERROR_HTMLPARSER_UNRESOLVEDDTD NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1011)
#define NS_ERROR_HTMLPARSER_MISPLACED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1012)
#define NS_ERROR_HTMLPARSER_BADDTD NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1013)
#define NS_ERROR_HTMLPARSER_BADCONTEXT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1014)
#define NS_ERROR_HTMLPARSER_STOPPARSING NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1015)
#define NS_ERROR_HTMLPARSER_EOF NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1000)
#define NS_ERROR_HTMLPARSER_UNKNOWN NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1001)
#define NS_ERROR_HTMLPARSER_CANTPROPAGATE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1002)
#define NS_ERROR_HTMLPARSER_CONTEXTMISMATCH NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1003)
#define NS_ERROR_HTMLPARSER_BADFILENAME NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1004)
#define NS_ERROR_HTMLPARSER_BADURL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1005)
#define NS_ERROR_HTMLPARSER_INVALIDPARSERCONTEXT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1006)
#define NS_ERROR_HTMLPARSER_INTERRUPTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1007)
#define NS_ERROR_HTMLPARSER_BLOCK NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1008)
#define NS_ERROR_HTMLPARSER_BADTOKENIZER NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1009)
#define NS_ERROR_HTMLPARSER_BADATTRIBUTE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1010)
#define NS_ERROR_HTMLPARSER_UNRESOLVEDDTD NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1011)
#define NS_ERROR_HTMLPARSER_MISPLACED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1012)
#define NS_ERROR_HTMLPARSER_BADDTD NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1013)
#define NS_ERROR_HTMLPARSER_BADCONTEXT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1014)
#define NS_ERROR_HTMLPARSER_STOPPARSING NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1015)
#define NS_ERROR_HTMLPARSER_UNTERMINATEDSTRINGLITERAL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_HTMLPARSER,1016)
#define NS_ERROR_HTMLPARSER_CONTINUE NS_OK
@ -254,6 +255,7 @@ const PRUint32 kBadFilename = NS_ERROR_HTMLPARSER_BADFILENAME;
const PRUint32 kBadURL = NS_ERROR_HTMLPARSER_BADURL;
const PRUint32 kInvalidParserContext = NS_ERROR_HTMLPARSER_INVALIDPARSERCONTEXT;
const PRUint32 kBlocked = NS_ERROR_HTMLPARSER_BLOCK;
const PRUint32 kBadStringLiteral = NS_ERROR_HTMLPARSER_UNTERMINATEDSTRINGLITERAL;
const PRUnichar kNewLine = '\n';
const PRUnichar kCR = '\r';

View File

@ -898,6 +898,8 @@ aMimeType,PRBool aVerifyEnabled,PRBool aLastCall,eParseMode aMode){
if(pc && theScanner) {
PushContext(*pc);
if(theDTD) theDTD->WillBuildModel(*pc,nsnull); // Fixing UMR - Bug 33570
pc->mMultipart=!aLastCall; //by default
if (pc->mPrevContext) {
pc->mMultipart |= pc->mPrevContext->mMultipart; //if available