diff --git a/mozilla/htmlparser/src/nsExpatDTD.cpp b/mozilla/htmlparser/src/nsExpatDTD.cpp
index 23c494b7446..510b1494326 100644
--- a/mozilla/htmlparser/src/nsExpatDTD.cpp
+++ b/mozilla/htmlparser/src/nsExpatDTD.cpp
@@ -307,7 +307,7 @@ void nsExpatDTD::SetupExpatCallbacks(void) {
*/
nsITokenizer* nsExpatDTD::GetTokenizer(void) {
if(!mTokenizer) {
- mTokenizer=new nsExpatTokenizer(this);
+ mTokenizer=new nsExpatTokenizer();
mExpatParser = XML_ParserCreate(NULL);
if (mExpatParser) {
SetupExpatCallbacks();
diff --git a/mozilla/htmlparser/src/nsExpatTokenizer.cpp b/mozilla/htmlparser/src/nsExpatTokenizer.cpp
index 8800ca77d33..d40715ec8d8 100644
--- a/mozilla/htmlparser/src/nsExpatTokenizer.cpp
+++ b/mozilla/htmlparser/src/nsExpatTokenizer.cpp
@@ -95,6 +95,25 @@ NS_HTMLPARS nsresult NS_New_Expat_Tokenizer(nsIDTD** aInstancePtrResult) {
NS_IMPL_ADDREF(nsExpatTokenizer)
NS_IMPL_RELEASE(nsExpatTokenizer)
+/**
+ * Sets up the callbacks for the expat parser
+ * @update nra 2/24/99
+ * @param none
+ * @return none
+ */
+void nsExpatTokenizer::SetupExpatCallbacks(void) {
+ if (mExpatParser) {
+ XML_SetElementHandler(mExpatParser, HandleStartElement, HandleEndElement);
+ XML_SetCharacterDataHandler(mExpatParser, HandleCharacterData);
+ XML_SetProcessingInstructionHandler(mExpatParser, HandleProcessingInstruction);
+ // XML_SetDefaultHandler(mExpatParser, NULL);
+ // XML_SetUnparsedEntityDeclHandler(mExpatParser, NULL);
+ XML_SetNotationDeclHandler(mExpatParser, HandleNotationDecl);
+ // XML_SetExternalEntityRefHandler(mExpatParser, NULL);
+ // XML_SetUnknownEncodingHandler(mExpatParser, NULL, NULL);
+ }
+}
+
/**
* Default constructor
@@ -103,9 +122,12 @@ NS_IMPL_RELEASE(nsExpatTokenizer)
* @param
* @return
*/
-nsExpatTokenizer::nsExpatTokenizer(nsExpatDTD *aDTD) : nsHTMLTokenizer() {
+nsExpatTokenizer::nsExpatTokenizer() : nsHTMLTokenizer() {
NS_INIT_REFCNT();
- mExpatDTD = aDTD;
+ mExpatParser = XML_ParserCreate(NULL);
+ if (mExpatParser) {
+ SetupExpatCallbacks();
+ }
}
/**
@@ -116,7 +138,8 @@ nsExpatTokenizer::nsExpatTokenizer(nsExpatDTD *aDTD) : nsHTMLTokenizer() {
* @return
*/
nsExpatTokenizer::~nsExpatTokenizer(){
-
+ if (mExpatParser)
+ XML_ParserFree(mExpatParser);
}
@@ -124,6 +147,23 @@ nsExpatTokenizer::~nsExpatTokenizer(){
Here begins the real working methods for the tokenizer.
*******************************************************************/
+nsresult nsExpatTokenizer::ParseXMLBuffer(const char *buffer){
+ nsresult result=NS_OK;
+ if (mExpatParser) {
+ if (!XML_Parse(mExpatParser, buffer, strlen(buffer), PR_FALSE)) {
+ // XXX Add code here to implement error propagation to the
+ // content sink.
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::ParseXMLBuffer(): \
+ Error propogation from expat not yet implemented.");
+ result = NS_ERROR_FAILURE;
+ }
+ }
+ else {
+ result = NS_ERROR_FAILURE;
+ }
+ return result;
+}
+
/**
* This method repeatedly called by the tokenizer.
* Each time, we determine the kind of token were about to
@@ -149,16 +189,81 @@ nsresult nsExpatTokenizer::ConsumeToken(nsScanner& aScanner) {
// XXX Rick should add a method to the scanner that gives me the
// entire contents of the scanner's buffer without calling
// GetChar() repeatedly.
- result = aScanner.ReadUntil(buffer, '\0', PR_FALSE);
- if (aScanner.Eof() == result || NS_OK == result) {
+ buffer = aScanner.GetBuffer();
+ if (buffer) {
expatBuffer = buffer.ToNewCString();
- if (expatBuffer && mExpatDTD) {
- // XXX Who takes ownership of expatBuffer?
- result = mExpatDTD->ParseXMLBuffer(expatBuffer);
+ if (expatBuffer) {
+ result = ParseXMLBuffer(expatBuffer);
delete [] expatBuffer;
}
}
return result;
}
+
+/***************************************/
+/* Expat Callback Functions start here */
+/***************************************/
+
+void nsExpatTokenizer::HandleStartElement(void *userData, const XML_Char *name, const XML_Char **atts)
+{
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::HandleStartElement() not yet implemented.");
+}
+
+void nsExpatTokenizer::HandleEndElement(void *userData, const XML_Char *name)
+{
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::HandleEndElement() not yet implemented.");
+}
+
+void nsExpatTokenizer::HandleCharacterData(void *userData, const XML_Char *s, int len)
+{
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::HandleCharacterData() not yet implemented.");
+}
+
+void nsExpatTokenizer::HandleProcessingInstruction(void *userData,
+ const XML_Char *target,
+ const XML_Char *data)
+{
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::HandleProcessingInstruction() not yet implemented.");
+}
+
+void nsExpatTokenizer::HandleDefault(void *userData, const XML_Char *s, int len)
+{
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::HandleDefault() not yet implemented.");
+}
+
+void nsExpatTokenizer::HandleUnparsedEntityDecl(void *userData,
+ const XML_Char *entityName,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId,
+ const XML_Char *notationName)
+{
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::HandleUnparsedEntityDecl() not yet implemented.");
+}
+
+void nsExpatTokenizer::HandleNotationDecl(void *userData,
+ const XML_Char *notationName,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId)
+{
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::HandleNotationDecl() not yet implemented.");
+}
+
+void nsExpatTokenizer::HandleExternalEntityRef(XML_Parser parser,
+ const XML_Char *openEntityNames,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId)
+{
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::HandleExternalEntityRef() not yet implemented.");
+}
+
+void nsExpatTokenizer::HandleUnknownEncoding(void *encodingHandlerData,
+ const XML_Char *name,
+ XML_Encoding *info)
+{
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::HandleUnknownEncoding() not yet implemented.");
+}
diff --git a/mozilla/htmlparser/src/nsExpatTokenizer.h b/mozilla/htmlparser/src/nsExpatTokenizer.h
index 138e86f5c9e..d7bc6002f45 100644
--- a/mozilla/htmlparser/src/nsExpatTokenizer.h
+++ b/mozilla/htmlparser/src/nsExpatTokenizer.h
@@ -29,7 +29,7 @@
#include "nsISupports.h"
#include "nsHTMLTokenizer.h"
#include "prtypes.h"
-#include "nsExpatDTD.h"
+#include "xmlparse.h"
#define NS_EXPATTOKENIZER_IID \
{0x483836aa, 0xcabe, 0x11d2, { 0xab, 0xcb, 0x0, 0x10, 0x4b, 0x98, 0x3f, 0xd4 }}
@@ -45,7 +45,7 @@
CLASS_EXPORT_HTMLPARS nsExpatTokenizer : public nsHTMLTokenizer {
public:
- nsExpatTokenizer(nsExpatDTD *aDTD=0);
+ nsExpatTokenizer();
virtual ~nsExpatTokenizer();
NS_DECL_ISUPPORTS
@@ -54,7 +54,51 @@ public:
virtual nsresult ConsumeToken(nsScanner& aScanner);
protected:
- nsExpatDTD *mExpatDTD;
+
+ /**
+ * Parse an XML buffer using expat
+ * @update nra 2/29/99
+ * @return NS_ERROR_FAILURE if expat encounters an error, else NS_OK
+ */
+ nsresult ParseXMLBuffer(const char *buffer);
+
+ /**
+ * Sets up the callbacks for the expat parser
+ * @update nra 2/24/99
+ * @param none
+ * @return none
+ */
+ void SetupExpatCallbacks(void);
+
+ /* The callback handlers that get called from the expat parser */
+ static void HandleStartElement(void *userData, const XML_Char *name, const XML_Char **atts);
+ static void HandleEndElement(void *userData, const XML_Char *name);
+ static void HandleCharacterData(void *userData, const XML_Char *s, int len);
+ static void HandleProcessingInstruction(void *userData,
+ const XML_Char *target,
+ const XML_Char *data);
+ static void HandleDefault(void *userData, const XML_Char *s, int len);
+ static void HandleUnparsedEntityDecl(void *userData,
+ const XML_Char *entityName,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId,
+ const XML_Char *notationName);
+ static void HandleNotationDecl(void *userData,
+ const XML_Char *notationName,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId);
+ static void HandleExternalEntityRef(XML_Parser parser,
+ const XML_Char *openEntityNames,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId);
+ static void HandleUnknownEncoding(void *encodingHandlerData,
+ const XML_Char *name,
+ XML_Encoding *info);
+
+ XML_Parser mExpatParser;
};
extern NS_HTMLPARS nsresult NS_Expat_Tokenizer(nsIDTD** aInstancePtrResult);
diff --git a/mozilla/htmlparser/src/nsParser.cpp b/mozilla/htmlparser/src/nsParser.cpp
index 7d49933515d..2d6b29a8d6d 100644
--- a/mozilla/htmlparser/src/nsParser.cpp
+++ b/mozilla/htmlparser/src/nsParser.cpp
@@ -31,9 +31,6 @@
#include "CNavDTD.h"
#include "nsWellFormedDTD.h"
#include "nsViewSourceHTML.h" //uncomment this to partially enable viewsource...
-#ifdef EXPAT
- #include "nsExpatDTD.h"
-#endif
#undef rickgdebug
#ifdef rickgdebug
@@ -93,12 +90,7 @@ public:
nsIDTD* theDTD;
-#ifndef EXPAT
NS_NewWellFormed_DTD(&theDTD);
-#else
- NS_New_Expat_DTD(&theDTD);
-#endif
-
RegisterDTD(theDTD);
NS_NewNavHTMLDTD(&theDTD); //do this as the default HTML DTD...
diff --git a/mozilla/htmlparser/src/nsWellFormedDTD.cpp b/mozilla/htmlparser/src/nsWellFormedDTD.cpp
index 12fd485b7e0..7082fecc7f2 100644
--- a/mozilla/htmlparser/src/nsWellFormedDTD.cpp
+++ b/mozilla/htmlparser/src/nsWellFormedDTD.cpp
@@ -35,6 +35,9 @@
#include "nsIContentSink.h"
#include "nsIHTMLContentSink.h"
#include "nsXMLTokenizer.h"
+#ifdef EXPAT
+ #include "nsExpatTokenizer.h"
+#endif
#include "prenv.h" //this is here for debug reasons...
#include "prtypes.h" //this is here for debug reasons...
@@ -136,6 +139,10 @@ CWellFormedDTD::CWellFormedDTD() : nsIDTD() {
*/
CWellFormedDTD::~CWellFormedDTD(){
mParser=0; //just to prove we destructed...
+#ifdef EXPAT
+ if (mTokenizer)
+ delete (nsExpatTokenizer *) mTokenizer;
+#endif
}
/**
@@ -322,8 +329,13 @@ nsITokenRecycler* CWellFormedDTD::GetTokenRecycler(void){
* @return ptr to tokenizer
*/
nsITokenizer* CWellFormedDTD::GetTokenizer(void) {
- if(!mTokenizer)
+ if(!mTokenizer) {
+#ifndef EXPAT
mTokenizer=new nsXMLTokenizer();
+#else
+ mTokenizer = new nsExpatTokenizer();
+#endif
+ }
return mTokenizer;
}
diff --git a/mozilla/parser/htmlparser/src/nsExpatDTD.cpp b/mozilla/parser/htmlparser/src/nsExpatDTD.cpp
index 23c494b7446..510b1494326 100644
--- a/mozilla/parser/htmlparser/src/nsExpatDTD.cpp
+++ b/mozilla/parser/htmlparser/src/nsExpatDTD.cpp
@@ -307,7 +307,7 @@ void nsExpatDTD::SetupExpatCallbacks(void) {
*/
nsITokenizer* nsExpatDTD::GetTokenizer(void) {
if(!mTokenizer) {
- mTokenizer=new nsExpatTokenizer(this);
+ mTokenizer=new nsExpatTokenizer();
mExpatParser = XML_ParserCreate(NULL);
if (mExpatParser) {
SetupExpatCallbacks();
diff --git a/mozilla/parser/htmlparser/src/nsExpatTokenizer.cpp b/mozilla/parser/htmlparser/src/nsExpatTokenizer.cpp
index 8800ca77d33..d40715ec8d8 100644
--- a/mozilla/parser/htmlparser/src/nsExpatTokenizer.cpp
+++ b/mozilla/parser/htmlparser/src/nsExpatTokenizer.cpp
@@ -95,6 +95,25 @@ NS_HTMLPARS nsresult NS_New_Expat_Tokenizer(nsIDTD** aInstancePtrResult) {
NS_IMPL_ADDREF(nsExpatTokenizer)
NS_IMPL_RELEASE(nsExpatTokenizer)
+/**
+ * Sets up the callbacks for the expat parser
+ * @update nra 2/24/99
+ * @param none
+ * @return none
+ */
+void nsExpatTokenizer::SetupExpatCallbacks(void) {
+ if (mExpatParser) {
+ XML_SetElementHandler(mExpatParser, HandleStartElement, HandleEndElement);
+ XML_SetCharacterDataHandler(mExpatParser, HandleCharacterData);
+ XML_SetProcessingInstructionHandler(mExpatParser, HandleProcessingInstruction);
+ // XML_SetDefaultHandler(mExpatParser, NULL);
+ // XML_SetUnparsedEntityDeclHandler(mExpatParser, NULL);
+ XML_SetNotationDeclHandler(mExpatParser, HandleNotationDecl);
+ // XML_SetExternalEntityRefHandler(mExpatParser, NULL);
+ // XML_SetUnknownEncodingHandler(mExpatParser, NULL, NULL);
+ }
+}
+
/**
* Default constructor
@@ -103,9 +122,12 @@ NS_IMPL_RELEASE(nsExpatTokenizer)
* @param
* @return
*/
-nsExpatTokenizer::nsExpatTokenizer(nsExpatDTD *aDTD) : nsHTMLTokenizer() {
+nsExpatTokenizer::nsExpatTokenizer() : nsHTMLTokenizer() {
NS_INIT_REFCNT();
- mExpatDTD = aDTD;
+ mExpatParser = XML_ParserCreate(NULL);
+ if (mExpatParser) {
+ SetupExpatCallbacks();
+ }
}
/**
@@ -116,7 +138,8 @@ nsExpatTokenizer::nsExpatTokenizer(nsExpatDTD *aDTD) : nsHTMLTokenizer() {
* @return
*/
nsExpatTokenizer::~nsExpatTokenizer(){
-
+ if (mExpatParser)
+ XML_ParserFree(mExpatParser);
}
@@ -124,6 +147,23 @@ nsExpatTokenizer::~nsExpatTokenizer(){
Here begins the real working methods for the tokenizer.
*******************************************************************/
+nsresult nsExpatTokenizer::ParseXMLBuffer(const char *buffer){
+ nsresult result=NS_OK;
+ if (mExpatParser) {
+ if (!XML_Parse(mExpatParser, buffer, strlen(buffer), PR_FALSE)) {
+ // XXX Add code here to implement error propagation to the
+ // content sink.
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::ParseXMLBuffer(): \
+ Error propogation from expat not yet implemented.");
+ result = NS_ERROR_FAILURE;
+ }
+ }
+ else {
+ result = NS_ERROR_FAILURE;
+ }
+ return result;
+}
+
/**
* This method repeatedly called by the tokenizer.
* Each time, we determine the kind of token were about to
@@ -149,16 +189,81 @@ nsresult nsExpatTokenizer::ConsumeToken(nsScanner& aScanner) {
// XXX Rick should add a method to the scanner that gives me the
// entire contents of the scanner's buffer without calling
// GetChar() repeatedly.
- result = aScanner.ReadUntil(buffer, '\0', PR_FALSE);
- if (aScanner.Eof() == result || NS_OK == result) {
+ buffer = aScanner.GetBuffer();
+ if (buffer) {
expatBuffer = buffer.ToNewCString();
- if (expatBuffer && mExpatDTD) {
- // XXX Who takes ownership of expatBuffer?
- result = mExpatDTD->ParseXMLBuffer(expatBuffer);
+ if (expatBuffer) {
+ result = ParseXMLBuffer(expatBuffer);
delete [] expatBuffer;
}
}
return result;
}
+
+/***************************************/
+/* Expat Callback Functions start here */
+/***************************************/
+
+void nsExpatTokenizer::HandleStartElement(void *userData, const XML_Char *name, const XML_Char **atts)
+{
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::HandleStartElement() not yet implemented.");
+}
+
+void nsExpatTokenizer::HandleEndElement(void *userData, const XML_Char *name)
+{
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::HandleEndElement() not yet implemented.");
+}
+
+void nsExpatTokenizer::HandleCharacterData(void *userData, const XML_Char *s, int len)
+{
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::HandleCharacterData() not yet implemented.");
+}
+
+void nsExpatTokenizer::HandleProcessingInstruction(void *userData,
+ const XML_Char *target,
+ const XML_Char *data)
+{
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::HandleProcessingInstruction() not yet implemented.");
+}
+
+void nsExpatTokenizer::HandleDefault(void *userData, const XML_Char *s, int len)
+{
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::HandleDefault() not yet implemented.");
+}
+
+void nsExpatTokenizer::HandleUnparsedEntityDecl(void *userData,
+ const XML_Char *entityName,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId,
+ const XML_Char *notationName)
+{
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::HandleUnparsedEntityDecl() not yet implemented.");
+}
+
+void nsExpatTokenizer::HandleNotationDecl(void *userData,
+ const XML_Char *notationName,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId)
+{
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::HandleNotationDecl() not yet implemented.");
+}
+
+void nsExpatTokenizer::HandleExternalEntityRef(XML_Parser parser,
+ const XML_Char *openEntityNames,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId)
+{
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::HandleExternalEntityRef() not yet implemented.");
+}
+
+void nsExpatTokenizer::HandleUnknownEncoding(void *encodingHandlerData,
+ const XML_Char *name,
+ XML_Encoding *info)
+{
+ NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::HandleUnknownEncoding() not yet implemented.");
+}
diff --git a/mozilla/parser/htmlparser/src/nsExpatTokenizer.h b/mozilla/parser/htmlparser/src/nsExpatTokenizer.h
index 138e86f5c9e..d7bc6002f45 100644
--- a/mozilla/parser/htmlparser/src/nsExpatTokenizer.h
+++ b/mozilla/parser/htmlparser/src/nsExpatTokenizer.h
@@ -29,7 +29,7 @@
#include "nsISupports.h"
#include "nsHTMLTokenizer.h"
#include "prtypes.h"
-#include "nsExpatDTD.h"
+#include "xmlparse.h"
#define NS_EXPATTOKENIZER_IID \
{0x483836aa, 0xcabe, 0x11d2, { 0xab, 0xcb, 0x0, 0x10, 0x4b, 0x98, 0x3f, 0xd4 }}
@@ -45,7 +45,7 @@
CLASS_EXPORT_HTMLPARS nsExpatTokenizer : public nsHTMLTokenizer {
public:
- nsExpatTokenizer(nsExpatDTD *aDTD=0);
+ nsExpatTokenizer();
virtual ~nsExpatTokenizer();
NS_DECL_ISUPPORTS
@@ -54,7 +54,51 @@ public:
virtual nsresult ConsumeToken(nsScanner& aScanner);
protected:
- nsExpatDTD *mExpatDTD;
+
+ /**
+ * Parse an XML buffer using expat
+ * @update nra 2/29/99
+ * @return NS_ERROR_FAILURE if expat encounters an error, else NS_OK
+ */
+ nsresult ParseXMLBuffer(const char *buffer);
+
+ /**
+ * Sets up the callbacks for the expat parser
+ * @update nra 2/24/99
+ * @param none
+ * @return none
+ */
+ void SetupExpatCallbacks(void);
+
+ /* The callback handlers that get called from the expat parser */
+ static void HandleStartElement(void *userData, const XML_Char *name, const XML_Char **atts);
+ static void HandleEndElement(void *userData, const XML_Char *name);
+ static void HandleCharacterData(void *userData, const XML_Char *s, int len);
+ static void HandleProcessingInstruction(void *userData,
+ const XML_Char *target,
+ const XML_Char *data);
+ static void HandleDefault(void *userData, const XML_Char *s, int len);
+ static void HandleUnparsedEntityDecl(void *userData,
+ const XML_Char *entityName,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId,
+ const XML_Char *notationName);
+ static void HandleNotationDecl(void *userData,
+ const XML_Char *notationName,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId);
+ static void HandleExternalEntityRef(XML_Parser parser,
+ const XML_Char *openEntityNames,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId);
+ static void HandleUnknownEncoding(void *encodingHandlerData,
+ const XML_Char *name,
+ XML_Encoding *info);
+
+ XML_Parser mExpatParser;
};
extern NS_HTMLPARS nsresult NS_Expat_Tokenizer(nsIDTD** aInstancePtrResult);
diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp
index 7d49933515d..2d6b29a8d6d 100644
--- a/mozilla/parser/htmlparser/src/nsParser.cpp
+++ b/mozilla/parser/htmlparser/src/nsParser.cpp
@@ -31,9 +31,6 @@
#include "CNavDTD.h"
#include "nsWellFormedDTD.h"
#include "nsViewSourceHTML.h" //uncomment this to partially enable viewsource...
-#ifdef EXPAT
- #include "nsExpatDTD.h"
-#endif
#undef rickgdebug
#ifdef rickgdebug
@@ -93,12 +90,7 @@ public:
nsIDTD* theDTD;
-#ifndef EXPAT
NS_NewWellFormed_DTD(&theDTD);
-#else
- NS_New_Expat_DTD(&theDTD);
-#endif
-
RegisterDTD(theDTD);
NS_NewNavHTMLDTD(&theDTD); //do this as the default HTML DTD...
diff --git a/mozilla/parser/htmlparser/src/nsWellFormedDTD.cpp b/mozilla/parser/htmlparser/src/nsWellFormedDTD.cpp
index 12fd485b7e0..7082fecc7f2 100644
--- a/mozilla/parser/htmlparser/src/nsWellFormedDTD.cpp
+++ b/mozilla/parser/htmlparser/src/nsWellFormedDTD.cpp
@@ -35,6 +35,9 @@
#include "nsIContentSink.h"
#include "nsIHTMLContentSink.h"
#include "nsXMLTokenizer.h"
+#ifdef EXPAT
+ #include "nsExpatTokenizer.h"
+#endif
#include "prenv.h" //this is here for debug reasons...
#include "prtypes.h" //this is here for debug reasons...
@@ -136,6 +139,10 @@ CWellFormedDTD::CWellFormedDTD() : nsIDTD() {
*/
CWellFormedDTD::~CWellFormedDTD(){
mParser=0; //just to prove we destructed...
+#ifdef EXPAT
+ if (mTokenizer)
+ delete (nsExpatTokenizer *) mTokenizer;
+#endif
}
/**
@@ -322,8 +329,13 @@ nsITokenRecycler* CWellFormedDTD::GetTokenRecycler(void){
* @return ptr to tokenizer
*/
nsITokenizer* CWellFormedDTD::GetTokenizer(void) {
- if(!mTokenizer)
+ if(!mTokenizer) {
+#ifndef EXPAT
mTokenizer=new nsXMLTokenizer();
+#else
+ mTokenizer = new nsExpatTokenizer();
+#endif
+ }
return mTokenizer;
}