This commit is contained in:
rickg%netscape.com 1998-11-23 23:11:22 +00:00
parent ff561429bf
commit 29ba77b339
6 changed files with 118 additions and 78 deletions

View File

@ -508,6 +508,7 @@ CNavDTD::CNavDTD() : nsIDTD(), mTokenDeque(gTokenKiller) {
mSink = 0;
mDTDDebug=0;
mLineNumber=1;
mHasOpenBody=PR_FALSE;
mParseMode=eParseMode_navigator;
nsCRT::zero(mTokenHandlers,sizeof(mTokenHandlers));
mHasOpenForm=PR_FALSE;
@ -630,10 +631,12 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,PRBool aNotifySink){
nsresult result=NS_OK;
mFilename=aFilename;
if((aNotifySink) && (mSink)) {
mHasOpenBody=PR_FALSE;
mLineNumber=1;
result = mSink->WillBuildModel();
//CStartToken theToken(eHTMLTag_body); //open the body container...
//result=HandleStartToken(&theToken);
}
return result;
@ -648,6 +651,12 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,PRBool aNotifySink){
nsresult CNavDTD::DidBuildModel(PRInt32 anErrorCode,PRBool aNotifySink){
nsresult result= NS_OK;
/* if((kNoError==anErrorCode) && (!mHasOpenBody)) {
CStartToken theToken(eHTMLTag_body); //open the body container...
result=HandleStartToken(&theToken);
}
*/
if((kNoError==anErrorCode) && (mBodyContext->mElements.mCount>0)) {
result = CloseContainersTo(0,eHTMLTag_unknown,PR_FALSE);
}
@ -727,43 +736,45 @@ PRInt32 CNavDTD::DidHandleStartTag(CToken* aToken,eHTMLTags aChildTag){
PRInt32 result=kNoError;
CToken* theNextToken=mParser->PeekToken();
switch(aChildTag){
case eHTMLTag_pre:
case eHTMLTag_listing:
{
if(theNextToken) {
eHTMLTokenTypes theType=eHTMLTokenTypes(theNextToken->GetTokenType());
if(eToken_newline==theType){
if(theNextToken){
switch(aChildTag){
case eHTMLTag_pre:
case eHTMLTag_listing:
{
if(theNextToken) {
eHTMLTokenTypes theType=eHTMLTokenTypes(theNextToken->GetTokenType());
if(eToken_newline==theType){
switch(aChildTag){
case eHTMLTag_pre:
case eHTMLTag_listing:
//we skip the first newline token inside PRE and LISTING
mParser->PopToken();
break;
default:
break;
}//switch
switch(aChildTag){
case eHTMLTag_pre:
case eHTMLTag_listing:
//we skip the first newline token inside PRE and LISTING
mParser->PopToken();
break;
default:
break;
}//switch
}//if
}//if
}//if
}
break;
case eHTMLTag_plaintext:
case eHTMLTag_xmp:
//grab the skipped content and dump it out as text...
if(theNextToken){
eHTMLTokenTypes theType=eHTMLTokenTypes(theNextToken->GetTokenType());
if(eToken_skippedcontent==theType){
nsString& theText=((CAttributeToken*)theNextToken)->GetKey();
CViewSourceHTML::WriteText(theText,*mSink,PR_TRUE);
}
}
break;
default:
break;
}//switch
break;
case eHTMLTag_plaintext:
case eHTMLTag_xmp:
//grab the skipped content and dump it out as text...
if(theNextToken){
eHTMLTokenTypes theType=eHTMLTokenTypes(theNextToken->GetTokenType());
if(eToken_skippedcontent==theType){
nsString& theText=((CAttributeToken*)theNextToken)->GetKey();
CViewSourceHTML::WriteText(theText,*mSink,PR_TRUE);
}
}
break;
default:
break;
}//switch
}
return result;
}
@ -1320,7 +1331,7 @@ PRBool CNavDTD::CanContainStyles(eHTMLTags aParent) const {
PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
PRBool result=PR_FALSE;
if(!IsContainer(aParent))
if((!IsContainer(aParent)) && (eHTMLTag_unknown!=aParent))
return result;
@ -2042,7 +2053,7 @@ PRBool CNavDTD::CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild) const {
case eHTMLTag_html:
case eHTMLTag_body:
result=HasOpenContainer(aChild); //don't bother if they're already open...
result=PR_TRUE;
break;
case eHTMLTag_newline:
@ -2747,6 +2758,7 @@ CNavDTD::OpenContainer(const nsIParserNode& aNode,PRBool aUpdateStyleStack){
result=OpenHTML(aNode); break;
case eHTMLTag_body:
mHasOpenBody=PR_TRUE;
result=OpenBody(aNode); break;
case eHTMLTag_style:

View File

@ -619,6 +619,7 @@ protected:
PRBool mHasOpenForm;
PRBool mHasOpenMap;
PRBool mHasOpenHead;
PRBool mHasOpenBody;
nsDeque mTokenDeque;
nsString mFilename;
nsIDTDDebug* mDTDDebug;

View File

@ -740,7 +740,10 @@ PRInt32 nsParser::BuildModel() {
* @return ptr to token
*/
CToken* nsParser::PeekToken() {
CToken* theToken=(CToken*)mParserContext->mCurrentPos->GetCurrent();
CToken* theToken=0;
if(mParserContext)
if(mParserContext->mCurrentPos)
theToken=(CToken*)mParserContext->mCurrentPos->GetCurrent();
return theToken;
}
@ -752,8 +755,12 @@ CToken* nsParser::PeekToken() {
* @return ptr to token or NULL
*/
CToken* nsParser::PopToken() {
CToken* theToken=(CToken*)mParserContext->mCurrentPos->GetCurrent();
++(*mParserContext->mCurrentPos);
CToken* theToken=0;
if(mParserContext)
if(mParserContext->mCurrentPos) {
theToken=(CToken*)mParserContext->mCurrentPos->GetCurrent();
++(*mParserContext->mCurrentPos);
}
return theToken;
}

View File

@ -508,6 +508,7 @@ CNavDTD::CNavDTD() : nsIDTD(), mTokenDeque(gTokenKiller) {
mSink = 0;
mDTDDebug=0;
mLineNumber=1;
mHasOpenBody=PR_FALSE;
mParseMode=eParseMode_navigator;
nsCRT::zero(mTokenHandlers,sizeof(mTokenHandlers));
mHasOpenForm=PR_FALSE;
@ -630,10 +631,12 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,PRBool aNotifySink){
nsresult result=NS_OK;
mFilename=aFilename;
if((aNotifySink) && (mSink)) {
mHasOpenBody=PR_FALSE;
mLineNumber=1;
result = mSink->WillBuildModel();
//CStartToken theToken(eHTMLTag_body); //open the body container...
//result=HandleStartToken(&theToken);
}
return result;
@ -648,6 +651,12 @@ nsresult CNavDTD::WillBuildModel(nsString& aFilename,PRBool aNotifySink){
nsresult CNavDTD::DidBuildModel(PRInt32 anErrorCode,PRBool aNotifySink){
nsresult result= NS_OK;
/* if((kNoError==anErrorCode) && (!mHasOpenBody)) {
CStartToken theToken(eHTMLTag_body); //open the body container...
result=HandleStartToken(&theToken);
}
*/
if((kNoError==anErrorCode) && (mBodyContext->mElements.mCount>0)) {
result = CloseContainersTo(0,eHTMLTag_unknown,PR_FALSE);
}
@ -727,43 +736,45 @@ PRInt32 CNavDTD::DidHandleStartTag(CToken* aToken,eHTMLTags aChildTag){
PRInt32 result=kNoError;
CToken* theNextToken=mParser->PeekToken();
switch(aChildTag){
case eHTMLTag_pre:
case eHTMLTag_listing:
{
if(theNextToken) {
eHTMLTokenTypes theType=eHTMLTokenTypes(theNextToken->GetTokenType());
if(eToken_newline==theType){
if(theNextToken){
switch(aChildTag){
case eHTMLTag_pre:
case eHTMLTag_listing:
{
if(theNextToken) {
eHTMLTokenTypes theType=eHTMLTokenTypes(theNextToken->GetTokenType());
if(eToken_newline==theType){
switch(aChildTag){
case eHTMLTag_pre:
case eHTMLTag_listing:
//we skip the first newline token inside PRE and LISTING
mParser->PopToken();
break;
default:
break;
}//switch
switch(aChildTag){
case eHTMLTag_pre:
case eHTMLTag_listing:
//we skip the first newline token inside PRE and LISTING
mParser->PopToken();
break;
default:
break;
}//switch
}//if
}//if
}//if
}
break;
case eHTMLTag_plaintext:
case eHTMLTag_xmp:
//grab the skipped content and dump it out as text...
if(theNextToken){
eHTMLTokenTypes theType=eHTMLTokenTypes(theNextToken->GetTokenType());
if(eToken_skippedcontent==theType){
nsString& theText=((CAttributeToken*)theNextToken)->GetKey();
CViewSourceHTML::WriteText(theText,*mSink,PR_TRUE);
}
}
break;
default:
break;
}//switch
break;
case eHTMLTag_plaintext:
case eHTMLTag_xmp:
//grab the skipped content and dump it out as text...
if(theNextToken){
eHTMLTokenTypes theType=eHTMLTokenTypes(theNextToken->GetTokenType());
if(eToken_skippedcontent==theType){
nsString& theText=((CAttributeToken*)theNextToken)->GetKey();
CViewSourceHTML::WriteText(theText,*mSink,PR_TRUE);
}
}
break;
default:
break;
}//switch
}
return result;
}
@ -1320,7 +1331,7 @@ PRBool CNavDTD::CanContainStyles(eHTMLTags aParent) const {
PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
PRBool result=PR_FALSE;
if(!IsContainer(aParent))
if((!IsContainer(aParent)) && (eHTMLTag_unknown!=aParent))
return result;
@ -2042,7 +2053,7 @@ PRBool CNavDTD::CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild) const {
case eHTMLTag_html:
case eHTMLTag_body:
result=HasOpenContainer(aChild); //don't bother if they're already open...
result=PR_TRUE;
break;
case eHTMLTag_newline:
@ -2747,6 +2758,7 @@ CNavDTD::OpenContainer(const nsIParserNode& aNode,PRBool aUpdateStyleStack){
result=OpenHTML(aNode); break;
case eHTMLTag_body:
mHasOpenBody=PR_TRUE;
result=OpenBody(aNode); break;
case eHTMLTag_style:

View File

@ -619,6 +619,7 @@ protected:
PRBool mHasOpenForm;
PRBool mHasOpenMap;
PRBool mHasOpenHead;
PRBool mHasOpenBody;
nsDeque mTokenDeque;
nsString mFilename;
nsIDTDDebug* mDTDDebug;

View File

@ -740,7 +740,10 @@ PRInt32 nsParser::BuildModel() {
* @return ptr to token
*/
CToken* nsParser::PeekToken() {
CToken* theToken=(CToken*)mParserContext->mCurrentPos->GetCurrent();
CToken* theToken=0;
if(mParserContext)
if(mParserContext->mCurrentPos)
theToken=(CToken*)mParserContext->mCurrentPos->GetCurrent();
return theToken;
}
@ -752,8 +755,12 @@ CToken* nsParser::PeekToken() {
* @return ptr to token or NULL
*/
CToken* nsParser::PopToken() {
CToken* theToken=(CToken*)mParserContext->mCurrentPos->GetCurrent();
++(*mParserContext->mCurrentPos);
CToken* theToken=0;
if(mParserContext)
if(mParserContext->mCurrentPos) {
theToken=(CToken*)mParserContext->mCurrentPos->GetCurrent();
++(*mParserContext->mCurrentPos);
}
return theToken;
}