82500 - Make sure that DidBuildModel gets called only once per document.

79492 - In collecting skipped content make sure that entity-like-markup is not mistaken for an entity.
80009 - PRE should be treated as a block-level element - per spec.
82498 - Do not process script content in a frameset document.
82544 - Beginning/ending quotes in attribute values are now removed by the parser.
77145 - Fix off-by-one error.

r=heikki
sr=vidur
a=asa
This commit is contained in:
harishd%netscape.com 2001-06-18 21:18:37 +00:00
parent bc37219a9a
commit addc8ca065
8 changed files with 58 additions and 42 deletions

View File

@ -228,22 +228,24 @@ class CopyNormalizeNewlines
}
PRUint32 write(const typename OutputIterator::value_type* aSource, PRUint32 aSourceLength) {
const typename OutputIterator::value_type* done_writing = aSource + aSourceLength;
// If the last source buffer ended with a CR...
if (mLastCharCR) {
// ..and if the next one is a LF, then skip it since
// we've already written out a newline
if (aSourceLength && (*aSource == value_type('\n'))) {
aSource++;
++aSource;
}
mLastCharCR = PR_FALSE;
}
const typename OutputIterator::value_type* done_writing = aSource + aSourceLength;
PRUint32 num_written = 0;
while ( aSource < done_writing ) {
if (*aSource == value_type('\r')) {
mDestination->writechar('\n');
aSource++;
++aSource;
// If we've reached the end of the buffer, record
// that we wrote out a CR
if (aSource == done_writing) {
@ -251,13 +253,13 @@ class CopyNormalizeNewlines
}
// If the next character is a LF, skip it
else if (*aSource == value_type('\n')) {
aSource++;
++aSource;
}
}
else {
mDestination->writechar(*aSource++);
}
num_written++;
++num_written;
}
mWritten += num_written;

View File

@ -565,22 +565,6 @@ HTMLContentSink::GetAttributeValueAt(const nsIParserNode& aNode,
aResult.Truncate();
aResult.Append(value);
aResult.Trim("\b\r\t\n",PR_TRUE,PR_TRUE,PR_TRUE);
if ( !aResult.IsEmpty() ) {
// Strip quotes if present
PRUnichar first = aResult.First();
if ((first == '\"') || (first == '\'')) {
if (aResult.Last() == first) {
aResult.Cut(0, 1);
PRInt32 pos = aResult.Length() - 1;
if (pos >= 0) {
aResult.Cut(pos, 1);
}
} else {
// Mismatched quotes - leave them in
}
}
}
}
nsresult
@ -4602,30 +4586,50 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
}
}
// Don't include script loading and evaluation in the stopwatch
// that is measuring content creation time
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::ProcessSCRIPTTag()\n"));
MOZ_TIMER_STOP(mWatch);
nsCOMPtr<nsIScriptLoader> loader;
if(mFrameset) {
// Fix bug 82498
// We don't want to evaluate scripts in a frameset document.
if (mDocument) {
mDocument->GetScriptLoader(getter_AddRefs(loader));
if (loader) {
loader->Suspend();
}
}
}
else {
// Don't include script loading and evaluation in the stopwatch
// that is measuring content creation time
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::ProcessSCRIPTTag()\n"));
MOZ_TIMER_STOP(mWatch);
// Assume that we're going to block the parser with a script load.
// If it's an inline script, we'll be told otherwise in the call
// to our ScriptAvailable method.
mNeedToBlockParser = PR_TRUE;
// Assume that we're going to block the parser with a script load.
// If it's an inline script, we'll be told otherwise in the call
// to our ScriptAvailable method.
mNeedToBlockParser = PR_TRUE;
nsCOMPtr<nsIDOMHTMLScriptElement> scriptElement(do_QueryInterface(element));
mScriptElements.AppendElement(scriptElement);
nsCOMPtr<nsIDOMHTMLScriptElement> scriptElement(do_QueryInterface(element));
mScriptElements.AppendElement(scriptElement);
}
// Insert the child into the content tree. This will evaluate the
// script as well.
if (mCurrentContext->mStack[mCurrentContext->mStackPos-1].mInsertionPoint != -1) {
parent->InsertChildAt(element,
mCurrentContext->mStack[mCurrentContext->mStackPos-1].mInsertionPoint++,
PR_FALSE, PR_FALSE);
parent->InsertChildAt(element,
mCurrentContext->mStack[mCurrentContext->mStackPos-1].mInsertionPoint++,
PR_FALSE, PR_FALSE);
}
else {
parent->AppendChildTo(element, PR_FALSE, PR_FALSE);
}
// To prevent script evaluation, in a frameset document, we
// suspended the script loader. Now that the script content
// has been handled let's resume the script loader.
if(loader) {
loader->Resume();
}
// If the act of insertion evaluated the script, we're fine.
// Else, block the parser till the script has loaded.
if (mNeedToBlockParser) {

View File

@ -2432,10 +2432,15 @@ nsresult CNavDTD::CollectSkippedContent(nsIParserNode& aNode,PRInt32 &aCount) {
// since this is an entity, we know that it's only one character.
// check to see if it's a CR, in which case we'll need to do line
// termination conversion at the end.
if(mScratch.Length()>0){
if(!mScratch.IsEmpty()){
aMustConvertLinebreaks |= (mScratch[0] == kCR);
theNode->mSkippedContent->Append(mScratch);
}
else {
// We thought it was an entity but it is not! - bug 79492
theNode->mSkippedContent->Append(PRUnichar('&'));
theNode->mSkippedContent->Append(theNextToken->GetStringValue());
}
}
else theNextToken->AppendSource(*theNode->mSkippedContent);
}

View File

@ -954,7 +954,7 @@ 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*/ kInlineEntity|kPreformatted, (kSelf|kFlowEntity), kNone, //I'm allowing WAY too much in here. Spec says inline.
/*parent,incl,exclgroups*/ kBlock|kPreformatted, (kSelf|kFlowEntity), kNone, // Note: PRE is a block level element - bug 80009
/*special props, prop-range*/ 0, kDefaultPropRange,
/*special parents,kids,skip*/ 0,&gPreKids,eHTMLTag_unknown);

View File

@ -1887,10 +1887,10 @@ nsresult nsParser::ResumeParse(PRBool allowIteration, PRBool aIsFinalChunk) {
}
else if (NS_ERROR_HTMLPARSER_STOPPARSING==result) {
mInternalState=result;
// Note: Parser Terminate() calls DidBuildModel.
if(NS_ERROR_HTMLPARSER_STOPPARSING!=theTokenizerResult) {
if(mInternalState!=NS_ERROR_HTMLPARSER_STOPPARSING) {
DidBuildModel(mStreamStatus);
mInternalState = result;
}
break;
}

View File

@ -2432,10 +2432,15 @@ nsresult CNavDTD::CollectSkippedContent(nsIParserNode& aNode,PRInt32 &aCount) {
// since this is an entity, we know that it's only one character.
// check to see if it's a CR, in which case we'll need to do line
// termination conversion at the end.
if(mScratch.Length()>0){
if(!mScratch.IsEmpty()){
aMustConvertLinebreaks |= (mScratch[0] == kCR);
theNode->mSkippedContent->Append(mScratch);
}
else {
// We thought it was an entity but it is not! - bug 79492
theNode->mSkippedContent->Append(PRUnichar('&'));
theNode->mSkippedContent->Append(theNextToken->GetStringValue());
}
}
else theNextToken->AppendSource(*theNode->mSkippedContent);
}

View File

@ -954,7 +954,7 @@ 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*/ kInlineEntity|kPreformatted, (kSelf|kFlowEntity), kNone, //I'm allowing WAY too much in here. Spec says inline.
/*parent,incl,exclgroups*/ kBlock|kPreformatted, (kSelf|kFlowEntity), kNone, // Note: PRE is a block level element - bug 80009
/*special props, prop-range*/ 0, kDefaultPropRange,
/*special parents,kids,skip*/ 0,&gPreKids,eHTMLTag_unknown);

View File

@ -1887,10 +1887,10 @@ nsresult nsParser::ResumeParse(PRBool allowIteration, PRBool aIsFinalChunk) {
}
else if (NS_ERROR_HTMLPARSER_STOPPARSING==result) {
mInternalState=result;
// Note: Parser Terminate() calls DidBuildModel.
if(NS_ERROR_HTMLPARSER_STOPPARSING!=theTokenizerResult) {
if(mInternalState!=NS_ERROR_HTMLPARSER_STOPPARSING) {
DidBuildModel(mStreamStatus);
mInternalState = result;
}
break;
}