зеркало из https://github.com/mozilla/pjs.git
69160 - Parser stack & sink stack should be 1:1 even when handling nested MAPs.
3248 - Added Support for http headers ( link,content-base,default-style ) in the sink. 41426 - Making sure that XML like syntax ( <tag/> ) does not produce an extra end tag ( <tag></tag> ) in view-source. 62803 - Stop processing NOFRAME content ( will have to add support to process the content once we have to ability to turn off frames). r=heikki,sr=vidur
This commit is contained in:
Родитель
337636fdef
Коммит
92a2c9be3a
|
@ -147,7 +147,7 @@ CNavDTD::CNavDTD() : nsIDTD(),
|
||||||
mHasOpenBody=PR_FALSE;
|
mHasOpenBody=PR_FALSE;
|
||||||
mHasOpenHead=0;
|
mHasOpenHead=0;
|
||||||
mHasOpenForm=PR_FALSE;
|
mHasOpenForm=PR_FALSE;
|
||||||
mHasOpenMap=PR_FALSE;
|
mOpenMapCount=0;
|
||||||
mHasOpenNoXXX=0;
|
mHasOpenNoXXX=0;
|
||||||
mFormContext=0;
|
mFormContext=0;
|
||||||
mMapContext=0;
|
mMapContext=0;
|
||||||
|
@ -802,8 +802,13 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){
|
||||||
|
|
||||||
if(theToken){
|
if(theToken){
|
||||||
//Before dealing with the token normally, we need to deal with skip targets
|
//Before dealing with the token normally, we need to deal with skip targets
|
||||||
if((!execSkipContent) && (theType!=eToken_end) &&
|
CStartToken* theStartToken=NS_STATIC_CAST(CStartToken*,aToken);
|
||||||
(eHTMLTag_unknown==mSkipTarget) && (gHTMLElements[theTag].mSkipTarget)){ //create a new target
|
if((!execSkipContent) &&
|
||||||
|
(theType!=eToken_end) &&
|
||||||
|
(eHTMLTag_unknown==mSkipTarget) &&
|
||||||
|
(gHTMLElements[theTag].mSkipTarget) &&
|
||||||
|
(!theStartToken->IsEmpty())) { // added empty token check for bug 44186
|
||||||
|
//create a new target
|
||||||
mSkipTarget=gHTMLElements[theTag].mSkipTarget;
|
mSkipTarget=gHTMLElements[theTag].mSkipTarget;
|
||||||
mSkippedContent.Push(theToken);
|
mSkippedContent.Push(theToken);
|
||||||
}
|
}
|
||||||
|
@ -1611,12 +1616,12 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eHTMLTag_area:
|
case eHTMLTag_area:
|
||||||
if(!mHasOpenMap) isTokenHandled=PR_TRUE;
|
if(!mOpenMapCount) isTokenHandled=PR_TRUE;
|
||||||
|
|
||||||
STOP_TIMER();
|
STOP_TIMER();
|
||||||
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::HandleStartToken(), this=%p\n", this));
|
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::HandleStartToken(), this=%p\n", this));
|
||||||
|
|
||||||
if (mHasOpenMap && mSink) {
|
if (mOpenMapCount>0 && mSink) {
|
||||||
result=mSink->AddLeaf(*theNode);
|
result=mSink->AddLeaf(*theNode);
|
||||||
isTokenHandled=PR_TRUE;
|
isTokenHandled=PR_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -2756,7 +2761,7 @@ PRBool CNavDTD::HasOpenContainer(eHTMLTags aContainer) const {
|
||||||
case eHTMLTag_form:
|
case eHTMLTag_form:
|
||||||
result=mHasOpenForm; break;
|
result=mHasOpenForm; break;
|
||||||
case eHTMLTag_map:
|
case eHTMLTag_map:
|
||||||
result=mHasOpenMap; break;
|
result=mOpenMapCount>0; break;
|
||||||
default:
|
default:
|
||||||
result=mBodyContext->HasOpenContainer(aContainer);
|
result=mBodyContext->HasOpenContainer(aContainer);
|
||||||
break;
|
break;
|
||||||
|
@ -3162,8 +3167,6 @@ nsresult CNavDTD::CloseForm(const nsIParserNode *aNode){
|
||||||
* @return TRUE if ok, FALSE if error
|
* @return TRUE if ok, FALSE if error
|
||||||
*/
|
*/
|
||||||
nsresult CNavDTD::OpenMap(const nsIParserNode *aNode){
|
nsresult CNavDTD::OpenMap(const nsIParserNode *aNode){
|
||||||
if(mHasOpenMap)
|
|
||||||
CloseMap(aNode);
|
|
||||||
|
|
||||||
STOP_TIMER();
|
STOP_TIMER();
|
||||||
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenMap(), this=%p\n", this));
|
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenMap(), this=%p\n", this));
|
||||||
|
@ -3175,7 +3178,7 @@ nsresult CNavDTD::OpenMap(const nsIParserNode *aNode){
|
||||||
|
|
||||||
if(NS_OK==result) {
|
if(NS_OK==result) {
|
||||||
mBodyContext->Push(aNode);
|
mBodyContext->Push(aNode);
|
||||||
mHasOpenMap=PR_TRUE;
|
mOpenMapCount++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -3191,8 +3194,8 @@ nsresult CNavDTD::OpenMap(const nsIParserNode *aNode){
|
||||||
nsresult CNavDTD::CloseMap(const nsIParserNode *aNode){
|
nsresult CNavDTD::CloseMap(const nsIParserNode *aNode){
|
||||||
// NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos);
|
// NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos);
|
||||||
nsresult result=NS_OK;
|
nsresult result=NS_OK;
|
||||||
if(mHasOpenMap) {
|
if(mOpenMapCount) {
|
||||||
mHasOpenMap=PR_FALSE;
|
mOpenMapCount--;
|
||||||
|
|
||||||
STOP_TIMER();
|
STOP_TIMER();
|
||||||
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseMap(), this=%p\n", this));
|
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseMap(), this=%p\n", this));
|
||||||
|
|
|
@ -500,8 +500,8 @@ protected:
|
||||||
nsDTDContext* mFormContext;
|
nsDTDContext* mFormContext;
|
||||||
nsDTDContext* mMapContext;
|
nsDTDContext* mMapContext;
|
||||||
nsDTDContext* mTempContext;
|
nsDTDContext* mTempContext;
|
||||||
PRBool mHasOpenForm;
|
PRInt32 mHasOpenForm;
|
||||||
PRBool mHasOpenMap;
|
PRInt32 mOpenMapCount;
|
||||||
PRInt32 mHasOpenHead;
|
PRInt32 mHasOpenHead;
|
||||||
PRBool mHasOpenBody;
|
PRBool mHasOpenBody;
|
||||||
PRInt32 mHasOpenNoXXX; //true when NOFRAMES, NOSCRIPT, NOEMBED, NOLAYER are open
|
PRInt32 mHasOpenNoXXX; //true when NOFRAMES, NOSCRIPT, NOEMBED, NOLAYER are open
|
||||||
|
|
|
@ -371,7 +371,7 @@ nsDTDContext::nsDTDContext() : mStack(), mEntities(0){
|
||||||
|
|
||||||
MOZ_COUNT_CTOR(nsDTDContext);
|
MOZ_COUNT_CTOR(nsDTDContext);
|
||||||
mResidualStyleCount=0;
|
mResidualStyleCount=0;
|
||||||
mContextTopIndex=0;
|
mContextTopIndex=-1;
|
||||||
mTableStates=0;
|
mTableStates=0;
|
||||||
mCounters=0;
|
mCounters=0;
|
||||||
mTokenAllocator=0;
|
mTokenAllocator=0;
|
||||||
|
|
|
@ -857,7 +857,7 @@ void InitializeElementTable(void) {
|
||||||
/*autoclose starttags and endtags*/ 0,0,0,0,
|
/*autoclose starttags and endtags*/ 0,0,0,0,
|
||||||
/*parent,incl,exclgroups*/ kBlock, kFlowEntity, kNone,
|
/*parent,incl,exclgroups*/ kBlock, kFlowEntity, kNone,
|
||||||
/*special props, prop-range*/ 0, kNoPropRange,
|
/*special props, prop-range*/ 0, kNoPropRange,
|
||||||
/*special parents,kids,skip*/ &gNoframeRoot,0,eHTMLTag_unknown);
|
/*special parents,kids,skip*/ &gNoframeRoot,0,eHTMLTag_noframes); // Added noframes - fix bug 62803 - since Mozilla supports frames.
|
||||||
|
|
||||||
Initialize(
|
Initialize(
|
||||||
/*tag*/ eHTMLTag_nolayer,
|
/*tag*/ eHTMLTag_nolayer,
|
||||||
|
|
|
@ -576,17 +576,21 @@ nsresult nsHTMLTokenizer::ConsumeAttributes(PRUnichar aChar,CStartToken* aToken,
|
||||||
//and a textkey of "/". We should destroy it, and tell the
|
//and a textkey of "/". We should destroy it, and tell the
|
||||||
//start token it was empty.
|
//start token it was empty.
|
||||||
if(NS_SUCCEEDED(result)) {
|
if(NS_SUCCEEDED(result)) {
|
||||||
|
PRBool isUsableAttr=PR_TRUE;
|
||||||
const nsAReadableString& key=theToken->GetKey();
|
const nsAReadableString& key=theToken->GetKey();
|
||||||
const nsAReadableString& text=theToken->GetValue();
|
const nsAReadableString& text=theToken->GetValue();
|
||||||
if((mDoXMLEmptyTags) && (kForwardSlash==key.CharAt(0)) && (0==text.Length())){
|
// support XML like syntax to fix bugs like 44186
|
||||||
//tada! our special case! Treat it like an empty start tag...
|
if((kForwardSlash==key.CharAt(0)) && (0==text.Length())){
|
||||||
aToken->SetEmpty(PR_TRUE);
|
aToken->SetEmpty(PR_TRUE);
|
||||||
IF_FREE(theToken);
|
isUsableAttr=!mDoXMLEmptyTags;
|
||||||
}
|
}
|
||||||
else {
|
if(isUsableAttr) {
|
||||||
theAttrCount++;
|
theAttrCount++;
|
||||||
AddToken((CToken*&)theToken,result,&mTokenDeque,theAllocator);
|
AddToken((CToken*&)theToken,result,&mTokenDeque,theAllocator);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
IF_FREE(theToken);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else { //if(NS_ERROR_HTMLPARSER_BADATTRIBUTE==result){
|
else { //if(NS_ERROR_HTMLPARSER_BADATTRIBUTE==result){
|
||||||
aToken->SetEmpty(PR_TRUE);
|
aToken->SetEmpty(PR_TRUE);
|
||||||
|
@ -677,6 +681,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan
|
||||||
}//if
|
}//if
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CStartToken* theStartToken=NS_STATIC_CAST(CStartToken*,aToken);
|
||||||
if(theTagHasAttributes) {
|
if(theTagHasAttributes) {
|
||||||
if (eViewSource==mParserCommand) {
|
if (eViewSource==mParserCommand) {
|
||||||
// Since we conserve whitespace in view-source mode,
|
// Since we conserve whitespace in view-source mode,
|
||||||
|
@ -684,7 +689,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan
|
||||||
// and let the first attribute grab it.
|
// and let the first attribute grab it.
|
||||||
aScanner.SetPosition(start, PR_FALSE, PR_TRUE);
|
aScanner.SetPosition(start, PR_FALSE, PR_TRUE);
|
||||||
}
|
}
|
||||||
result=ConsumeAttributes(aChar,(CStartToken*)aToken,aScanner);
|
result=ConsumeAttributes(aChar,theStartToken,aScanner);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now that that's over with, we have one more problem to solve.
|
/* Now that that's over with, we have one more problem to solve.
|
||||||
|
@ -700,7 +705,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mRecordTrailingContent)
|
if(mRecordTrailingContent)
|
||||||
RecordTrailingContent((CStartToken*)aToken,aScanner,origin);
|
RecordTrailingContent(theStartToken,aScanner,origin);
|
||||||
|
|
||||||
//if((eHTMLTag_style==theTag) || (eHTMLTag_script==theTag)) {
|
//if((eHTMLTag_style==theTag) || (eHTMLTag_script==theTag)) {
|
||||||
if(gHTMLElements[theTag].CanContainType(kCDATA)) {
|
if(gHTMLElements[theTag].CanContainType(kCDATA)) {
|
||||||
|
@ -709,12 +714,22 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan
|
||||||
endText.Assign(endTagName);
|
endText.Assign(endTagName);
|
||||||
endText.InsertWithConversion("</",0,2);
|
endText.InsertWithConversion("</",0,2);
|
||||||
|
|
||||||
CToken* textToken=theAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text);
|
CToken* text=theAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text);
|
||||||
result=((CTextToken*)textToken)->ConsumeUntil(0,PRBool(theTag!=eHTMLTag_script),aScanner,endText,mParseMode,aFlushTokens); //tell new token to finish consuming text...
|
CTextToken* textToken=NS_STATIC_CAST(CTextToken*,text);
|
||||||
|
result=textToken->ConsumeUntil(0,theTag!=eHTMLTag_script,aScanner,endText,mParseMode,aFlushTokens); //tell new token to finish consuming text...
|
||||||
CToken* endToken=theAllocator->CreateTokenOfType(eToken_end,theTag,endTagName);
|
|
||||||
AddToken(textToken,result,&mTokenDeque,theAllocator);
|
// Fix bug 44186
|
||||||
AddToken(endToken,result,&mTokenDeque,theAllocator);
|
// Support XML like syntax, i.e., <script src="external.js"/> == <script src="external.js"></script>
|
||||||
|
// Note: if aFlushTokens is TRUE then we have seen an </script>
|
||||||
|
if(!theStartToken->IsEmpty() || aFlushTokens) {
|
||||||
|
theStartToken->SetEmpty(PR_FALSE); // Setting this would make cases like <script/>d.w("text");</script> work.
|
||||||
|
CToken* endToken=theAllocator->CreateTokenOfType(eToken_end,theTag,endTagName);
|
||||||
|
AddToken(text,result,&mTokenDeque,theAllocator);
|
||||||
|
AddToken(endToken,result,&mTokenDeque,theAllocator);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
IF_FREE(text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ CNavDTD::CNavDTD() : nsIDTD(),
|
||||||
mHasOpenBody=PR_FALSE;
|
mHasOpenBody=PR_FALSE;
|
||||||
mHasOpenHead=0;
|
mHasOpenHead=0;
|
||||||
mHasOpenForm=PR_FALSE;
|
mHasOpenForm=PR_FALSE;
|
||||||
mHasOpenMap=PR_FALSE;
|
mOpenMapCount=0;
|
||||||
mHasOpenNoXXX=0;
|
mHasOpenNoXXX=0;
|
||||||
mFormContext=0;
|
mFormContext=0;
|
||||||
mMapContext=0;
|
mMapContext=0;
|
||||||
|
@ -802,8 +802,13 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){
|
||||||
|
|
||||||
if(theToken){
|
if(theToken){
|
||||||
//Before dealing with the token normally, we need to deal with skip targets
|
//Before dealing with the token normally, we need to deal with skip targets
|
||||||
if((!execSkipContent) && (theType!=eToken_end) &&
|
CStartToken* theStartToken=NS_STATIC_CAST(CStartToken*,aToken);
|
||||||
(eHTMLTag_unknown==mSkipTarget) && (gHTMLElements[theTag].mSkipTarget)){ //create a new target
|
if((!execSkipContent) &&
|
||||||
|
(theType!=eToken_end) &&
|
||||||
|
(eHTMLTag_unknown==mSkipTarget) &&
|
||||||
|
(gHTMLElements[theTag].mSkipTarget) &&
|
||||||
|
(!theStartToken->IsEmpty())) { // added empty token check for bug 44186
|
||||||
|
//create a new target
|
||||||
mSkipTarget=gHTMLElements[theTag].mSkipTarget;
|
mSkipTarget=gHTMLElements[theTag].mSkipTarget;
|
||||||
mSkippedContent.Push(theToken);
|
mSkippedContent.Push(theToken);
|
||||||
}
|
}
|
||||||
|
@ -1611,12 +1616,12 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eHTMLTag_area:
|
case eHTMLTag_area:
|
||||||
if(!mHasOpenMap) isTokenHandled=PR_TRUE;
|
if(!mOpenMapCount) isTokenHandled=PR_TRUE;
|
||||||
|
|
||||||
STOP_TIMER();
|
STOP_TIMER();
|
||||||
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::HandleStartToken(), this=%p\n", this));
|
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::HandleStartToken(), this=%p\n", this));
|
||||||
|
|
||||||
if (mHasOpenMap && mSink) {
|
if (mOpenMapCount>0 && mSink) {
|
||||||
result=mSink->AddLeaf(*theNode);
|
result=mSink->AddLeaf(*theNode);
|
||||||
isTokenHandled=PR_TRUE;
|
isTokenHandled=PR_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -2756,7 +2761,7 @@ PRBool CNavDTD::HasOpenContainer(eHTMLTags aContainer) const {
|
||||||
case eHTMLTag_form:
|
case eHTMLTag_form:
|
||||||
result=mHasOpenForm; break;
|
result=mHasOpenForm; break;
|
||||||
case eHTMLTag_map:
|
case eHTMLTag_map:
|
||||||
result=mHasOpenMap; break;
|
result=mOpenMapCount>0; break;
|
||||||
default:
|
default:
|
||||||
result=mBodyContext->HasOpenContainer(aContainer);
|
result=mBodyContext->HasOpenContainer(aContainer);
|
||||||
break;
|
break;
|
||||||
|
@ -3162,8 +3167,6 @@ nsresult CNavDTD::CloseForm(const nsIParserNode *aNode){
|
||||||
* @return TRUE if ok, FALSE if error
|
* @return TRUE if ok, FALSE if error
|
||||||
*/
|
*/
|
||||||
nsresult CNavDTD::OpenMap(const nsIParserNode *aNode){
|
nsresult CNavDTD::OpenMap(const nsIParserNode *aNode){
|
||||||
if(mHasOpenMap)
|
|
||||||
CloseMap(aNode);
|
|
||||||
|
|
||||||
STOP_TIMER();
|
STOP_TIMER();
|
||||||
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenMap(), this=%p\n", this));
|
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::OpenMap(), this=%p\n", this));
|
||||||
|
@ -3175,7 +3178,7 @@ nsresult CNavDTD::OpenMap(const nsIParserNode *aNode){
|
||||||
|
|
||||||
if(NS_OK==result) {
|
if(NS_OK==result) {
|
||||||
mBodyContext->Push(aNode);
|
mBodyContext->Push(aNode);
|
||||||
mHasOpenMap=PR_TRUE;
|
mOpenMapCount++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -3191,8 +3194,8 @@ nsresult CNavDTD::OpenMap(const nsIParserNode *aNode){
|
||||||
nsresult CNavDTD::CloseMap(const nsIParserNode *aNode){
|
nsresult CNavDTD::CloseMap(const nsIParserNode *aNode){
|
||||||
// NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos);
|
// NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos);
|
||||||
nsresult result=NS_OK;
|
nsresult result=NS_OK;
|
||||||
if(mHasOpenMap) {
|
if(mOpenMapCount) {
|
||||||
mHasOpenMap=PR_FALSE;
|
mOpenMapCount--;
|
||||||
|
|
||||||
STOP_TIMER();
|
STOP_TIMER();
|
||||||
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseMap(), this=%p\n", this));
|
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseMap(), this=%p\n", this));
|
||||||
|
|
|
@ -500,8 +500,8 @@ protected:
|
||||||
nsDTDContext* mFormContext;
|
nsDTDContext* mFormContext;
|
||||||
nsDTDContext* mMapContext;
|
nsDTDContext* mMapContext;
|
||||||
nsDTDContext* mTempContext;
|
nsDTDContext* mTempContext;
|
||||||
PRBool mHasOpenForm;
|
PRInt32 mHasOpenForm;
|
||||||
PRBool mHasOpenMap;
|
PRInt32 mOpenMapCount;
|
||||||
PRInt32 mHasOpenHead;
|
PRInt32 mHasOpenHead;
|
||||||
PRBool mHasOpenBody;
|
PRBool mHasOpenBody;
|
||||||
PRInt32 mHasOpenNoXXX; //true when NOFRAMES, NOSCRIPT, NOEMBED, NOLAYER are open
|
PRInt32 mHasOpenNoXXX; //true when NOFRAMES, NOSCRIPT, NOEMBED, NOLAYER are open
|
||||||
|
|
|
@ -371,7 +371,7 @@ nsDTDContext::nsDTDContext() : mStack(), mEntities(0){
|
||||||
|
|
||||||
MOZ_COUNT_CTOR(nsDTDContext);
|
MOZ_COUNT_CTOR(nsDTDContext);
|
||||||
mResidualStyleCount=0;
|
mResidualStyleCount=0;
|
||||||
mContextTopIndex=0;
|
mContextTopIndex=-1;
|
||||||
mTableStates=0;
|
mTableStates=0;
|
||||||
mCounters=0;
|
mCounters=0;
|
||||||
mTokenAllocator=0;
|
mTokenAllocator=0;
|
||||||
|
|
|
@ -857,7 +857,7 @@ void InitializeElementTable(void) {
|
||||||
/*autoclose starttags and endtags*/ 0,0,0,0,
|
/*autoclose starttags and endtags*/ 0,0,0,0,
|
||||||
/*parent,incl,exclgroups*/ kBlock, kFlowEntity, kNone,
|
/*parent,incl,exclgroups*/ kBlock, kFlowEntity, kNone,
|
||||||
/*special props, prop-range*/ 0, kNoPropRange,
|
/*special props, prop-range*/ 0, kNoPropRange,
|
||||||
/*special parents,kids,skip*/ &gNoframeRoot,0,eHTMLTag_unknown);
|
/*special parents,kids,skip*/ &gNoframeRoot,0,eHTMLTag_noframes); // Added noframes - fix bug 62803 - since Mozilla supports frames.
|
||||||
|
|
||||||
Initialize(
|
Initialize(
|
||||||
/*tag*/ eHTMLTag_nolayer,
|
/*tag*/ eHTMLTag_nolayer,
|
||||||
|
|
|
@ -576,17 +576,21 @@ nsresult nsHTMLTokenizer::ConsumeAttributes(PRUnichar aChar,CStartToken* aToken,
|
||||||
//and a textkey of "/". We should destroy it, and tell the
|
//and a textkey of "/". We should destroy it, and tell the
|
||||||
//start token it was empty.
|
//start token it was empty.
|
||||||
if(NS_SUCCEEDED(result)) {
|
if(NS_SUCCEEDED(result)) {
|
||||||
|
PRBool isUsableAttr=PR_TRUE;
|
||||||
const nsAReadableString& key=theToken->GetKey();
|
const nsAReadableString& key=theToken->GetKey();
|
||||||
const nsAReadableString& text=theToken->GetValue();
|
const nsAReadableString& text=theToken->GetValue();
|
||||||
if((mDoXMLEmptyTags) && (kForwardSlash==key.CharAt(0)) && (0==text.Length())){
|
// support XML like syntax to fix bugs like 44186
|
||||||
//tada! our special case! Treat it like an empty start tag...
|
if((kForwardSlash==key.CharAt(0)) && (0==text.Length())){
|
||||||
aToken->SetEmpty(PR_TRUE);
|
aToken->SetEmpty(PR_TRUE);
|
||||||
IF_FREE(theToken);
|
isUsableAttr=!mDoXMLEmptyTags;
|
||||||
}
|
}
|
||||||
else {
|
if(isUsableAttr) {
|
||||||
theAttrCount++;
|
theAttrCount++;
|
||||||
AddToken((CToken*&)theToken,result,&mTokenDeque,theAllocator);
|
AddToken((CToken*&)theToken,result,&mTokenDeque,theAllocator);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
IF_FREE(theToken);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else { //if(NS_ERROR_HTMLPARSER_BADATTRIBUTE==result){
|
else { //if(NS_ERROR_HTMLPARSER_BADATTRIBUTE==result){
|
||||||
aToken->SetEmpty(PR_TRUE);
|
aToken->SetEmpty(PR_TRUE);
|
||||||
|
@ -677,6 +681,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan
|
||||||
}//if
|
}//if
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CStartToken* theStartToken=NS_STATIC_CAST(CStartToken*,aToken);
|
||||||
if(theTagHasAttributes) {
|
if(theTagHasAttributes) {
|
||||||
if (eViewSource==mParserCommand) {
|
if (eViewSource==mParserCommand) {
|
||||||
// Since we conserve whitespace in view-source mode,
|
// Since we conserve whitespace in view-source mode,
|
||||||
|
@ -684,7 +689,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan
|
||||||
// and let the first attribute grab it.
|
// and let the first attribute grab it.
|
||||||
aScanner.SetPosition(start, PR_FALSE, PR_TRUE);
|
aScanner.SetPosition(start, PR_FALSE, PR_TRUE);
|
||||||
}
|
}
|
||||||
result=ConsumeAttributes(aChar,(CStartToken*)aToken,aScanner);
|
result=ConsumeAttributes(aChar,theStartToken,aScanner);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now that that's over with, we have one more problem to solve.
|
/* Now that that's over with, we have one more problem to solve.
|
||||||
|
@ -700,7 +705,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mRecordTrailingContent)
|
if(mRecordTrailingContent)
|
||||||
RecordTrailingContent((CStartToken*)aToken,aScanner,origin);
|
RecordTrailingContent(theStartToken,aScanner,origin);
|
||||||
|
|
||||||
//if((eHTMLTag_style==theTag) || (eHTMLTag_script==theTag)) {
|
//if((eHTMLTag_style==theTag) || (eHTMLTag_script==theTag)) {
|
||||||
if(gHTMLElements[theTag].CanContainType(kCDATA)) {
|
if(gHTMLElements[theTag].CanContainType(kCDATA)) {
|
||||||
|
@ -709,12 +714,22 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan
|
||||||
endText.Assign(endTagName);
|
endText.Assign(endTagName);
|
||||||
endText.InsertWithConversion("</",0,2);
|
endText.InsertWithConversion("</",0,2);
|
||||||
|
|
||||||
CToken* textToken=theAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text);
|
CToken* text=theAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text);
|
||||||
result=((CTextToken*)textToken)->ConsumeUntil(0,PRBool(theTag!=eHTMLTag_script),aScanner,endText,mParseMode,aFlushTokens); //tell new token to finish consuming text...
|
CTextToken* textToken=NS_STATIC_CAST(CTextToken*,text);
|
||||||
|
result=textToken->ConsumeUntil(0,theTag!=eHTMLTag_script,aScanner,endText,mParseMode,aFlushTokens); //tell new token to finish consuming text...
|
||||||
CToken* endToken=theAllocator->CreateTokenOfType(eToken_end,theTag,endTagName);
|
|
||||||
AddToken(textToken,result,&mTokenDeque,theAllocator);
|
// Fix bug 44186
|
||||||
AddToken(endToken,result,&mTokenDeque,theAllocator);
|
// Support XML like syntax, i.e., <script src="external.js"/> == <script src="external.js"></script>
|
||||||
|
// Note: if aFlushTokens is TRUE then we have seen an </script>
|
||||||
|
if(!theStartToken->IsEmpty() || aFlushTokens) {
|
||||||
|
theStartToken->SetEmpty(PR_FALSE); // Setting this would make cases like <script/>d.w("text");</script> work.
|
||||||
|
CToken* endToken=theAllocator->CreateTokenOfType(eToken_end,theTag,endTagName);
|
||||||
|
AddToken(text,result,&mTokenDeque,theAllocator);
|
||||||
|
AddToken(endToken,result,&mTokenDeque,theAllocator);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
IF_FREE(text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче