diff --git a/mozilla/htmlparser/src/CNavDTD.cpp b/mozilla/htmlparser/src/CNavDTD.cpp index aed5c2d17c6..928c3f292b2 100644 --- a/mozilla/htmlparser/src/CNavDTD.cpp +++ b/mozilla/htmlparser/src/CNavDTD.cpp @@ -644,7 +644,7 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){ // printf("token: %p\n",aToken); - if(mSkipTarget){ //handle a preexisting target... + if(mSkipTarget){ //handle a preexisting target... if((theTag==mSkipTarget) && (eToken_end==theType)){ mSkipTarget=eHTMLTag_unknown; //stop skipping. //mTokenizer->PushTokenFront(aToken); //push the end token... @@ -658,7 +658,32 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){ return result; } } + else if(mDTDState==NS_HTMLPARSER_ALTERNATECONTENT) { + if(eHTMLTag_noscript!=theTag || theType!=eToken_end) { + // attribute source is a part of start token. + if(theType!=eToken_attribute) { + aToken->AppendSource(mScratch); + } + IF_FREE(aToken); + return result; + } + else { + // If you're here then we have seen a /noscript. + // After handling the text token intentionally + // fall thro' such that /noscript gets handled. + CTextToken theTextToken(mScratch); + result=HandleStartToken(&theTextToken); + + if(NS_FAILED(result)) { + return result; + } + mScratch.Truncate(); + mScratch.SetCapacity(0); + } + } + + /* --------------------------------------------------------------------------------- This section of code is used to "move" misplaced content from one location in our document model to another. (Consider what would happen if we found a

tag @@ -666,7 +691,7 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){ deque until we can deal with it. --------------------------------------------------------------------------------- */ - if(!execSkipContent && mDTDState!=NS_HTMLPARSER_ALTERNATECONTENT) { + if(!execSkipContent) { switch(theTag) { case eHTMLTag_html: @@ -1224,7 +1249,7 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsCParserNode STOP_TIMER() MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::WillHandleStartTag(), this=%p\n", this)); - if(mParser && mDTDState!=NS_HTMLPARSER_ALTERNATECONTENT) { + if(mParser) { CObserverService* theService=mParser->GetObserverService(); if(theService) { @@ -1661,8 +1686,7 @@ eHTMLTags FindAutoCloseTargetForEndTag(eHTMLTags aCurrentTag,nsDTDContext& aCont PRInt32 theChildIndex=GetIndexOfChildOrSynonym(aContext,aCurrentTag); if(kNotFoundCountChar(kNewLine); return NS_OK; } - + /*********************************************************************************** The preceeding tables determine the set of elements each tag can contain... ***********************************************************************************/ @@ -3186,17 +3210,16 @@ nsresult CNavDTD::OpenNoscript(const nsIParserNode *aNode,nsEntryStack* aStyleSt if(result==NS_HTMLPARSER_ALTERNATECONTENT) { // We're here because the sink has identified that // JS is enabled and therefore noscript content should - // not be treated as a regular content,i.e., make sure - // that head elements are handled correctly and may be - // residual style. - mDTDState=result; - // Though NS_HTMLPARSER_ALTERNATECONTENT is a succeeded message we don't want to propagate it - // because there are lots of places where we don't check for succeeded result instead - // we check for NS_OK. Also, this message is pertinent to the DTD only - result=NS_OK; + // not be treated as a regular content + ++mHasOpenNoXXX; + mScratch.Truncate(); + mScratch.SetCapacity(0); + + mBodyContext->Push(aNode,aStyleStack); + + mDTDState=result; + result=NS_OK; } - mHasOpenNoXXX++; - mBodyContext->Push(aNode,aStyleStack); } } @@ -3758,26 +3781,24 @@ nsresult CNavDTD::AddHeadLeaf(nsIParserNode *aNode){ // within NOSCRIPT and since JS is enanbled we should not process // this content. However, when JS is disabled alternate content // would become regular content. - if(mDTDState!=NS_HTMLPARSER_ALTERNATECONTENT) { - result=OpenHead(aNode); - if(NS_OK==result) { - if(eHTMLTag_title==theTag) { + result=OpenHead(aNode); + if(NS_OK==result) { + if(eHTMLTag_title==theTag) { - const nsString& theString=aNode->GetSkippedContent(); - PRInt32 theLen=theString.Length(); - CBufDescriptor theBD(theString.GetUnicode(), PR_TRUE, theLen+1, theLen); - nsAutoString theString2(theBD); + const nsString& theString=aNode->GetSkippedContent(); + PRInt32 theLen=theString.Length(); + CBufDescriptor theBD(theString.GetUnicode(), PR_TRUE, theLen+1, theLen); + nsAutoString theString2(theBD); - theString2.CompressWhitespace(); + theString2.CompressWhitespace(); + STOP_TIMER() + MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::AddHeadLeaf(), this=%p\n", this)); + mSink->SetTitle(theString2); + MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::AddHeadLeaf(), this=%p\n", this)); + START_TIMER() - STOP_TIMER() - MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::AddHeadLeaf(), this=%p\n", this)); - mSink->SetTitle(theString2); - MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::AddHeadLeaf(), this=%p\n", this)); - START_TIMER() - - } - else result=AddLeaf(aNode); + } + else result=AddLeaf(aNode); // XXX If the return value tells us to block, go // ahead and close the tag out anyway, since its // contents will be consumed. @@ -3792,12 +3813,11 @@ nsresult CNavDTD::AddHeadLeaf(nsIParserNode *aNode){ // the AddLeaf. if (rv != NS_OK) { result = rv; - } } - } - } - else result=AddLeaf(aNode); + } + } } + return result; } diff --git a/mozilla/htmlparser/src/nsElementTable.cpp b/mozilla/htmlparser/src/nsElementTable.cpp index 4a45fec9aa6..a3897c7f47e 100644 --- a/mozilla/htmlparser/src/nsElementTable.cpp +++ b/mozilla/htmlparser/src/nsElementTable.cpp @@ -869,7 +869,7 @@ void InitializeElementTable(void) { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0,0, /*parent,incl,exclgroups*/ kBlock, kFlowEntity|kSelf, kNone, - /*special props, prop-range*/ 0, kNoPropRange, + /*special props, prop-range*/ kLegalOpen, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown); Initialize( diff --git a/mozilla/htmlparser/src/nsHTMLTokenizer.cpp b/mozilla/htmlparser/src/nsHTMLTokenizer.cpp index bae9930fa16..8bfca2430d5 100644 --- a/mozilla/htmlparser/src/nsHTMLTokenizer.cpp +++ b/mozilla/htmlparser/src/nsHTMLTokenizer.cpp @@ -694,7 +694,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan //XXX - Find a better soution to record content //Added _plaintext to fix bug 46054. - if((eHTMLTag_textarea==theTag || eHTMLTag_xmp==theTag || eHTMLTag_plaintext==theTag) && !mRecordTrailingContent) { + if((eHTMLTag_textarea==theTag || eHTMLTag_xmp==theTag || eHTMLTag_plaintext==theTag || eHTMLTag_noscript==theTag) && !mRecordTrailingContent) { mRecordTrailingContent=PR_TRUE; } diff --git a/mozilla/parser/htmlparser/src/CNavDTD.cpp b/mozilla/parser/htmlparser/src/CNavDTD.cpp index aed5c2d17c6..928c3f292b2 100644 --- a/mozilla/parser/htmlparser/src/CNavDTD.cpp +++ b/mozilla/parser/htmlparser/src/CNavDTD.cpp @@ -644,7 +644,7 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){ // printf("token: %p\n",aToken); - if(mSkipTarget){ //handle a preexisting target... + if(mSkipTarget){ //handle a preexisting target... if((theTag==mSkipTarget) && (eToken_end==theType)){ mSkipTarget=eHTMLTag_unknown; //stop skipping. //mTokenizer->PushTokenFront(aToken); //push the end token... @@ -658,7 +658,32 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){ return result; } } + else if(mDTDState==NS_HTMLPARSER_ALTERNATECONTENT) { + if(eHTMLTag_noscript!=theTag || theType!=eToken_end) { + // attribute source is a part of start token. + if(theType!=eToken_attribute) { + aToken->AppendSource(mScratch); + } + IF_FREE(aToken); + return result; + } + else { + // If you're here then we have seen a /noscript. + // After handling the text token intentionally + // fall thro' such that /noscript gets handled. + CTextToken theTextToken(mScratch); + result=HandleStartToken(&theTextToken); + + if(NS_FAILED(result)) { + return result; + } + mScratch.Truncate(); + mScratch.SetCapacity(0); + } + } + + /* --------------------------------------------------------------------------------- This section of code is used to "move" misplaced content from one location in our document model to another. (Consider what would happen if we found a

tag @@ -666,7 +691,7 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){ deque until we can deal with it. --------------------------------------------------------------------------------- */ - if(!execSkipContent && mDTDState!=NS_HTMLPARSER_ALTERNATECONTENT) { + if(!execSkipContent) { switch(theTag) { case eHTMLTag_html: @@ -1224,7 +1249,7 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsCParserNode STOP_TIMER() MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::WillHandleStartTag(), this=%p\n", this)); - if(mParser && mDTDState!=NS_HTMLPARSER_ALTERNATECONTENT) { + if(mParser) { CObserverService* theService=mParser->GetObserverService(); if(theService) { @@ -1661,8 +1686,7 @@ eHTMLTags FindAutoCloseTargetForEndTag(eHTMLTags aCurrentTag,nsDTDContext& aCont PRInt32 theChildIndex=GetIndexOfChildOrSynonym(aContext,aCurrentTag); if(kNotFoundCountChar(kNewLine); return NS_OK; } - + /*********************************************************************************** The preceeding tables determine the set of elements each tag can contain... ***********************************************************************************/ @@ -3186,17 +3210,16 @@ nsresult CNavDTD::OpenNoscript(const nsIParserNode *aNode,nsEntryStack* aStyleSt if(result==NS_HTMLPARSER_ALTERNATECONTENT) { // We're here because the sink has identified that // JS is enabled and therefore noscript content should - // not be treated as a regular content,i.e., make sure - // that head elements are handled correctly and may be - // residual style. - mDTDState=result; - // Though NS_HTMLPARSER_ALTERNATECONTENT is a succeeded message we don't want to propagate it - // because there are lots of places where we don't check for succeeded result instead - // we check for NS_OK. Also, this message is pertinent to the DTD only - result=NS_OK; + // not be treated as a regular content + ++mHasOpenNoXXX; + mScratch.Truncate(); + mScratch.SetCapacity(0); + + mBodyContext->Push(aNode,aStyleStack); + + mDTDState=result; + result=NS_OK; } - mHasOpenNoXXX++; - mBodyContext->Push(aNode,aStyleStack); } } @@ -3758,26 +3781,24 @@ nsresult CNavDTD::AddHeadLeaf(nsIParserNode *aNode){ // within NOSCRIPT and since JS is enanbled we should not process // this content. However, when JS is disabled alternate content // would become regular content. - if(mDTDState!=NS_HTMLPARSER_ALTERNATECONTENT) { - result=OpenHead(aNode); - if(NS_OK==result) { - if(eHTMLTag_title==theTag) { + result=OpenHead(aNode); + if(NS_OK==result) { + if(eHTMLTag_title==theTag) { - const nsString& theString=aNode->GetSkippedContent(); - PRInt32 theLen=theString.Length(); - CBufDescriptor theBD(theString.GetUnicode(), PR_TRUE, theLen+1, theLen); - nsAutoString theString2(theBD); + const nsString& theString=aNode->GetSkippedContent(); + PRInt32 theLen=theString.Length(); + CBufDescriptor theBD(theString.GetUnicode(), PR_TRUE, theLen+1, theLen); + nsAutoString theString2(theBD); - theString2.CompressWhitespace(); + theString2.CompressWhitespace(); + STOP_TIMER() + MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::AddHeadLeaf(), this=%p\n", this)); + mSink->SetTitle(theString2); + MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::AddHeadLeaf(), this=%p\n", this)); + START_TIMER() - STOP_TIMER() - MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::AddHeadLeaf(), this=%p\n", this)); - mSink->SetTitle(theString2); - MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::AddHeadLeaf(), this=%p\n", this)); - START_TIMER() - - } - else result=AddLeaf(aNode); + } + else result=AddLeaf(aNode); // XXX If the return value tells us to block, go // ahead and close the tag out anyway, since its // contents will be consumed. @@ -3792,12 +3813,11 @@ nsresult CNavDTD::AddHeadLeaf(nsIParserNode *aNode){ // the AddLeaf. if (rv != NS_OK) { result = rv; - } } - } - } - else result=AddLeaf(aNode); + } + } } + return result; } diff --git a/mozilla/parser/htmlparser/src/nsElementTable.cpp b/mozilla/parser/htmlparser/src/nsElementTable.cpp index 4a45fec9aa6..a3897c7f47e 100644 --- a/mozilla/parser/htmlparser/src/nsElementTable.cpp +++ b/mozilla/parser/htmlparser/src/nsElementTable.cpp @@ -869,7 +869,7 @@ void InitializeElementTable(void) { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0,0, /*parent,incl,exclgroups*/ kBlock, kFlowEntity|kSelf, kNone, - /*special props, prop-range*/ 0, kNoPropRange, + /*special props, prop-range*/ kLegalOpen, kNoPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown); Initialize( diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp index bae9930fa16..8bfca2430d5 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp @@ -694,7 +694,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan //XXX - Find a better soution to record content //Added _plaintext to fix bug 46054. - if((eHTMLTag_textarea==theTag || eHTMLTag_xmp==theTag || eHTMLTag_plaintext==theTag) && !mRecordTrailingContent) { + if((eHTMLTag_textarea==theTag || eHTMLTag_xmp==theTag || eHTMLTag_plaintext==theTag || eHTMLTag_noscript==theTag) && !mRecordTrailingContent) { mRecordTrailingContent=PR_TRUE; }