Changed Notify() method, in nsDTDUtils, to
support viewing source in the desired charset.
This commit is contained in:
harishd%netscape.com 1999-09-10 18:51:16 +00:00
Родитель d7e1750a01
Коммит b4206a6f8f
8 изменённых файлов: 116 добавлений и 66 удалений

Просмотреть файл

@ -714,7 +714,7 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){
if(gHTMLElements[eHTMLTag_body].SectionContains(theTag,PR_TRUE)){
mTokenizer->PushTokenFront(aToken); //put this token back...
mTokenizer->PrependTokens(mMisplacedContent); //push misplaced content
theToken=(CHTMLToken*)gRecycler->CreateTokenOfType(eToken_start,eHTMLTag_body);
theToken=(CHTMLToken*)gRecycler->CreateTokenOfType(eToken_start,theTag=eHTMLTag_body);
//now open a body...
}
}
@ -1087,12 +1087,15 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsCParserNode
}
if(mParser) {
nsAutoString charsetValue;
nsCharsetSource charsetSource;
nsAutoString charsetValue;
nsCharsetSource charsetSource;
CObserverService& theService=mParser->GetObserverService();
CParserContext* pc=mParser->PeekContext();
void* theDocID=(pc)? pc->mKey:0;
mParser->GetDocumentCharset(charsetValue,charsetSource);
CParserContext* pc=mParser->PeekContext();
void* theDocID=(pc) ? pc->mKey : 0;
result=(mParser->GetObserverService()).Notify(aTag,aNode,(PRUint32)theDocID,this,charsetValue,charsetSource);
result=theService.Notify(aTag,aNode,(PRUint32)theDocID,kHTMLTextContentType,
charsetValue,charsetSource);
}

Просмотреть файл

@ -752,7 +752,7 @@ void CObserverService::RegisterObservers(nsString& aTopic) {
* @param aCharsetSource -
* @return if SUCCESS return NS_OK else return ERROR code.
*/
nsresult CObserverService::Notify(eHTMLTags aTag,nsIParserNode& aNode,PRUint32 aUniqueID, nsIDTD* aDTD,
nsresult CObserverService::Notify(eHTMLTags aTag,nsIParserNode& aNode,PRUint32 aUniqueID, const char* aCommand,
nsAutoString& aCharsetValue,nsCharsetSource& aCharsetSource) {
nsresult result=NS_OK;
nsDeque* theDeque=GetObserversForTag(aTag);
@ -783,6 +783,13 @@ nsresult CObserverService::Notify(eHTMLTags aTag,nsIParserNode& aNode,PRUint32 a
theValues[index] = intValue.GetUnicode();
index++;
}
if(index < 50) {
nsAutoString theDTDKey("X_COMMAND");
nsAutoString theDTDValue(aCommand);
theKeys[index]=theDTDKey.GetUnicode();
theValues[index]=theDTDValue.GetUnicode();
index++;
}
nsAutoString theTagStr(nsHTMLTags::GetStringValue(aTag));
nsObserverNotifier theNotifier(theTagStr.GetUnicode(),aUniqueID,index,theKeys,theValues);
theDeque->FirstThat(theNotifier);

Просмотреть файл

@ -251,8 +251,8 @@ public:
nsDeque* GetObserversForTag(eHTMLTags aTag);
nsresult Notify(eHTMLTags aTag,nsIParserNode& aNode,
PRUint32 aUniqueID, nsIDTD* aDTD,
nsAutoString& aCharsetValue,nsCharsetSource& aCharsetSource) ;
PRUint32 aUniqueID, const char* aCommand,
nsAutoString& aCharsetValue,nsCharsetSource& aCharsetSource);
protected:
void RegisterObservers(nsString& aTopicList);

Просмотреть файл

@ -389,7 +389,7 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
mNeedsFontSpec=PR_FALSE;
}
while(NS_OK==result){
while(NS_SUCCEEDED(result)){
CToken* theToken=mTokenizer->PopToken();
if(theToken) {
result=HandleToken(theToken,aParser);
@ -971,33 +971,48 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) {
else return kEOF;
}
}
}
WriteTag(theContext.mTokenNode,*mSink,theEndTag,mIsHTML,mIsPlaintext,theContext);
// We make sure to display the title on the view source window.
if(eHTMLTag_title == theTag){
nsCParserNode attrNode(theToken,mLineNumber,GetTokenRecycler());
CToken* theNextToken = mTokenizer->PopToken();
if(theNextToken) {
theType=eHTMLTokenTypes(theNextToken->GetTokenType());
if(eToken_text==theType) {
attrNode.SetSkippedContent(theNextToken->GetStringValueXXX());
}
#if 0
if(mParser) {
nsAutoString charsetValue;
nsCharsetSource charsetSource;
CObserverService& theService=mParser->GetObserverService();
CParserContext* pc=mParser->PeekContext();
void* theDocID=(pc)? pc->mKey:0;
mParser->GetDocumentCharset(charsetValue,charsetSource);
result=theService.Notify(theTag,theContext.mTokenNode,(PRUint32)theDocID,
kViewSourceCommand,charsetValue,charsetSource);
}
result= OpenHead(attrNode);
if(NS_OK==result) {
if(mSink) {
mSink->SetTitle(attrNode.GetSkippedContent());
#endif
if(NS_SUCCEEDED(result)) {
WriteTag(theContext.mTokenNode,*mSink,theEndTag,mIsHTML,mIsPlaintext,theContext);
// We make sure to display the title on the view source window.
if(eHTMLTag_title == theTag){
nsCParserNode attrNode(theToken,mLineNumber,GetTokenRecycler());
CToken* theNextToken = mTokenizer->PopToken();
if(theNextToken) {
theType=eHTMLTokenTypes(theNextToken->GetTokenType());
if(eToken_text==theType) {
attrNode.SetSkippedContent(theNextToken->GetStringValueXXX());
}
}
result= OpenHead(attrNode);
if(NS_OK==result) {
if(mSink) {
mSink->SetTitle(attrNode.GetSkippedContent());
}
if(NS_OK==result)
result=CloseHead(attrNode);
}
const nsString& theText=attrNode.GetSkippedContent();
::WriteText(theText,*mSink,PR_FALSE,mIsPlaintext,theContext);
}
if(NS_OK==result)
result=CloseHead(attrNode);
}
const nsString& theText=attrNode.GetSkippedContent();
::WriteText(theText,*mSink,PR_FALSE,mIsPlaintext,theContext);
break;
}
break;
case eToken_end:
WriteTag(theContext.mTokenNode,*mSink,theEndTag,mIsHTML,mIsPlaintext,theContext);
break;

Просмотреть файл

@ -714,7 +714,7 @@ nsresult CNavDTD::HandleToken(CToken* aToken,nsIParser* aParser){
if(gHTMLElements[eHTMLTag_body].SectionContains(theTag,PR_TRUE)){
mTokenizer->PushTokenFront(aToken); //put this token back...
mTokenizer->PrependTokens(mMisplacedContent); //push misplaced content
theToken=(CHTMLToken*)gRecycler->CreateTokenOfType(eToken_start,eHTMLTag_body);
theToken=(CHTMLToken*)gRecycler->CreateTokenOfType(eToken_start,theTag=eHTMLTag_body);
//now open a body...
}
}
@ -1087,12 +1087,15 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsCParserNode
}
if(mParser) {
nsAutoString charsetValue;
nsCharsetSource charsetSource;
nsAutoString charsetValue;
nsCharsetSource charsetSource;
CObserverService& theService=mParser->GetObserverService();
CParserContext* pc=mParser->PeekContext();
void* theDocID=(pc)? pc->mKey:0;
mParser->GetDocumentCharset(charsetValue,charsetSource);
CParserContext* pc=mParser->PeekContext();
void* theDocID=(pc) ? pc->mKey : 0;
result=(mParser->GetObserverService()).Notify(aTag,aNode,(PRUint32)theDocID,this,charsetValue,charsetSource);
result=theService.Notify(aTag,aNode,(PRUint32)theDocID,kHTMLTextContentType,
charsetValue,charsetSource);
}

Просмотреть файл

@ -752,7 +752,7 @@ void CObserverService::RegisterObservers(nsString& aTopic) {
* @param aCharsetSource -
* @return if SUCCESS return NS_OK else return ERROR code.
*/
nsresult CObserverService::Notify(eHTMLTags aTag,nsIParserNode& aNode,PRUint32 aUniqueID, nsIDTD* aDTD,
nsresult CObserverService::Notify(eHTMLTags aTag,nsIParserNode& aNode,PRUint32 aUniqueID, const char* aCommand,
nsAutoString& aCharsetValue,nsCharsetSource& aCharsetSource) {
nsresult result=NS_OK;
nsDeque* theDeque=GetObserversForTag(aTag);
@ -783,6 +783,13 @@ nsresult CObserverService::Notify(eHTMLTags aTag,nsIParserNode& aNode,PRUint32 a
theValues[index] = intValue.GetUnicode();
index++;
}
if(index < 50) {
nsAutoString theDTDKey("X_COMMAND");
nsAutoString theDTDValue(aCommand);
theKeys[index]=theDTDKey.GetUnicode();
theValues[index]=theDTDValue.GetUnicode();
index++;
}
nsAutoString theTagStr(nsHTMLTags::GetStringValue(aTag));
nsObserverNotifier theNotifier(theTagStr.GetUnicode(),aUniqueID,index,theKeys,theValues);
theDeque->FirstThat(theNotifier);

Просмотреть файл

@ -251,8 +251,8 @@ public:
nsDeque* GetObserversForTag(eHTMLTags aTag);
nsresult Notify(eHTMLTags aTag,nsIParserNode& aNode,
PRUint32 aUniqueID, nsIDTD* aDTD,
nsAutoString& aCharsetValue,nsCharsetSource& aCharsetSource) ;
PRUint32 aUniqueID, const char* aCommand,
nsAutoString& aCharsetValue,nsCharsetSource& aCharsetSource);
protected:
void RegisterObservers(nsString& aTopicList);

Просмотреть файл

@ -389,7 +389,7 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
mNeedsFontSpec=PR_FALSE;
}
while(NS_OK==result){
while(NS_SUCCEEDED(result)){
CToken* theToken=mTokenizer->PopToken();
if(theToken) {
result=HandleToken(theToken,aParser);
@ -971,33 +971,48 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) {
else return kEOF;
}
}
}
WriteTag(theContext.mTokenNode,*mSink,theEndTag,mIsHTML,mIsPlaintext,theContext);
// We make sure to display the title on the view source window.
if(eHTMLTag_title == theTag){
nsCParserNode attrNode(theToken,mLineNumber,GetTokenRecycler());
CToken* theNextToken = mTokenizer->PopToken();
if(theNextToken) {
theType=eHTMLTokenTypes(theNextToken->GetTokenType());
if(eToken_text==theType) {
attrNode.SetSkippedContent(theNextToken->GetStringValueXXX());
}
#if 0
if(mParser) {
nsAutoString charsetValue;
nsCharsetSource charsetSource;
CObserverService& theService=mParser->GetObserverService();
CParserContext* pc=mParser->PeekContext();
void* theDocID=(pc)? pc->mKey:0;
mParser->GetDocumentCharset(charsetValue,charsetSource);
result=theService.Notify(theTag,theContext.mTokenNode,(PRUint32)theDocID,
kViewSourceCommand,charsetValue,charsetSource);
}
result= OpenHead(attrNode);
if(NS_OK==result) {
if(mSink) {
mSink->SetTitle(attrNode.GetSkippedContent());
#endif
if(NS_SUCCEEDED(result)) {
WriteTag(theContext.mTokenNode,*mSink,theEndTag,mIsHTML,mIsPlaintext,theContext);
// We make sure to display the title on the view source window.
if(eHTMLTag_title == theTag){
nsCParserNode attrNode(theToken,mLineNumber,GetTokenRecycler());
CToken* theNextToken = mTokenizer->PopToken();
if(theNextToken) {
theType=eHTMLTokenTypes(theNextToken->GetTokenType());
if(eToken_text==theType) {
attrNode.SetSkippedContent(theNextToken->GetStringValueXXX());
}
}
result= OpenHead(attrNode);
if(NS_OK==result) {
if(mSink) {
mSink->SetTitle(attrNode.GetSkippedContent());
}
if(NS_OK==result)
result=CloseHead(attrNode);
}
const nsString& theText=attrNode.GetSkippedContent();
::WriteText(theText,*mSink,PR_FALSE,mIsPlaintext,theContext);
}
if(NS_OK==result)
result=CloseHead(attrNode);
}
const nsString& theText=attrNode.GetSkippedContent();
::WriteText(theText,*mSink,PR_FALSE,mIsPlaintext,theContext);
break;
}
break;
case eToken_end:
WriteTag(theContext.mTokenNode,*mSink,theEndTag,mIsHTML,mIsPlaintext,theContext);
break;