diff --git a/mozilla/htmlparser/src/CNavDTD.cpp b/mozilla/htmlparser/src/CNavDTD.cpp
index 9a12ab32b7f..b52aa73158e 100644
--- a/mozilla/htmlparser/src/CNavDTD.cpp
+++ b/mozilla/htmlparser/src/CNavDTD.cpp
@@ -69,6 +69,7 @@ static char gStyleTags[]={
eHTMLTag_bdo,
eHTMLTag_big,
eHTMLTag_blink,
+ eHTMLTag_center,
eHTMLTag_cite,
eHTMLTag_code,
eHTMLTag_del,
@@ -229,7 +230,7 @@ eHTMLTags CTagStack::Last() const {
class nsCTokenRecycler : public nsITokenRecycler {
public:
- enum {eCacheMaxSize=50};
+ enum {eCacheMaxSize=100};
nsCTokenRecycler();
virtual ~nsCTokenRecycler();
@@ -239,6 +240,7 @@ public:
protected:
CToken* mTokenCache[eToken_last-1][eCacheMaxSize];
PRInt32 mCount[eToken_last-1];
+ PRInt32 mTotals[eToken_last-1];
};
@@ -250,6 +252,7 @@ protected:
nsCTokenRecycler::nsCTokenRecycler() : nsITokenRecycler() {
nsCRT::zero(mTokenCache,sizeof(mTokenCache));
nsCRT::zero(mCount,sizeof(mCount));
+ nsCRT::zero(mTotals,sizeof(mTotals));
}
/**
@@ -257,6 +260,14 @@ nsCTokenRecycler::nsCTokenRecycler() : nsITokenRecycler() {
* @update gess7/25/98
*/
nsCTokenRecycler::~nsCTokenRecycler() {
+ //begin by deleting all the known (recycled tokens)...
+ int index1,index2;
+ for(index1=0;index1Reinitialize(aTag,aString);
mTokenCache[aType-1][mCount[aType-1]-1]=0;
mCount[aType-1]--;
}
else {
+ mTotals[aType-1]++;
switch(aType){
case eToken_start: result=new CStartToken(aTag); break;
case eToken_end: result=new CEndToken(aTag); break;
@@ -476,6 +489,7 @@ CNavDTD::CNavDTD() : nsIDTD(), mContextStack(), mTokenDeque(gTokenKiller) {
mSink = nsnull;
mDTDDebug=0;
mLineNumber=1;
+ mParseMode=eParseMode_navigator;
mStyleStack=new CTagStack();
nsCRT::zero(mTokenHandlers,sizeof(mTokenHandlers));
mHasOpenForm=PR_FALSE;
@@ -1200,16 +1214,21 @@ CITokenHandler* CNavDTD::AddTokenHandler(CITokenHandler* aHandler) {
}
/**
- *
+ * The parser calls this method after it's selected
+ * an constructed a DTD.
*
* @update gess 3/25/98
- * @param
- * @return
+ * @param aParser is a ptr to the controlling parser.
+ * @return nada
*/
void CNavDTD::SetParser(nsIParser* aParser) {
mParser=(nsParser*)aParser;
+ if(aParser)
+ mParseMode=aParser->GetParseMode();
+// mParseMode=eParseMode_noquirks;
}
+
/**
* This method gets called in order to set the content
* sink for this parser to dump nodes to.
@@ -1364,7 +1383,7 @@ static char gTagSet3[]={
* @param aChild -- tag enum of child container
* @return PR_TRUE if parent can contain child
*/
-PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) {
+PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
PRBool result=PR_FALSE;
@@ -1787,6 +1806,16 @@ PRBool CNavDTD::CanOmit(eHTMLTags aParent,eHTMLTags aChild) const {
result=PR_TRUE;
break;
+ case eHTMLTag_table:
+
+ if(eParseMode_noquirks!=mParseMode) {
+ if(eHTMLTag_table==GetTopNode()) {
+ result=PR_TRUE;
+ }
+ break;
+ }
+ //otherwise, we intentionally fall through...
+
default:
if(eHTMLTag_unknown==aParent)
result=PR_FALSE;
@@ -1836,6 +1865,10 @@ PRBool CNavDTD::CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild) const {
result=PR_TRUE;
break;
+ case eHTMLTag_a:
+ result=!HasOpenContainer(aChild);
+ break;
+
case eHTMLTag_html:
case eHTMLTag_body:
result=HasOpenContainer(aChild); //don't bother if they're already open...
@@ -2061,11 +2094,18 @@ PRBool CNavDTD::BackwardPropagate(CTagStack& aStack,eHTMLTags aParentTag,eHTMLTa
if(theParentTag!=eHTMLTag_unknown) {
aStack.Push(theParentTag);
}
+ if(CanContain(aParentTag,theParentTag)) {
+ //we've found a complete sequence, so push the parent...
+ theParentTag=aParentTag;
+ aStack.Push(theParentTag);
+ }
} while((theParentTag!=eHTMLTag_unknown) && (theParentTag!=aParentTag));
return PRBool(aParentTag==theParentTag);
}
+
+
/**
* This method allows the caller to determine if a form
* element is currently open.
@@ -2600,7 +2640,7 @@ CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag,
NS_PRECONDITION(mContextStack.mCount > 0, kInvalidTagStackPos);
nsresult result=NS_OK;
- CEndToken aToken(gEmpty);
+ static CEndToken aToken(gEmpty);
nsCParserNode theNode(&aToken,mLineNumber);
if((anIndex=0)) {
@@ -2710,7 +2750,8 @@ nsresult CNavDTD::CreateContextStackFor(eHTMLTags aChildTag){
if(PR_FALSE==bResult){
if(eHTMLTag_unknown!=theTop) {
- bResult=BackwardPropagate(kPropagationStack,theTop,aChildTag);
+ if(theTop!=aChildTag) //dont even bother if we're already inside a similar element...
+ bResult=BackwardPropagate(kPropagationStack,theTop,aChildTag);
/*****************************************************************************
OH NOOOO!...
@@ -3100,7 +3141,7 @@ nsresult
CNavDTD::ConsumeWhitespace(PRUnichar aChar,
CScanner& aScanner,
CToken*& aToken) {
- aToken = gTokenRecycler.CreateTokenOfType(eToken_whitespace,eHTMLTag_unknown,gEmpty);
+ aToken = gTokenRecycler.CreateTokenOfType(eToken_whitespace,eHTMLTag_whitespace,gEmpty);
nsresult result=kNoError;
if(aToken) {
result=aToken->Consume(aChar,aScanner);
diff --git a/mozilla/htmlparser/src/CNavDTD.h b/mozilla/htmlparser/src/CNavDTD.h
index 75c6cf1c53f..56cd98f355d 100644
--- a/mozilla/htmlparser/src/CNavDTD.h
+++ b/mozilla/htmlparser/src/CNavDTD.h
@@ -80,6 +80,7 @@
#include "nsIDTD.h"
#include "nsISupports.h"
+#include "nsIParser.h"
#include "nsHTMLTokens.h"
#include "nshtmlpars.h"
#include "nsVoidArray.h"
@@ -303,7 +304,7 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
* @param aChild -- int tag of child container
* @return PR_TRUE if parent can contain child
*/
- virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild);
+ virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild) const;
/**
* This method is called to determine whether a tag
@@ -611,6 +612,7 @@ protected:
nsString mFilename;
nsIDTDDebug* mDTDDebug;
PRInt32 mLineNumber;
+ eParseMode mParseMode;
};
diff --git a/mozilla/htmlparser/src/CRtfDTD.cpp b/mozilla/htmlparser/src/CRtfDTD.cpp
index 6f90c69a580..6379443cf51 100644
--- a/mozilla/htmlparser/src/CRtfDTD.cpp
+++ b/mozilla/htmlparser/src/CRtfDTD.cpp
@@ -470,7 +470,7 @@ void CRtfDTD::SetVerification(PRBool aEnabled){
* @param aChild -- int tag of child container
* @return PR_TRUE if parent can contain child
*/
-PRBool CRtfDTD::CanContain(PRInt32 aParent,PRInt32 aChild){
+PRBool CRtfDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const{
PRBool result=PR_FALSE;
return result;
}
diff --git a/mozilla/htmlparser/src/CRtfDTD.h b/mozilla/htmlparser/src/CRtfDTD.h
index 971831a6045..92224c17ef7 100644
--- a/mozilla/htmlparser/src/CRtfDTD.h
+++ b/mozilla/htmlparser/src/CRtfDTD.h
@@ -345,7 +345,7 @@ class CRtfDTD : public nsIDTD {
* @param aChild -- int tag of child container
* @return PR_TRUE if parent can contain child
*/
- virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild);
+ virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild) const;
/**
* Retrieve a ptr to the global token recycler...
diff --git a/mozilla/htmlparser/src/nsIDTD.h b/mozilla/htmlparser/src/nsIDTD.h
index 8b74354cba6..b44c3c2d4fe 100644
--- a/mozilla/htmlparser/src/nsIDTD.h
+++ b/mozilla/htmlparser/src/nsIDTD.h
@@ -174,7 +174,7 @@ class nsIDTD : public nsISupports {
* @param aChild -- int tag of child container
* @return PR_TRUE if parent can contain child
*/
- virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild)=0;
+ virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild) const =0;
/**
* Called by the parser to initiate dtd verification of the
diff --git a/mozilla/htmlparser/src/nsIParser.h b/mozilla/htmlparser/src/nsIParser.h
index 176a6a147d2..d6d178c5840 100644
--- a/mozilla/htmlparser/src/nsIParser.h
+++ b/mozilla/htmlparser/src/nsIParser.h
@@ -47,6 +47,16 @@ class nsIStreamObserver;
class nsString;
class nsIURL;
+
+enum eParseMode {
+
+ eParseMode_unknown=0,
+ eParseMode_navigator,
+ eParseMode_noquirks,
+ eParseMode_other,
+ eParseMode_autodetect
+};
+
/**
* This class defines the iparser interface. This XPCOM
* inteface is all that parser clients ever need to see.
@@ -104,6 +114,16 @@ class nsIParser : public nsISupports {
*/
virtual PRInt32 BuildModel(void)=0;
+
+ /**
+ * Retrieve the parse mode from the parser...
+ *
+ * @update gess 6/9/98
+ * @return ptr to scanner
+ */
+ virtual eParseMode GetParseMode(void)=0;
+
+
};
#endif
diff --git a/mozilla/htmlparser/src/nsParser.cpp b/mozilla/htmlparser/src/nsParser.cpp
index 8f375b1c2be..e991e4d3592 100644
--- a/mozilla/htmlparser/src/nsParser.cpp
+++ b/mozilla/htmlparser/src/nsParser.cpp
@@ -244,11 +244,10 @@ void nsParser::RegisterDTD(nsIDTD* aDTD){
}
/**
- *
+ * Retrieve scanner from topmost parsecontext
*
* @update gess 6/9/98
- * @param
- * @return
+ * @return ptr to internal scanner
*/
CScanner* nsParser::GetScanner(void){
if(mParserContext)
@@ -256,6 +255,20 @@ CScanner* nsParser::GetScanner(void){
return 0;
}
+
+/**
+ * Retrieve parsemode from topmost parser context
+ *
+ * @update gess 6/9/98
+ * @return parsemode
+ */
+eParseMode nsParser::GetParseMode(void){
+ if(mParserContext)
+ return mParserContext->mParseMode;
+ return eParseMode_unknown;
+}
+
+
/**
*
*
@@ -473,9 +486,7 @@ PRInt32 nsParser::Parse(fstream& aStream,PRBool aVerifyEnabled){
//ok, time to create our tokenizer and begin the process
CParserContext* pc=new CParserContext(new CScanner(kUnknownFilename,aStream,PR_FALSE),&aStream,0);
PushContext(*pc);
-
pc->mSourceType="text/html";
-
mParserContext->mScanner->Eof();
if(eValidDetect==AutoDetectContentType(mParserContext->mScanner->GetBuffer(),
mParserContext->mSourceType)) {
diff --git a/mozilla/htmlparser/src/nsParser.h b/mozilla/htmlparser/src/nsParser.h
index b97cbaba9e0..1561ba1128b 100644
--- a/mozilla/htmlparser/src/nsParser.h
+++ b/mozilla/htmlparser/src/nsParser.h
@@ -104,11 +104,18 @@ friend class CTokenHandler;
virtual void RegisterDTD(nsIDTD* aDTD);
/**
- *
+ * Retrieve the scanner from the topmost parser context
*
* @update gess 6/9/98
- * @param
- * @return
+ * @return ptr to scanner
+ */
+ virtual eParseMode GetParseMode(void);
+
+ /**
+ * Retrieve the scanner from the topmost parser context
+ *
+ * @update gess 6/9/98
+ * @return ptr to scanner
*/
virtual CScanner* GetScanner(void);
diff --git a/mozilla/htmlparser/src/nsParserTypes.h b/mozilla/htmlparser/src/nsParserTypes.h
index 3cc5f343452..9ed17b38d49 100644
--- a/mozilla/htmlparser/src/nsParserTypes.h
+++ b/mozilla/htmlparser/src/nsParserTypes.h
@@ -34,14 +34,6 @@
#include "prtypes.h"
#include "nsError.h"
-enum eParseMode {
-
- eParseMode_unknown=0,
- eParseMode_navigator,
- eParseMode_other,
- eParseMode_autodetect
-};
-
const PRInt32 kEOF = 10000;
const PRInt32 kUnknownError = 10001;
diff --git a/mozilla/htmlparser/src/nsToken.cpp b/mozilla/htmlparser/src/nsToken.cpp
index 32bc47a8a7f..18612f774c2 100644
--- a/mozilla/htmlparser/src/nsToken.cpp
+++ b/mozilla/htmlparser/src/nsToken.cpp
@@ -20,6 +20,9 @@
#include "nsScanner.h"
static int TokenCount=0;
+static int DelTokenCount=0;
+
+int CToken::GetTokenCount(){return TokenCount-DelTokenCount;}
/**************************************************************
@@ -67,6 +70,7 @@ CToken::CToken(const char* aName) : mTextValue(aName) {
* @update gess 3/25/98
*/
CToken::~CToken() {
+ DelTokenCount++;
}
@@ -115,7 +119,7 @@ void CToken::DebugDumpToken(ostream& anOutputStream) {
for(i=0;iReinitialize(aTag,aString);
mTokenCache[aType-1][mCount[aType-1]-1]=0;
mCount[aType-1]--;
}
else {
+ mTotals[aType-1]++;
switch(aType){
case eToken_start: result=new CStartToken(aTag); break;
case eToken_end: result=new CEndToken(aTag); break;
@@ -476,6 +489,7 @@ CNavDTD::CNavDTD() : nsIDTD(), mContextStack(), mTokenDeque(gTokenKiller) {
mSink = nsnull;
mDTDDebug=0;
mLineNumber=1;
+ mParseMode=eParseMode_navigator;
mStyleStack=new CTagStack();
nsCRT::zero(mTokenHandlers,sizeof(mTokenHandlers));
mHasOpenForm=PR_FALSE;
@@ -1200,16 +1214,21 @@ CITokenHandler* CNavDTD::AddTokenHandler(CITokenHandler* aHandler) {
}
/**
- *
+ * The parser calls this method after it's selected
+ * an constructed a DTD.
*
* @update gess 3/25/98
- * @param
- * @return
+ * @param aParser is a ptr to the controlling parser.
+ * @return nada
*/
void CNavDTD::SetParser(nsIParser* aParser) {
mParser=(nsParser*)aParser;
+ if(aParser)
+ mParseMode=aParser->GetParseMode();
+// mParseMode=eParseMode_noquirks;
}
+
/**
* This method gets called in order to set the content
* sink for this parser to dump nodes to.
@@ -1364,7 +1383,7 @@ static char gTagSet3[]={
* @param aChild -- tag enum of child container
* @return PR_TRUE if parent can contain child
*/
-PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) {
+PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
PRBool result=PR_FALSE;
@@ -1787,6 +1806,16 @@ PRBool CNavDTD::CanOmit(eHTMLTags aParent,eHTMLTags aChild) const {
result=PR_TRUE;
break;
+ case eHTMLTag_table:
+
+ if(eParseMode_noquirks!=mParseMode) {
+ if(eHTMLTag_table==GetTopNode()) {
+ result=PR_TRUE;
+ }
+ break;
+ }
+ //otherwise, we intentionally fall through...
+
default:
if(eHTMLTag_unknown==aParent)
result=PR_FALSE;
@@ -1836,6 +1865,10 @@ PRBool CNavDTD::CanOmitEndTag(eHTMLTags aParent,eHTMLTags aChild) const {
result=PR_TRUE;
break;
+ case eHTMLTag_a:
+ result=!HasOpenContainer(aChild);
+ break;
+
case eHTMLTag_html:
case eHTMLTag_body:
result=HasOpenContainer(aChild); //don't bother if they're already open...
@@ -2061,11 +2094,18 @@ PRBool CNavDTD::BackwardPropagate(CTagStack& aStack,eHTMLTags aParentTag,eHTMLTa
if(theParentTag!=eHTMLTag_unknown) {
aStack.Push(theParentTag);
}
+ if(CanContain(aParentTag,theParentTag)) {
+ //we've found a complete sequence, so push the parent...
+ theParentTag=aParentTag;
+ aStack.Push(theParentTag);
+ }
} while((theParentTag!=eHTMLTag_unknown) && (theParentTag!=aParentTag));
return PRBool(aParentTag==theParentTag);
}
+
+
/**
* This method allows the caller to determine if a form
* element is currently open.
@@ -2600,7 +2640,7 @@ CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTag,
NS_PRECONDITION(mContextStack.mCount > 0, kInvalidTagStackPos);
nsresult result=NS_OK;
- CEndToken aToken(gEmpty);
+ static CEndToken aToken(gEmpty);
nsCParserNode theNode(&aToken,mLineNumber);
if((anIndex=0)) {
@@ -2710,7 +2750,8 @@ nsresult CNavDTD::CreateContextStackFor(eHTMLTags aChildTag){
if(PR_FALSE==bResult){
if(eHTMLTag_unknown!=theTop) {
- bResult=BackwardPropagate(kPropagationStack,theTop,aChildTag);
+ if(theTop!=aChildTag) //dont even bother if we're already inside a similar element...
+ bResult=BackwardPropagate(kPropagationStack,theTop,aChildTag);
/*****************************************************************************
OH NOOOO!...
@@ -3100,7 +3141,7 @@ nsresult
CNavDTD::ConsumeWhitespace(PRUnichar aChar,
CScanner& aScanner,
CToken*& aToken) {
- aToken = gTokenRecycler.CreateTokenOfType(eToken_whitespace,eHTMLTag_unknown,gEmpty);
+ aToken = gTokenRecycler.CreateTokenOfType(eToken_whitespace,eHTMLTag_whitespace,gEmpty);
nsresult result=kNoError;
if(aToken) {
result=aToken->Consume(aChar,aScanner);
diff --git a/mozilla/parser/htmlparser/src/CNavDTD.h b/mozilla/parser/htmlparser/src/CNavDTD.h
index 75c6cf1c53f..56cd98f355d 100644
--- a/mozilla/parser/htmlparser/src/CNavDTD.h
+++ b/mozilla/parser/htmlparser/src/CNavDTD.h
@@ -80,6 +80,7 @@
#include "nsIDTD.h"
#include "nsISupports.h"
+#include "nsIParser.h"
#include "nsHTMLTokens.h"
#include "nshtmlpars.h"
#include "nsVoidArray.h"
@@ -303,7 +304,7 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
* @param aChild -- int tag of child container
* @return PR_TRUE if parent can contain child
*/
- virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild);
+ virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild) const;
/**
* This method is called to determine whether a tag
@@ -611,6 +612,7 @@ protected:
nsString mFilename;
nsIDTDDebug* mDTDDebug;
PRInt32 mLineNumber;
+ eParseMode mParseMode;
};
diff --git a/mozilla/parser/htmlparser/src/CRtfDTD.cpp b/mozilla/parser/htmlparser/src/CRtfDTD.cpp
index 6f90c69a580..6379443cf51 100644
--- a/mozilla/parser/htmlparser/src/CRtfDTD.cpp
+++ b/mozilla/parser/htmlparser/src/CRtfDTD.cpp
@@ -470,7 +470,7 @@ void CRtfDTD::SetVerification(PRBool aEnabled){
* @param aChild -- int tag of child container
* @return PR_TRUE if parent can contain child
*/
-PRBool CRtfDTD::CanContain(PRInt32 aParent,PRInt32 aChild){
+PRBool CRtfDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const{
PRBool result=PR_FALSE;
return result;
}
diff --git a/mozilla/parser/htmlparser/src/CRtfDTD.h b/mozilla/parser/htmlparser/src/CRtfDTD.h
index 971831a6045..92224c17ef7 100644
--- a/mozilla/parser/htmlparser/src/CRtfDTD.h
+++ b/mozilla/parser/htmlparser/src/CRtfDTD.h
@@ -345,7 +345,7 @@ class CRtfDTD : public nsIDTD {
* @param aChild -- int tag of child container
* @return PR_TRUE if parent can contain child
*/
- virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild);
+ virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild) const;
/**
* Retrieve a ptr to the global token recycler...
diff --git a/mozilla/parser/htmlparser/src/nsIDTD.h b/mozilla/parser/htmlparser/src/nsIDTD.h
index 8b74354cba6..b44c3c2d4fe 100644
--- a/mozilla/parser/htmlparser/src/nsIDTD.h
+++ b/mozilla/parser/htmlparser/src/nsIDTD.h
@@ -174,7 +174,7 @@ class nsIDTD : public nsISupports {
* @param aChild -- int tag of child container
* @return PR_TRUE if parent can contain child
*/
- virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild)=0;
+ virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild) const =0;
/**
* Called by the parser to initiate dtd verification of the
diff --git a/mozilla/parser/htmlparser/src/nsIParser.h b/mozilla/parser/htmlparser/src/nsIParser.h
index 176a6a147d2..d6d178c5840 100644
--- a/mozilla/parser/htmlparser/src/nsIParser.h
+++ b/mozilla/parser/htmlparser/src/nsIParser.h
@@ -47,6 +47,16 @@ class nsIStreamObserver;
class nsString;
class nsIURL;
+
+enum eParseMode {
+
+ eParseMode_unknown=0,
+ eParseMode_navigator,
+ eParseMode_noquirks,
+ eParseMode_other,
+ eParseMode_autodetect
+};
+
/**
* This class defines the iparser interface. This XPCOM
* inteface is all that parser clients ever need to see.
@@ -104,6 +114,16 @@ class nsIParser : public nsISupports {
*/
virtual PRInt32 BuildModel(void)=0;
+
+ /**
+ * Retrieve the parse mode from the parser...
+ *
+ * @update gess 6/9/98
+ * @return ptr to scanner
+ */
+ virtual eParseMode GetParseMode(void)=0;
+
+
};
#endif
diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp
index 8f375b1c2be..e991e4d3592 100644
--- a/mozilla/parser/htmlparser/src/nsParser.cpp
+++ b/mozilla/parser/htmlparser/src/nsParser.cpp
@@ -244,11 +244,10 @@ void nsParser::RegisterDTD(nsIDTD* aDTD){
}
/**
- *
+ * Retrieve scanner from topmost parsecontext
*
* @update gess 6/9/98
- * @param
- * @return
+ * @return ptr to internal scanner
*/
CScanner* nsParser::GetScanner(void){
if(mParserContext)
@@ -256,6 +255,20 @@ CScanner* nsParser::GetScanner(void){
return 0;
}
+
+/**
+ * Retrieve parsemode from topmost parser context
+ *
+ * @update gess 6/9/98
+ * @return parsemode
+ */
+eParseMode nsParser::GetParseMode(void){
+ if(mParserContext)
+ return mParserContext->mParseMode;
+ return eParseMode_unknown;
+}
+
+
/**
*
*
@@ -473,9 +486,7 @@ PRInt32 nsParser::Parse(fstream& aStream,PRBool aVerifyEnabled){
//ok, time to create our tokenizer and begin the process
CParserContext* pc=new CParserContext(new CScanner(kUnknownFilename,aStream,PR_FALSE),&aStream,0);
PushContext(*pc);
-
pc->mSourceType="text/html";
-
mParserContext->mScanner->Eof();
if(eValidDetect==AutoDetectContentType(mParserContext->mScanner->GetBuffer(),
mParserContext->mSourceType)) {
diff --git a/mozilla/parser/htmlparser/src/nsParser.h b/mozilla/parser/htmlparser/src/nsParser.h
index b97cbaba9e0..1561ba1128b 100644
--- a/mozilla/parser/htmlparser/src/nsParser.h
+++ b/mozilla/parser/htmlparser/src/nsParser.h
@@ -104,11 +104,18 @@ friend class CTokenHandler;
virtual void RegisterDTD(nsIDTD* aDTD);
/**
- *
+ * Retrieve the scanner from the topmost parser context
*
* @update gess 6/9/98
- * @param
- * @return
+ * @return ptr to scanner
+ */
+ virtual eParseMode GetParseMode(void);
+
+ /**
+ * Retrieve the scanner from the topmost parser context
+ *
+ * @update gess 6/9/98
+ * @return ptr to scanner
*/
virtual CScanner* GetScanner(void);
diff --git a/mozilla/parser/htmlparser/src/nsParserTypes.h b/mozilla/parser/htmlparser/src/nsParserTypes.h
index 3cc5f343452..9ed17b38d49 100644
--- a/mozilla/parser/htmlparser/src/nsParserTypes.h
+++ b/mozilla/parser/htmlparser/src/nsParserTypes.h
@@ -34,14 +34,6 @@
#include "prtypes.h"
#include "nsError.h"
-enum eParseMode {
-
- eParseMode_unknown=0,
- eParseMode_navigator,
- eParseMode_other,
- eParseMode_autodetect
-};
-
const PRInt32 kEOF = 10000;
const PRInt32 kUnknownError = 10001;
diff --git a/mozilla/parser/htmlparser/src/nsToken.cpp b/mozilla/parser/htmlparser/src/nsToken.cpp
index 32bc47a8a7f..18612f774c2 100644
--- a/mozilla/parser/htmlparser/src/nsToken.cpp
+++ b/mozilla/parser/htmlparser/src/nsToken.cpp
@@ -20,6 +20,9 @@
#include "nsScanner.h"
static int TokenCount=0;
+static int DelTokenCount=0;
+
+int CToken::GetTokenCount(){return TokenCount-DelTokenCount;}
/**************************************************************
@@ -67,6 +70,7 @@ CToken::CToken(const char* aName) : mTextValue(aName) {
* @update gess 3/25/98
*/
CToken::~CToken() {
+ DelTokenCount++;
}
@@ -115,7 +119,7 @@ void CToken::DebugDumpToken(ostream& anOutputStream) {
for(i=0;i